问题描述
我以前使用PHP fpdf中的javascript打印方法来打印PDF文档,这用于显示Google Chrome的打印对话框。
很久以前,它只是停止工作,为了紧急情况,我移到了Firefox,但是我需要回到Chrome。
这就是我包含JavaScript代码的方式:
var $javascript;
var $n_js;
function IncludeJS($script) {
$this->javascript=$script;
}
function _putjavascript() {
$this->_newobj();
$this->n_js=$this->n;
$this->_out('<<');
$this->_out('/Names [(EmbeddedJS) '.($this->n+1).' 0 R]');
$this->_out('>>');
$this->_out('endobj');
$this->_newobj();
$this->_out('<<');
$this->_out('/S /JavaScript');
$this->_out('/JS '.$this->_textstring($this->javascript));
$this->_out('>>');
$this->_out('endobj');
}
function _putresources() {
parent::_putresources();
if (!empty($this->javascript)) {
$this->_putjavascript();
}
}
function _putcatalog() {
parent::_putcatalog();
if (!empty($this->javascript)) {
$this->_out('/Names <</JavaScript '.($this->n_js).' 0 R>>');
}
}
进入扩展FPDF的类
我以前这样称呼它:
$pdf->IncludeJS("print('true');");
$pdf->Output('I');
然后我尝试了这个:
$pdf->IncludeJS("window.print();");
$pdf->Output();
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)