Welcome Guest Search | Active Topics | Sign In | Register

Linking to bookmarks across PdfDocuments Options
Exameron
Posted: Thursday, November 2, 2017 8:59:57 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
As expected, when I create a bookmark within a HtmlToPdfResult, then to a PdfDocument, then finally merge with another PdfDocument everything works fine (the parent PdfDocument understands and merges the Bookmark).

If I create an anchor link to that bookmark within the html (and within the same original PDF document) everything is fine.

However, if I create an anchor link within a separate PdfDocument that I merge, it does not work. Is it possible to link to bookmarks from PdfDocuments that are merged?


Thanks.
Exameron
Posted: Thursday, November 2, 2017 10:42:00 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
The main issue is that I need to create include a number of different styles for pages within a single PdfDocument. Title page has a white background and no footer, Chapter dividers have another background color and no footer, Then the rest has yet another background color and does have the footer.

To achieve this, I create a number of PdfDocuments and merge them together at the end.

It works great visually, but I dont seem to be able to link between them. Ideally, I'd like to be able to make the PDF highly interactive with bookmarks and a href links that target those bookmarks through out the merged pdf.

Thanks for your help on this!
Exameron
Posted: Thursday, November 2, 2017 11:05:24 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
Alternatively, I could create the Pdf as a single document in the first place. Is there a way of detecting (and intercepting) the page that's being rendered? If somehow during On_BeforeRenderPage I could detect something from the page like an h1 tag value?
eo_support
Posted: Friday, November 3, 2017 8:02:00 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Hi,

Have you tried to use this version of the Merge function?

https://www.essentialobjects.com/doc/eo.pdf.pdfdocument.merge_overload_3.aspx

Thanks!
Exameron
Posted: Sunday, November 5, 2017 6:00:18 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
I believe that's the one I'm using. I've included a couple of snippets below to demonstrate (this is not the full code)

I initially set:

Code:
List<HtmlToPdfResult> results = new List<HtmlToPdfResult>();


In a loop, I do:

Code: C#
PdfDocument pdfDocument = new PdfDocument();
HtmlToPdfResult contentResult = EO.Pdf.HtmlToPdf.ConvertHtml(html, pdfDocument, htmlToPdfOptions);

results.Add(contentResult);




Then afterwards,

Code: C#
PdfDocument pdfDocument = PdfDocument.Merge(results.ToArray());


However, any links between Pdf's that get merged do not work.
Exameron
Posted: Sunday, November 5, 2017 6:22:21 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
By the way - just in case this is the problem - here's how the links look:

The link in the 2nd HtmlToPdfResult
Code: HTML/ASPX
<a class="" href="#SectionAppendixChapterDividerPage"><span>Appendix</span></a>


The destination in the 1st HtmlToPdfResult
Code: HTML/ASPX
<div id="SectionAppendixChapterDividerPage" name="SectionAppendixChapterDividerPage" class="chapter_title" style="visibility:hidden;">Appendix</div>



The 2 HtmlToPdfResult's are merged, but the link does not work. If the link and destination are in the same HtmlToPdfResult, then it works after it is merged.

Thanks.
Exameron
Posted: Monday, November 6, 2017 5:08:02 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
When I created a separate test application I was able to get this working. So, I'll track down what's causing the issue in the bigger one. Thx for your help.
eo_support
Posted: Tuesday, November 7, 2017 9:19:27 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Thanks for the update. We were indeed having trouble reproducing this problem. If you manage to isolate and reproduce it, please send it over and we will be happy to investigate further.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.