PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Jul 18, 2024 10:21 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Footer Alignment
PostPosted: Tue Dec 13, 2011 11:15 am 
Offline

Joined: Tue Nov 08, 2011 12:24 pm
Posts: 22
Hello!

I have got the footer alignment problem. I need to put 3 fields in footers. On the right, center and left alignments. I am getting only one of them right depending on the paragraph alignment. I can add AddTab to put it somewhere in center but then the right one doesn't align well and leaves some space. This is my code:

style = document.Styles[StyleNames.Footer];
style.ParagraphFormat.AddTabStop("1cm", TabAlignment.Right);

// Create a paragraph with page number. See definition of style "Footer".
DateTime dt = DateTime.Today;
string date = String.Format("{0:MM/dd/yyyy}", dt);
Paragraph paragraph = new Paragraph();
paragraph.Format.Borders.Top.Visible = true;
paragraph.AddText(name); // N
paragraph.AddTab(); paragraph.AddTab(); paragraph.AddTab(); paragraph.AddTab();
paragraph.AddText("Seite ");
paragraph.AddPageField();
paragraph.AddTab(); paragraph.AddTab(); paragraph.AddTab(); paragraph.AddTab();
paragraph.AddTab(); paragraph.AddTab(); paragraph.AddTab();
paragraph.AddText(date); // N
paragraph.Format.Alignment = ParagraphAlignment.Left;

Can you help?

Thanks,
tulips


Top
 Profile  
Reply with quote  
 Post subject: Re: Footer Alignment
PostPosted: Tue Dec 13, 2011 1:20 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Simple thing: make the paragraph left-aligned, create two tabs (e.g. center-aligned in the middle, right-aligned at/near the right margin.

This code snippet creates two tabstops for a style (e.g. the Footer style):
Code:
style.ParagraphFormat.TabStops.ClearAll();
style.ParagraphFormat.TabStops.AddTabStop(Unit.FromMillimeter(80), TabAlignment.Center);
style.ParagraphFormat.TabStops.AddTabStop(Unit.FromMillimeter(158), TabAlignment.Right);


Add the left-aligned text, then "paragraph.AddTab();" and the centered text, then "paragraph.AddTab();" and the right-aligned text.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 39 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group