This is a migrated thread and some comments may be shown as answers.

Create Bookmark programmatically.

3 Answers 158 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Jakub
Top achievements
Rank 1
Iron
Jakub asked on 13 Sep 2016, 10:26 AM

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.

3 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 16 Sep 2016, 08:40 AM
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.
0
Jakub
Top achievements
Rank 1
Iron
answered on 16 Sep 2016, 12:46 PM

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.

0
Tanya
Telerik team
answered on 21 Sep 2016, 12:02 PM
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 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.
Tags
RichTextBox
Asked by
Jakub
Top achievements
Rank 1
Iron
Answers by
Tanya
Telerik team
Jakub
Top achievements
Rank 1
Iron
Share this question
or