PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 6:32 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: Fri Oct 20, 2023 8:50 pm 
Offline

Joined: Mon Aug 07, 2023 9:07 pm
Posts: 7
First page in Migradoc PDF file should not have page header.
All remaining pages should have same header.
I tried

Code:
             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 also empty space in top of first page:

If

Quote:
Section.PageSetup.TopMargin = "0cm";

Is used, header overlaps with contents:

Image

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


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 23, 2023 12:07 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 916
Location: CCAA
andrus wrote:
How to add header starting from second page so that there is no empty space in start of first page?
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.

_________________
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 362 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