You must Sign In to post a response.
  • Category: ASP.NET

    How to Import Bookmark from xml to existing pdf?

    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.

    Here I am attaching my code.


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

  • #766741

    I never worked on such scenario, but as per my understanding I give you one suggestion, as you said you can export controls to pdf is working fine but you are struggling to export one pdf to another pdf, my suggestion is rather than export one pdf to another simply export pdf to some control ex gridview and from that control to again export to pdf.

    I'm not sure whether it works in your case, but I just give you some suggestion.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #766745
    No, Naveen you are misunderstood. I can export bookmark from pdf and struggling for to import the bookmark to pdf.

  • #766751
    I haven't tried this ever, but I guess merging both pdf will help to add the bookmark in merged pdf. Just look at the sample code below and see if it helps.

    Asheej T K

  • #766753
    I don`t need to combine pdf or bookmarks. I need to import the bookmark to existing pdf which does not have bookmark.

  • #766774
    But I don`t need to merge pdf, my only need to import the bookmark (Which is stored in xml) to another pdf.

  • #766784

    PDF bookmarks are actually a area in pdf file where are jump in, do you have a area co-ordinates in XML to set them in PDF, I think first you need make a demo to create a bookmark in pdf, here are some good links that you can work on

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #766875
    Please refer once tesaract ocr you may get the desired result and for that matter PDF readers too. Please check once with Tesaract Optical character Recognition.

  • #766900
    Thanks prasad, I will try your solution. Actually In xml files contains position of the text and bookmark details only. Lets I try your suggest and get back if I face any issue.

  • #767172
    check these links

  • Sign In to post your comments