PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun May 12, 2024 11:26 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Dec 04, 2009 9:15 pm 
Offline

Joined: Fri Dec 04, 2009 9:03 pm
Posts: 2
Greetings, I am a first time user of PDFSharp and it works great. But I am having problems getting Bookmarks (the PDF Outline) to appear in my document. I have a folder that contains multiple PDF files in which I am merging. When each file is merged, I want to create an outline entry for it. Here is the code.

Dim fiBaseFiles As FileInfo
Dim pdfMerge As New PdfDocument
Dim pdfBookmark As PdfOutline

' Loop through the files and merge
Try
For Each fiBaseFiles In disSubPDFDirectory.GetFiles()
Dim pdfBase As PdfDocument = PdfReader.Open(strPDFPath & "\" & fiBaseFiles.Name, PdfDocumentOpenMode.Import)

For intX = 0 To pdfBase.PageCount - 1
Dim pdfPage As PdfPage = pdfBase.Pages(intX)

pdfMerge.AddPage(pdfPage)

If intX = 0 Then
pdfBookmark = pdfBase.Outlines.Add(fiBaseFiles.Name, pdfPage, True)
End If
Next
Next

The merged PDF is being created but there is not an outline that is being produced. Am I doing this correctly?

Greg


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 07, 2009 12:14 pm 
Offline
PDFsharp Guru
User avatar

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

Try
Code:
pdfMerge.Outlines.Add

instead of
Code:
pdfBase.Outlines.Add


Maybe this helps ...

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 08, 2009 9:28 pm 
Offline

Joined: Fri Dec 04, 2009 9:03 pm
Posts: 2
Thank you for the help. This pointed me in the right direction. You were correct in that I was using my input file as trying to put the Outline (duh). I also had to add the page definition for the output page and it it worked fine. Here is the final code for others to view.

Dim fiBaseFiles As FileInfo 'The individual files in the report directory
Dim pdfMerge As PdfDocument = New PdfDocument() 'The new merged PDF, i.e. the plan
Dim pdfMergePage As PdfPage 'Each page of the merged (Plan) PDF
Dim pdfBookmark As PdfOutline 'The PDF bookmarks for the plan

' Loop through the files and merge.
Try
For Each fiBaseFiles In disSubPDFDirectory.GetFiles()
Dim pdfBase As PdfDocument = PdfReader.Open(strPDFPath & "\" & fiBaseFiles.Name, PdfDocumentOpenMode.Import)
For intX = 0 To pdfBase.PageCount - 1
Dim pdfBasePage As PdfPage = pdfBase.Pages(intX)
pdfMergePage = pdfMerge.AddPage(pdfBasePage)
If intX = 0 Then
pdfBookmark = pdfMerge.Outlines.Add(fiBaseFiles.Name), pdfMergePage, True)
End If
Next
Next


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

All times are UTC


Who is online

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