4

I'm converting a group of HTML files to PDF in C#. Wkhtmltopdf did the job perfectly, but now I need to add a link to a location in another pdf and wkhtmltopdf doesn't seem to be able to do that.

Creating links to point to another location in the same document is easy:

<a href="#idOfDesiredPlace">Link</a>

Also, linking to another document works well:

<a href="b.pdf">Link</a>

However, I need to link to a specific location in a different document. The simple method with wkhtmltopdf fails here:

<a href="b.pdf#idOfDesiredLocation">This link doesn't work</a>

This is supported in PDF specification with Remote Go-To actions. PDF Reference, p. 520: remote go-to actions

How can this be achieved in C#?

I need the converter to support CSS 3, so I think the way to go would be to first convert the HTML to PDF with wkhtmltopdf and then use a library to edit the PDF to correct the links.

How to do this practically? Which library to use and how to use it?

UPDATE: I've created a feature request for wkhtmltopdf on GitHub. However, this question is still relevant.

Draex_
  • 3,011
  • 4
  • 32
  • 50
  • Helpful: https://stackoverflow.com/a/17812299/628637 – Draex_ Feb 05 '19 at 12:26
  • 2
    I came across a library to do this called `Quick PDF library` by Debenu. Here's the link to the exact method https://www.debenu.com/docs/pdf_library_reference/AddLinkToFile.php – kowsikbabu Feb 07 '19 at 07:15
  • When this problem seems not solvable in pure C# you can at least start a process with ghostscript to do this job. – nologin Feb 11 '19 at 17:03

0 Answers0