PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Nov 06, 2024 1:57 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Oct 29, 2024 3:04 pm 
Offline

Joined: Tue Oct 29, 2024 2:49 pm
Posts: 2
Hello, I recently started using Migradoc to generate a pdf.

I'm having trouble with headers and footers. I have found a way to use different headers and footers on odd or even pages. However, to prevent content overlapping the header or footer I need to set margin for the document. But I've currently not found a way to set a different margin for odd or even pages, as my headers have different height. Which causes inconsistencies, is this even possible ?

Here is a samble of what I'm trying to achieve :
Code:
var section = _document.AddSection();
section.PageSetup.OddAndEvenPagesHeaderFooter = true;
section.PageSetup.TopMargin  = Unit.FromCentimeter(3);
// Need another margin for even pages section.PageSetup.TopMargin = Unit.FromCentimeter(5);

var paragraph = section.Headers.Primary.AddParagraph()
paragraph.addText("odd header")

var paragraph2 = section.Headers.EvenPage.AddParagraph()
paragraph2.addText("even header")

var paragraph3 = section.Headers.EvenPage.AddParagraph()
paragraph2.addText("even header with more text")


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 29, 2024 3:59 pm 
Offline
PDFsharp Guru
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 1002
Location: CCAA
MigraDoc was designed with books in mind, so headers and footers are assumed to have the same height on all pages.

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


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 29, 2024 6:12 pm 
Offline

Joined: Tue Oct 29, 2024 2:49 pm
Posts: 2
Ok, thanks for your reply


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 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