BCL easyPDF SDK
easyPDF SDK Usermanual
PDF Creator Programming API  |  Download Free Trial  |  Contact Us to Purchase

ExtractAllBookmarks Method

Extracts all bookmarks from a PDF file and return an XML string to the caller.
The data contained in the XML string can be used to invoke AppendBookmark function in BCL easyPDF SDK for adding bookmarks in PDF file.

Function ExtractAllBookmarks() As String

string ExtractAllBookmarks()

String ExtractAllBookmarks() throws PDFProcessorException

Parameters

N/A.

Return Values

String in an XML format.

Sample XML string will look like the following:

<?xml version="1.0" encoding="utf-8" ?> 
<Bookmarks>
<Bookmark id="1" title="1. Introduction" depth="0" page="0"/>
<Bookmark id="2" title="1.1. Background" depth="1" page="0"/>
<Bookmark id="3" title="1.2. Investigational Agent" depth="2" page="0"/>
<Bookmark id="4" title="2. Study Objectives" depth="0" page="3"/>
<Bookmark id="5" title="3. Study Design" depth="0" page="3"/>
<Bookmark id="6" title="3.1. General Design" depth="1" page="3"/>
.........................................
.........................................
</Bookmarks>

Remarks

Note:
New attributes can be added to Bookmark element if needed and the ID attribute is important since it also stands for the order to invoke AppendBookmark () method.
Assumption: The user needs to know how to parse data from an XML string.

For those who are familiar with ExtractAllBookmarks from the PDFProcessor object, note that this version of ExtractAllBookmarks from the PDFProcessorHandle object does not take an optional password argument for working with encrypted PDF files. If and when PDFProcessorHandle is enhanced to support processing of encrypted PDF files, the password required will be taken by OpenFile or OpenMem at the time the PDFProcessorHandle is obtained.

Example Usage in VBScript

Set oProcessor = CreateObject("easyPDF.PDFProcessor.8")

Set oProcessorHandle = oProcessor.OpenFile("C:\test\input.pdf", "C:\test\input.pdf")

bookmarks = oProcessorHandle.ExtractAllBookmarks

oProcessorHandle.Close
MsgBox bookmarks

Example Usage in VB.NET

Dim oProcessor As PDFProcessor = New PDFProcessor
Dim oProcessorHandle As PDFProcessorHandle = oProcessor.OpenFile("C:\test\input.pdf", "C:\test\input.pdf")

Dim bookmarks As String = oProcessorHandle.ExtractAllBookmarks()

oProcessorHandle.Close()
File.WriteAllText("C:\test\bookmarks.xml", bookmarks)

Example Usage in C#

PDFProcessor oProcessor = new PDFProcessor();
PDFProcessorHandle oProcessorHandle = oProcessor.OpenFile(@"C:\test\input.pdf", @"C:\test\input.pdf", null);

string bookmarks = oProcessorHandle.ExtractAllBookmarks();

oProcessorHandle.Close();
File.WriteAllText(@"C:\test\bookmarks.xml", bookmarks);