Проблема с автоматической печатью mPDF

Я использую php-класс mpdf, который очень хорошо генерирует PDF-файлы. Я пытаюсь автоматически распечатать файл (т.е. открыть диалоговое окно печати) при визуализации. Я расширил основные функции с помощью приведенного ниже кода, чтобы добавить javascript в pdf. PDF-файл отображается, но без автоматической печати. Любая помощь была бы замечательной. Спасибо!

    require('mpdf.php');
    class PDF_JavaScript extends mPDF {
        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>>');
            }
        }
    }
    class PDF_AutoPrint extends PDF_Javascript { 
        function AutoPrint($dialog=false) { //Embed some JavaScript to show the print dialog or start printing immediately
        $param=($dialog ? 'true' : 'false');
        $script="print($param);";
        $this->IncludeJS($script); } }


$mpdf = new PDF_AutoPrint('', 'Letter', 0, '', 12.7, 12.7, 14, 12.7, 8, 8);

$stylesheet = file_get_contents('eabill.css');
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($message,2);
$mpdf->AutoPrint(true);

$mpdf->Output();
11
задан mozgras 24 August 2011 в 04:21
поделиться