Maintain internal links using FPDI

I am trying to dynamically add text to an existing PDF file.

I tried both FPDF and TCPDF in conjunction with FPDI to import an existing pdf. This is normal. But, as expected, all existing links from the original pdf code are gone.

Then I tried to save the links using this FPDI extension:

fpdi_with_annnots https://gist.github.com/andreyvit/2020422

At first, only external links were saved, but then the creator was modified to include internal links as well. But this extension is deprecated, no longer supported, and no longer works for ** INTERNAL links ** (external links saved, this is normal!) With FPDI and TCPDF.

Someone tried (see the Github link above) to make it work with TCPDF and changed this piece of code:

$this->PageLinks[$this->page][] = $link; 

:

 $this->Link( $link[0]/$this->k, ($this->fhPt-$link[1]+$link[3])/$this->k, $link[2]/$this->k, -$link[3]/$this->k, $link[4] ); 

Then, after some time, someone said that it was necessary to change to this:

 $this->Link( $link[0]/$this->k, ($this->hPt - $link[1])/$this->k, $link[2]/$this->k, $link[3]/$this->k, $link[4] ); 

But it also does not work anymore.

Question:

1) Does anyone know how to modify this code to keep internal links?
or:
2) Does anyone know an alternative to fpdi_with_annots that import, generate and save hyperlinks?

Hint: Perhaps using the Bookmarks extension for FPDF will help instead of Addlink () and Setlink (): http://fpdf.de/downloads/addons/1/

+6
source share
1 answer

I have been working with TCPDF, FPDF, FPDI, Imagick, Ghostscript for the past 4 years, and I understand what problems you are facing, but, unfortunately, there is no technology yet. Therefore, the answer is NO.

0
source

Source: https://habr.com/ru/post/986299/


All Articles