views:

300

answers:

2

Is it possible to add anchor text(link) in Zend_PDF page? I wasn't be able to find any information about this in Zend_Pdf online manual, or reading code, so I guess it is not possible.

If there is way, please suggest!

Thanks!

+1  A: 

This isn't possible - I tried to do something similar myself and unfortunately had to resort to FPDF which isn't as good as Zend_Pdf.

I looked into implementing the link functionality in Zend_Pdf and the structure was too complicated for the amount of time I had to find a solution.

David Caunt
This is now possible with the release of Zend Framework 1.9 and the addition of support for annotations. Read more at http://framework.zend.com/manual/en/zend.pdf.interactive-features.html#zend.pdf.pages.interactive-features.annotations
David Caunt
A: 

The following code will create a blank page with a clickable area at the bottom 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 on all versions of Zend Framework from 1.9.7 onwards.

JamesG