Zend_Pdf Add a text link to the pdf page

Can I add anchor text (link) on the Zend_PDF page? I could not find information about this in the Zend_Pdf online manual or read the code, so I think this is not possible.

If there is a way, please suggest!

Thanks!

+5
source share
4 answers

Disable Border:

...
$target = Zend_Pdf_Action_URI::create('http://example.com');
$annotation = Zend_Pdf_Annotation_Link::create(0,0,100,100,$target);
$annotation->getResource()->Border = new Zend_Pdf_Element_Array();
$pdf->pages[0]->attachAnnotation($annotation);
...
+5
source

The following code will create a blank page with an interactive area in the lower left corner that contains a hyperlink:

$pdf = new Zend_Pdf();
$pdf->pages[0] = new Zend_Pdf_Page( Zend_Pdf_Page::SIZE_A4 );
$target = Zend_Pdf_Action_URI :: create( 'http://example.com' );
$annotation = Zend_Pdf_Annotation_Link :: create( 0, 0, 100, 100, $target );
$pdf->pages[0]->attachAnnotation( $annotation );
$pdf->save( 'test.pdf' );

The above snippet was tested with Zend Framework 1.10.7, but should work with all versions of Zend Framework from version 1.9.7 onwards.

+3
source

- - , , FPDF, , Zend_Pdf.

I studied the implementation of link functionality in Zend_Pdf, and the structure was too complex for the time I had to find.

+1
source

I am struggling with a border problem and solved it with a fairly simple hack:

echo str_replace('/Annot /Subtype /Link', '/Annot /Subtype /Link /Border[0 0 0]', $pdf->render());

This will cause all type link annotations to have no border.

+1
source

All Articles