【发布时间】:2011-12-12 13:19:15
【问题描述】:
我正在使用 DOMPDF 从 PHP 生成 PDF 文件。效果很好。
但是现在,当我单击生成 PDF 的链接时,我希望它带我到 PDF 的第五页(如果该页面上有内容)。有没有办法做到这一点?
【问题讨论】:
标签: php pdf pdf-generation dompdf
我正在使用 DOMPDF 从 PHP 生成 PDF 文件。效果很好。
但是现在,当我单击生成 PDF 的链接时,我希望它带我到 PDF 的第五页(如果该页面上有内容)。有没有办法做到这一点?
【问题讨论】:
标签: php pdf pdf-generation dompdf
根据this page上贴的源码,可以使用函数Cpdf.openHere:
/**
* specify where the document should open when it first starts
*/
function openHere($style, $a = 0, $b = 0, $c = 0) {
// this function will open the document at a specified page, in a specified style
// the values for style, and the required paramters are:
// 'XYZ' left, top, zoom
// 'Fit'
// 'FitH' top
// 'FitV' left
// 'FitR' left,bottom,right
// 'FitB'
// 'FitBH' top
// 'FitBV' left
$this->numObj++;
$this->o_destination($this->numObj, 'new', array('page' => $this->currentPage, 'type' => $style, 'p1' => $a, 'p2' => $b, 'p3' => $c));
$id = $this->catalogId;
$this->o_catalog($id, 'openHere', $this->numObj);
}
【讨论】:
<script type="text/php">$cpdf=$pdf->get_cpdf();$cpdf->openHere('Fit');</script>。
...pdf#page=5 就可以了。