PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 11:33 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: header
PostPosted: Sat Nov 09, 2019 12:11 am 
Offline

Joined: Sun Nov 03, 2019 7:51 pm
Posts: 47
Hi

Is it possible in MigraDoc to make headers that are different on EACH page? (I don't mean even/odd pages).
I want to set a header specific for each page.


Top
 Profile  
Reply with quote  
 Post subject: Re: header
PostPosted: Sat Nov 09, 2019 8:15 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
Hi!
Jessica wrote:
I want to set a header specific for each page.
There are no pages when you create a MigraDoc document.
Start a new Section - Headers and Footers are set per section.

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


Top
 Profile  
Reply with quote  
 Post subject: Re: header
PostPosted: Sat Nov 09, 2019 7:09 pm 
Offline

Joined: Sun Nov 03, 2019 7:51 pm
Posts: 47
thx this works!

But now my page number in the footer doesn't work. I do this code for each section I make:

Code:
// Create a paragraph with centered page number. See definition of style "Footer".
Paragraph paragraph = new Paragraph();
paragraph.AddTab();
paragraph.AddPageField();

// Add paragraph to footer
section.Footers.Primary.Add(paragraph);


Can you tell me please how to make page number work ?
I have page numbers but each page has page number "1"


Top
 Profile  
Reply with quote  
 Post subject: Re: header
PostPosted: Sat Nov 09, 2019 7:43 pm 
Offline

Joined: Sun Nov 03, 2019 7:51 pm
Posts: 47
So to make a summary:

- I make a new section in order to make a header specific for that section => this works!

- but because I make new sections (to have different headers), the page numbers (in the footer) don't work anymore. They start at 1 again on each new section

How can I make page numbers (in the footer) work when creating new sections in the pdf?
If I don't create new sections, they work.


Top
 Profile  
Reply with quote  
 Post subject: Re: header
PostPosted: Mon Nov 11, 2019 8:56 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
You specify the starting page number when you start a new section. Leave the page number empty to get consecutive page numbers. This is the default behavior, so you just have to remove the line that always sets the start to 1.

For serial letters it makes sense to always start at 1.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

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