Create Bookmark programmatically.

4 posts, 0 answers
  1. Jakub
    Jakub avatar
    14 posts
    Member since:
    Sep 2015

    Posted 13 Sep Link to this post

    Hi,

    i need to create PDF bookmarks programmatically and using RadDocument model api instead of RadDocumentEditor. 

    My code looks like this:

    // Create section with header, footer and two paragraphs.     
    Section section = new Section();
     
    // Create bookmark.
    var titleSpan = new Span(title);
    BookmarkRangeStart start = new BookmarkRangeStart(title);
    BookmarkRangeEnd end = new BookmarkRangeEnd();
    start.End = end;
    end.Start = start;
     
    Paragraph headingParagraph = new Paragraph() { StyleName = "Heading1" };
     
    // Insert inlines.
    headingParagraph.Inlines.Add(start);
    headingParagraph.Inlines.Add(titleSpan);
    headingParagraph.Inlines.Add(end);
     
    section.Blocks.Add(headingParagraph);
     
    this.radDocument.Sections.Add(section );

     

    but when I open document in AdobeReader there aren't any bookmarks.

    What's wrong with this code?

    Thank you.

  2. Tanya
    Admin
    Tanya avatar
    405 posts

    Posted 16 Sep Link to this post

    Hi Jakub,

    As I understand, when opening the document in Adobe Reader, you expect to see the bookmarks, known as document outlines. If so, the behavior you are currently observing is expected as the flow document formats are pretty different than PDF and the bookmarks are not converted to document outlines.

    In case you are using the bookmarks as links to a place in the document, I tested the functionality and it seems to work as expected.

    Regards,
    Tanya
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jakub
    Jakub avatar
    14 posts
    Member since:
    Sep 2015

    Posted 16 Sep Link to this post

    Hi,

    so Telerik's bookmarks created by me are not converted to document outlines (called in Adobe Reader "Bookmarks").

    Can I create those document outlines? Programatically and not using RadDocumentEditor.

    My goal is to create PDF document which can be opened from website on selected chapter using:

    <a href="MyDocument.pdf#nameddest=Chapter1">Chapter1</a>

    and as I found in web, 'nameddest' is name of AdobeReader's Bookmark - which means pdf document outline as I understand your reply.

    It works on downloaded random pdf document with outlines.

  5. Tanya
    Admin
    Tanya avatar
    405 posts

    Posted 21 Sep Link to this post

    Hi Jakub,

    Generally speaking, it is possible to add bookmarks in the PDF document when converting it from DOCX. However, this setting is not supported in RadRichTextBox and we have logged a feature request to implement it. You could vote for it as well as track its progress through the related public item.

    I am not sure if it will fit your requirements, but you could create links (on the first page, for example) pointing to a specific place in the document using the API of RadPdfProcessing. You could import the generated PDF, then insert the annotations and export it back to a .pdf file. Have in mind that using this approach won't allow you to directly open the document on a specific location.

    Hope this helps.

    Regards,
    Tanya
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top