First page in Migradoc PDF file should not have page header. All remaining pages should have same header. I tried
var document = new Document { }; var Section = document.AddSection(); Section.PageSetup = document.DefaultPageSetup.Clone(); Section.PageSetup.DifferentFirstPageHeaderFooter = true; Section.Headers.Primary.AddParagraph("Page header for all pages except first page"); Section.PageSetup.TopMargin = "1cm"; Section.PageSetup.HeaderDistance = 0; for (int i = 1; i < 77; i++) Section.AddParagraph("Line " + i);
But this adds empty space in top of first page:
If
Section.PageSetup.TopMargin = "0cm";
Is used, header overlaps with contents:
How to add header starting from second page so that there is no empty space in start of first page ?
Negative SpaceBefore for first paragraph in page fixes the issue. Since this is ignored for first paragraph, it requires adding dummy zero-heigth paragraph before it. DifferentFirstPageHeaderFooter also requires duplicating footerfor first and remaining pages.
Should those hacks used?
Using .NET Core PdfSharp-Migradoc
Footer distance applies to all headers.
SpaceBefore
seems like an approach for the first page. Yes, a dummy paragraph is required.
Maybe a dummy paragraph with a negative SpaceAfter
can also be used - I did not try this.