PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jul 14, 2024 7:01 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Thu Jan 10, 2013 9:42 pm 
Offline

Joined: Thu Jan 10, 2013 9:34 pm
Posts: 4
Is there a way to get the heading/title into the header and footer? And if the content for that heading/title carries over into a new page, that new page will need to display the same heading/title in the header and footer.

I have attached and image as an example. The footer in the example is not the first page under the "General Information" Section, but it would need to be on all the pages that the heading/title of "General Information" spills into.


Attachments:
footer.JPG
footer.JPG [ 9.92 KiB | Viewed 10259 times ]
Top
 Profile  
Reply with quote  
PostPosted: Fri Jan 11, 2013 6:30 am 
Offline

Joined: Thu Jan 10, 2013 8:29 pm
Posts: 10
This can be done via "Sections" in MigraDoc.

All you need is to start a new section for each chapter, whichs name shall appear in header/footer.

You always have to redefine your PageSetup (offsets/margins if they are not default).
But you can also specifiy specific text for header and footer for this section.

My code looks like this:

foreach(Chapter chpt in newPageChapterList)
{
Section section = doc.AddSection();
definePageSetup(section);
defineHeaderAndFooter(section, chpt.Title);
}

and within "defineHeaderAndFooter" (I did it for header, but you just have to do it for footer):

HeaderFooter header = section.Headers.Primary;
TextFrame tf = header.AddTextFrame();
... // layouting my headers textframe
Paragraph par = tf.AddParagraph(title);
... // layouting of the text

See my result below


Attachments:
example.png
example.png [ 10.07 KiB | Viewed 10254 times ]
Top
 Profile  
Reply with quote  
PostPosted: Fri Jan 11, 2013 2:39 pm 
Offline

Joined: Thu Jan 10, 2013 9:34 pm
Posts: 4
If you start a new section, doesn't it start the page numbering over again. I am working on a legal document that needs continuous page numbering, but also needs the "section" number (of the legal document, not of the section number in relation to pdfsharp) in the header and footer.

Am I clear with my problem?

So the footer of the first page would have "Page 1, Section 1.1". If Section 1.1 carrries into page two, then the footer of page two would be "Page 2, Section 1.1". Then the footer of page three would be "Page 3, Section 1.2" if section 1.2 start on page two but did not finish or was the first thing on page three.


Top
 Profile  
Reply with quote  
PostPosted: Sat Jan 12, 2013 10:42 am 
Offline

Joined: Thu Jan 10, 2013 8:29 pm
Posts: 10
I am not clear, if understand your issue correctly.

Every Section automatically starts on a new page. So yes, if you have sub chapters (for which you don't start a new section), these won't be visible in section header/footer.
Resulting you have to differ between "new page chapters" and "sub chapters".
And - with my solution - then only the "new page chapter" titles are visible in header/footer.
For me this was no problem, because in my oppinion, it is more important for orientation to see the "top chapter" in header, than to see only the current active chapter.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 14, 2013 10:09 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
natemobley wrote:
If you start a new section, doesn't it start the page numbering over again.
You can set the starting page number for each section. If you don't set it, you get what you expect (1, 2, 3, 4, 5, ...) as the new section continues the count of previous sections.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 14, 2013 2:21 pm 
Offline

Joined: Thu Jan 10, 2013 9:34 pm
Posts: 4
So Thomas can I retrieve the last used number from the previous section? If so then I can just make the next section start one number higher.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 14, 2013 2:28 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
natemobley wrote:
So Thomas can I retrieve the last used number from the previous section? If so then I can just make the next section start one number higher.
That's the default behavior (what you get when you don't do anything about page numbers).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 14, 2013 2:36 pm 
Offline

Joined: Thu Jan 10, 2013 9:34 pm
Posts: 4
Yes. Sorry. I just re-read your post and saw that. Thank you.

And thanks MakroDoccer. Your solution isn't exactly what I am looking for, but it does give me an idea of how to accomplish it.


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 48 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