PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun Jun 25, 2017 10:30 pm 
Offline

Joined: Sun Jun 25, 2017 10:00 pm
Posts: 4
Hello,

I used Migradoc to create a section of blank pages and I added bookmarks to the contents. Then I added the contents by importing from several PDFs using PDFSharp GFI api.

To make the TOC using the bookmarks, how can I prepend the TOC page in the beginning of the document. It seems like Migradoc only has the AddSection() function which adds the page to the end of the document. I tried to create the TOC section in the beginning of the document and leave it blank. But I do not know how to navigate to the page after I populated the contents. I also tried to create another document object for the TOC and use RenderPage() function to prepend the TOC back to the document with the content. But Migradocs failed to work with the page links when using the AddPageRef(). Can you please show me an code example how to make the TOC in the first page?

In terms of building TOC, can you also provide some template code to use that already formatted the TOC nicely? (i.e. with tabs and trailing dots, etc...) It helps me so I do not have build it from scratch completely.

Thanks,
Steven


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 26, 2017 10:06 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Hi!

The Hello MigraDoc sample shows how to create a TOC:
http://www.pdfsharp.net/wiki/HelloMigraDoc-sample.ashx

You have to add a section for the TOC right from the start, but you can leave it empty.

You can add the PDF pages using MigraDoc's AddImage method. A file name like "test.pdf#7" tells MigraDoc to use the 7th page from that PDF file.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 26, 2017 3:03 pm 
Offline

Joined: Sun Jun 25, 2017 10:00 pm
Posts: 4
Hello!

Sorry, can you please explain again?

If I have to add a section for the TOC right from the start and leave it empty.
How can I navigate back the TOC page to create the TOC after I build the bookmark and populate the rest of the content?


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 26, 2017 3:23 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
A call to "AddSection()" returns the new section. Store this result in a variable/member for future use.

You can use the "Sections" property of the "Document" class to access any section of the document at any time.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

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