PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Migradoc - Insert TOC in the beginning of document
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3611
Page 1 of 1

Author:  Steven [ Sun Jun 25, 2017 10:30 pm ]
Post subject:  Migradoc - Insert TOC in the beginning of document

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

Author:  Thomas Hoevel [ Mon Jun 26, 2017 10:06 am ]
Post subject:  Re: Migradoc - Insert TOC in the beginning of document

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.

Author:  Steven [ Mon Jun 26, 2017 3:03 pm ]
Post subject:  Re: Migradoc - Insert TOC in the beginning of document

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?

Author:  Thomas Hoevel [ Mon Jun 26, 2017 3:23 pm ]
Post subject:  Re: Migradoc - Insert TOC in the beginning of document

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.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/