Zend_Pdf Add text link to pdf page
Asked Answered
D

4

7

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!

Diatribe answered 27/7, 2009 at 7:52 Comment(0)
G
6

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([
    new Zend_Pdf_Element_Numeric(0),
    new Zend_Pdf_Element_Numeric(0),
    new Zend_Pdf_Element_Numeric(0)
]);
$pdf->pages[0]->attachAnnotation($annotation);
...
Greenhead answered 23/9, 2013 at 12:32 Comment(1)
Thanks, $annotation->getResource()->Border = new Zend_Pdf_Element_Array(); works for me :)Earn
I
3

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.

Iguana answered 28/9, 2010 at 12:9 Comment(0)
G
1

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.

Guelders answered 27/7, 2009 at 15:39 Comment(1)
This is now possible with the release of Zend Framework 1.9 and the addition of support for annotations. Read more at framework.zend.com/manual/en/…Guelders
M
1

I've been struggling with the border issue and have resolved it with a rather simple hack:

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

This will make all anotations of type link to not have a border.

Mckee answered 29/11, 2010 at 14:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.