PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Add a footer on Migradoc last page
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3901
Page 1 of 1

Author:  MyGoodWorld [ Mon Dec 31, 2018 12:30 pm ]
Post subject:  Add a footer on Migradoc last page

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.

Author:  TH-Soft [ Mon Dec 31, 2018 12:32 pm ]
Post subject:  Re: Add a footer on Migradoc last page

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

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/