7

是否可以在 Zend_PDF 页面中添加锚文本(链接)?我无法在 Zend_Pdf 在线手册或阅读代码中找到有关此的任何信息,所以我想这是不可能的。

如果有办法,请指教!

谢谢!

4

4 回答 4

6

禁用边框:

...
$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);
...
于 2013-09-23T12:32:21.917 回答
3

以下代码将在左下角创建一个包含超链接的可点击区域的空白页面:

$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' );

上面的代码片段已经使用 Zend Framework 1.10.7 进行了测试,但应该适用于 Zend Framework 1.9.7 以后的所有版本。

于 2010-09-28T12:09:10.450 回答
1

这是不可能的——我自己尝试做类似的事情,不幸的是不得不求助于不如 Zend_Pdf 好的FPDF 。

我研究了在 Zend_Pdf 中实现链接功能,但结构过于复杂,以至于我不得不花费大量时间找到解决方案。

于 2009-07-27T15:39:19.593 回答
1

我一直在努力解决边界问题,并通过一个相当简单的 hack 解决了它:

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

这将使链接类型的所有注释都没有边框。

于 2010-11-29T14:17:03.050 回答