Click here to Skip to main content
15,887,464 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.
C#
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();
Posted
v2

1 solution

Please see this bookmark tutorial: Adding bookmarks (iText 5).

—SA
 
Share this answer
 
Comments
Nachiappan Rajendran 25-Jun-16 7:32am    
How to import the exported bookmark to another pdf? This shows we can export to xml but in which way we can import this xml?
Sergey Alexandrovich Kryukov 25-Jun-16 9:40am    
It shows how to add bookmarks to PDF. It says nothing about import/export. Now, you say "import bookmarks from XML to existing PDF". It means that bookmarks are added to PDF.
—SA
Nachiappan Rajendran 26-Jun-16 23:31pm    
I have two pdf, one pdf is bookmarked(1) another one is not having bookmarks(2). I have success on exporting bookmarks from one pdf(1) to xml file and I am struggling in the import section from exported xml to another pdf(2). I am searching/looking that solution only, I hope now my requirement is clear to you.
Sergey Alexandrovich Kryukov 27-Jun-16 1:50am    
Please see my previous comment.
—SA
Nachiappan Rajendran 27-Jun-16 23:45pm    
Yes Sergey... bookmarks are added to first pdf, I need to extract that bookmark and import to second pdf(which bookmarks are not contain currently)

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