|
-
Oct 8th, 2010, 04:07 PM
#10
Re: [VB.NET] Extract Pages and Split Pdf Files Using iTextSharp
 Originally Posted by blofvendahl
Hey Stanav,
Which method in your class, if any, can be used to extract bookmark info from a pdf?
thanks
Brian
You can use the SimpleBookmark class to extract all the bookmarks in a pdf and export it to an XML file if you want to. Here's how you do it
Code:
Public Shared Function ExportBookmarksToXML(ByVal sourcePdf As String, ByVal outputXML As String) As Boolean
Dim result as Boolean = False
Try
Dim reader As New iTextSharp.text.pdf.PdfReader(sourcePdf)
Dim bookmarks As System.Collections.Generic.List(Of System.Collections.Generic.Dictionary(Of String, Object)) = SimpleBookmark.GetBookmark(reader)
Using outFile As New IO.StreamWriter(outputXML)
SimpleBookmark.ExportToXML(bookmarks, outFile, "ISO8859-1", True)
End Using
reader.Close()
result = True
Catch ex As Exception
Throw New ApplicationException(ex.Message, ex)
End Try
Return result
End Function
I'm also working on a method to merge pdf files with all bookmarks preserved. However, it works only with bookmarks that use the page number as the destination. Bookmarks that use named destination get broken after merged (that is you still see all the bookmarks but it doesn't work (go to a destination) when clicked on). That's why I'm not posting the solution yet.
Last edited by stanav; Oct 12th, 2010 at 07:45 AM.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|