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

Adding a bookmark to imported page.
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2402
Page 1 of 1

Author:  MonkFox [ Fri Apr 05, 2013 6:50 pm ]
Post subject:  Adding a bookmark to imported page.

Ok, so I'm having an issue.

I create my document with MigraDoc. Define headerfooter, content and etc.
Throughout the content I'm adding paragraphs with local/bookmark links. Also
adding a AddPageRefLink().
Then I call DocumentRenderer.RenderDocument() after assigning its Document property.

Then I loop through some attachments and add them to the document with DocumentRenderer.PdfDocument.AddPage()
I also add an outline to that imported document (pdf) with:
DocumentRenderer.PdfDocument.Outlines.Add()

The problem is, that when I call RenderDocument, its only rendering the MigraDoc content that was added. So out beside the local/bookmark links it says "Bookmark 'x' is not defined within the document."

How can I define book mark links in the MigraDoc document I create to work globally after I've added external pdf pages to it?

Thanks,

Justin

Author:  Thomas Hoevel [ Mon Apr 08, 2013 9:17 am ]
Post subject:  Re: Adding a bookmark to imported page.

You can add pages to your MigraDoc document using AddImage. Use "sample.pdf#17" to get page 17 from a PDF file.
For "invisible" bookmarks, I used a hack: the bookmark text was white and had font size 0.01 points.

Use AddPageBreak(), AddParagraph(), AddImage(), and AddPageBreak(). You can set the absolute position of the image to have it fill the whole page (with "invisible" bookmark) or draw the image within the page margins with a visible paragraph for the bookmark.

This way, all pages will be created by MigraDoc and all links will work.

Author:  MonkFox [ Wed Apr 17, 2013 4:47 pm ]
Post subject:  Re: Adding a bookmark to imported page.

Thanks for the reply. The only problem is that these attachments are almost always PDF documents. I couldn't find a way to get the pdf to an image to add to the document.

I just created the document, got the page count, created list of page ranges for the documents going to be added, created the document again with the page range text and then added the attachments with a bookmark that was exactly the same as the page range text in the original document.

That way as they are scrolling through the document, they can see the corresponding bookmark in the outline browser and click on it.

Thanks again!

Justin

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