0

I've got some code that builds a PDF from an HTML template, then attaches several other PDFs to make one big PDF using abcPDF 7.

All this works fine and dandy -- however, I'd like to make some links in the HTML portion of the PDF to jump down to one of the several attached PDFs.

I tried creating links and anchors using the technique referenced here, by putting the

<a href="#elementId">Link to another page</a>

link in the HTML, then putting the anchor

<div><a name="elementId">A div that's on another page</a></div>

as an added-on paste-over on the top of the first page of the PDF I wanted to jump to.

I can see the text of the anchor just fine, and the link to it is blue, but it doesn't do anything.

As the next attempt, I've created bookmarks that work as well. Can someone point me in the direction to go back and adjust the links in the HTML portion to use them to jump to the bookmarks?

I apologize in advance for a lack of code, and I'm not asking for any code now.. I'd just like a more general way to go about it, like "try something like this." I'm not having much luck finding anything that is close to what I'm trying to do, not even on WebSuperGoo's website.

Community
  • 1
  • 1
Moose
  • 5,354
  • 3
  • 33
  • 46
  • Well, now I have working links, but the links are going to the same type of place as the other question's issue: something like file:///C:/Windows/Temp/ABCpdf/pdfDLVCRTVZ.htm#elementId. – Moose Aug 11 '12 at 01:23
  • Never really figured this out. Got around it by using a cover page for each attachment. Would still be interested to know if it's possible. – Moose Aug 11 '12 at 21:21

1 Answers1

1

This method has worked for me in the latest ABCpdf version (9) Add a bookmark to each page in your document:

For i = 1 to pdf.PageCount

    pdf.PageNumber = i
    pdf.AddBookmark("Page " & i, True)

Next

Then where you want to insert a link you can reference the bookmark - in this case we create a table of contents by looping through each bookmark we've created:

For Each bm As Bookmark In pdf.Bookmark

    toc &= "<Font annots='goto:" + bm.Page.PageNumber.ToString() + "'>" & bm.Title & "</Font><br>"

Next

pdf.AddHtml(toc)

The Websupergoo team supplied me with some example code and that's what this is based off of - so thanks to them!

Ian Black
  • 46
  • 2
  • This looks like it would work just fine.. The key is that annots='goto:' thing.. I'll accept this as the answer, maybe I'll revisit that code again soon. – Moose Jul 24 '13 at 16:50