PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 5:13 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
PostPosted: Mon Dec 31, 2018 12:30 pm 
Offline

Joined: Fri Dec 21, 2018 5:55 pm
Posts: 1
I need to add a footer on the MigraDoc. The following code adds footer to all the pages.

The page has a header which needs to appear on each page.

Code:
Document document = new Document();
 PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(false);
 Section HeaderSection = document.AddSection();
 HeaderSection.PageSetup.DifferentFirstPageHeaderFooter = false;

 MigraDoc.DocumentObjectModel.Shapes.Image image = HeaderSection.Headers.Primary.AddImage("../images/logo.jpg");
 image.Height = new Unit(65);
 image.Width = new Unit(150);
 image.LockAspectRatio = false;
 image.RelativeVertical = RelativeVertical.Line;
 image.RelativeHorizontal = RelativeHorizontal.Margin;

 Paragraph ParaHead1 = HeaderSection.AddParagraph();
 Parahead1.AddFormattedText("..dfg");
 Table table = HeaderSection.Footers.Primary.AddTable();
 table.Borders.Width = 0;

 Column column = table.AddColumn();
 column.Width =Unit.FromPoint(300);
 column.Format.Alignment = ParagraphAlignment.Left;
 Column column1 = table.AddColumn();
 column1.Width = Unit.FromPoint(200);
 column1.Format.Alignment = ParagraphAlignment.Left;
 Row row = table.AddRow();

 Cell cell = row.Cells[0];
 cell.AddParagraph("Regards,");
 cell = row.Cells[1];
 Paragraph para1 = cell.AddParagraph();
 para1.AddFormattedText("Support Team");


I need the footer table to appear only on the last page.

The formatted text in the first para is dynamic so the text can flow to the next page and i don't want the footer on the first page just in case the text flows to the next page.

I don't want add to add the last paragraph as the table as the footer as that will cause the footer to appear just appear the text.


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 31, 2018 12:32 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
You cannot use the MigraDoc footers for a footer on the last page only.

To achieve this effect, you have to add the text to the main body - or draw the footer later using PDFsharp.

You can use a TextFrame to have the footer at a fixed location, but you must take care that the TextFrame will not overlap with other main body content.

https://stackoverflow.com/a/53985118/1015447

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


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 125 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