Table of Contents

Class SimpleBookmark

Namespace
iTextSharp.text.pdf
Assembly
iTextSharp.LGPLv2.Core.dll

Bookmark processing in a simple way. It has some limitations, mainly the only action types supported are GoTo, GoToR, URI and Launch. The list structure is composed by a number of Hashtable, keyed by strings, one Hashtable for each bookmark. The element values are all strings with the exception of the key "Kids" that has another list for the child bookmarks. All the bookmarks have a "Title" with the bookmark title and optionally a "Style" that can be "bold", "italic" or a combination of both. They can also have a "Color" key with a value of three floats separated by spaces. The key "Open" can have the values "true" or "false" and signals the open status of the children. It's "true" by default. The actions and the parameters can be: "Action" = "GoTo" - "Page" | "Named" "Page" = "3 XYZ 70 400 null" - page number followed by a destination (/XYZ is also accepted) "Named" = "named_destination" "Action" = "GoToR" - "Page" | "Named" | "NamedN", "File", ["NewWindow"] "Page" = "3 XYZ 70 400 null" - page number followed by a destination (/XYZ is also accepted) "Named" = "named_destination_as_a_string" "NamedN" = "named_destination_as_a_name" "File" - "the_file_to_open" "NewWindow" - "true" or "false" "Action" = "URI" - "URI" "URI" = "http://sf.net" - URI to jump to "Action" = "Launch" - "File" "File" - "the_file_to_open_or_execute" @author Paulo Soares (psoares@consiste.pt)

public sealed class SimpleBookmark : ISimpleXmlDocHandler
Inheritance
SimpleBookmark
Implements
Inherited Members

Methods

EliminatePages(IList<INullValueDictionary<string, object>>, int[])

Removes the bookmark entries for a number of page ranges. The page ranges consists of a number of pairs with the start/end page range. The page numbers are inclusive.

public static void EliminatePages(IList<INullValueDictionary<string, object>> list, int[] pageRange)

Parameters

list IList<INullValueDictionary<string, object>>

the bookmarks

pageRange int[]

the page ranges, always in pairs.

EndDocument()

Called after the document is parsed.

public void EndDocument()

EndElement(string)

public void EndElement(string tag)

Parameters

tag string

EscapeBinaryString(string)

public static string EscapeBinaryString(string s)

Parameters

s string

Returns

string

ExportToXml(IList<INullValueDictionary<string, object>>, Stream, string, bool)

Exports the bookmarks to XML. The DTD for this XML is: <?xml version='1.0' encoding='UTF-8'?> <!ELEMENT Title (#PCDATA|Title)*> <!ATTLIST Title Action CDATA #IMPLIED Open CDATA #IMPLIED Page CDATA #IMPLIED URI CDATA #IMPLIED File CDATA #IMPLIED Named CDATA #IMPLIED NamedN CDATA #IMPLIED NewWindow CDATA #IMPLIED Style CDATA #IMPLIED Color CDATA #IMPLIED

<!ELEMENT Bookmark (Title)*> whatever the encoding @throws IOException on error

public static void ExportToXml(IList<INullValueDictionary<string, object>> list, Stream outp, string encoding, bool onlyAscii)

Parameters

list IList<INullValueDictionary<string, object>>

the bookmarks

outp Stream

the export destination. The stream is not closed

encoding string

the encoding according to IANA conventions

onlyAscii bool

codes above 127 will always be escaped with &#nn; if true ,

ExportToXml(IList<INullValueDictionary<string, object>>, TextWriter, string, bool)

Exports the bookmarks to XML. whatever the encoding @throws IOException on error

public static void ExportToXml(IList<INullValueDictionary<string, object>> list, TextWriter wrt, string encoding, bool onlyAscii)

Parameters

list IList<INullValueDictionary<string, object>>

the bookmarks

wrt TextWriter

the export destination. The writer is not closed

encoding string

the encoding according to IANA conventions

onlyAscii bool

codes above 127 will always be escaped with &#nn; if true ,

ExportToXmlNode(IList<INullValueDictionary<string, object>>, TextWriter, int, bool)

Exports the bookmarks to XML. Only of use if the generation is to be include in some other XML document. whatever the encoding @throws IOException on error

public static void ExportToXmlNode(IList<INullValueDictionary<string, object>> list, TextWriter outp, int indent, bool onlyAscii)

Parameters

list IList<INullValueDictionary<string, object>>

the bookmarks

outp TextWriter

the export destination. The writer is not closed

indent int

the indentation level. Pretty printing significant only

onlyAscii bool

codes above 127 will always be escaped with &#nn; if true ,

GetBookmark(PdfReader)

Gets a List with the bookmarks. It returns null if the document doesn't have any bookmarks. document doesn't have any

public static IList<INullValueDictionary<string, object>> GetBookmark(PdfReader reader)

Parameters

reader PdfReader

the document

Returns

IList<INullValueDictionary<string, object>>

a List with the bookmarks or null if the

ImportFromXml(Stream)

Import the bookmarks from XML. @throws IOException on error

public static List<INullValueDictionary<string, object>> ImportFromXml(Stream inp)

Parameters

inp Stream

the XML source. The stream is not closed

Returns

List<INullValueDictionary<string, object>>

the bookmarks

ImportFromXml(TextReader)

Import the bookmarks from XML. @throws IOException on error

public static List<INullValueDictionary<string, object>> ImportFromXml(TextReader inp)

Parameters

inp TextReader

the XML source. The reader is not closed

Returns

List<INullValueDictionary<string, object>>

the bookmarks

IterateOutlines(PdfWriter, PdfIndirectReference, IList<INullValueDictionary<string, object>>, bool)

public static object[] IterateOutlines(PdfWriter writer, PdfIndirectReference parent, IList<INullValueDictionary<string, object>> kids, bool namedAsNames)

Parameters

writer PdfWriter
parent PdfIndirectReference
kids IList<INullValueDictionary<string, object>>
namedAsNames bool

Returns

object[]

ShiftPageNumbers(IList<INullValueDictionary<string, object>>, int, int[])

For the pages in range add the pageShift to the page number. The page ranges consists of a number of pairs with the start/end page range. The page numbers are inclusive. to include all the pages

public static void ShiftPageNumbers(IList<INullValueDictionary<string, object>> list, int pageShift, int[] pageRange)

Parameters

list IList<INullValueDictionary<string, object>>

the bookmarks

pageShift int

the number to add to the pages in range

pageRange int[]

the page ranges, always in pairs. It can be null

StartDocument()

Called when the document starts to be parsed.

public void StartDocument()

StartElement(string, INullValueDictionary<string, string>)

public void StartElement(string tag, INullValueDictionary<string, string> h)

Parameters

tag string
h INullValueDictionary<string, string>

Text(string)

public void Text(string str)

Parameters

str string

UnEscapeBinaryString(string)

public static string UnEscapeBinaryString(string s)

Parameters

s string

Returns

string