Click here to Skip to main content
15,888,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am currently working on pdf projects (dotnet/c#[Itextsharp pdf]), I want to export and import bookmarks from one pdf to another pdf (both pdf are having same content, only difference are with bookmark/without bookmark and one is normal pdf and another linked pdf). Exporting bookmarks to xml is working fine but I don`t have the idea of importing exported bookmark(xml) to another pdf. Can any body suggest solution.

What I have tried:

Here I am attaching my code.

string inputpdf = "D:\\chapter1.pdf"; string outputbookmark="D:\\chapter1Bookmark.xml";
PdfReader reader = new PdfReader(inputpdf);
IList<dictionary><string,>> bookmarks = SimpleBookmark.GetBookmark(reader);
using (StreamWriter Sw = new StreamWriter(outputbookmark))
{
SimpleBookmark.ExportToXML(bookmarks, Sw,"ISO8859-1", true);

}
reader.Close();


My xml output file is


<bookmark>
<Title Color="0 0 0" Page="1 XYZ 36 806" Action="GoTo" >Introduction</Title>
<Title Color="0 0 0" Page="1 XYZ 36 410" Action="GoTo" >Getting Started
<Title Color="0 0 0" Page="1 XYZ 36 364" Action="GoTo" >Printing a test page</Title>
<Title Color="0 0 0" Page="4 XYZ 36 740" Action="GoTo" >Accessing the novaPDF Printing Preferences – test the multiline bookmark detection option</Title>
<Title Color="0 0 0" Page="5 XYZ 36 806" Action="GoTo" >Creating PDF Files</Title>
</Title>


My Pdf file available in

http://www.novapdf.com/uploads/novapdf_en/media_items/pdf-example-bookmarks.original.pdf
Posted
Updated 24-Jun-16 21:45pm

1 solution

You really need a copy of "iText in Action" (Chapter 7) Books | iText Developers[^] to understand the iTextsharp example dealing with bookmarks https://sourceforge.net/p/itextsharp/code/HEAD/tree/book/iTextExamplesWeb/iTextExamplesWeb/iTextInAction2Ed/Chapter07/BookmarkedTimeTable.cs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900