PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Footer Alignment https://forum.pdfsharp.net/viewtopic.php?f=2&t=1870 |
Page 1 of 1 |
Author: | tulips [ Tue Dec 13, 2011 11:15 am ] |
Post subject: | Footer Alignment |
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 |
Author: | Thomas Hoevel [ Tue Dec 13, 2011 1:20 pm ] |
Post subject: | Re: Footer Alignment |
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. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |