제목과 마찬가지로. 여기서 검색하면 문서를 인쇄 할 수있는 FPDF의 "확장"을 발견했습니다. 이제 대화 상자없이 직접 인쇄해야합니다. 저자가 this page에 남긴 의견을 따르고 있지만 나를 위해 일하지 않습니다 :(. 복사 및 붙여 넣기를 시도했지만 해결책을 찾을 수 없습니다.FPDF - PDF_JS를 사용하는 동안 대화 상자가 인쇄되지 않음
참고 : FireFox (최신 버전)를 사용했습니다. . 프로세스는 또한 크롬과 Yandex 주차 브라우저를 사용하여 시도 전혀 작동하지 않았다 모두 작동하지만 여전히 대화 상자를 보여
이PS : 시간 내 주셔서 감사합니다
이내가 사용하고 코드는 다음과 같습니다.!.
pdf_js.php
require('fpdf.php');
class PDF_JavaScript extends FPDF {
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>>');
}
}
}
true로 "대화"변수를 설정하는
<?php
require('pdf_js.php');
class PDF_AutoPrint extends PDF_JavaScript
{
function AutoPrint($dialog=false)
{
//Open the print dialog or start printing immediately on the standard printer
$param=($dialog ? 'true' : 'false');
$script="print($param);";
$this->IncludeJS($script);
}
function AutoPrintToPrinter($server, $printer, $dialog=false)
{
//Print on a shared printer (requires at least Acrobat 6)
$script = "var pp = getPrintParams();";
if($dialog)
$script .= "pp.interactive = pp.constants.interactionLevel.full;";
else
$script .= "pp.interactive = pp.constants.interactionLevel.automatic;";
$script .= "pp.printerName = '\\\\\\\\".$server."\\\\".$printer."';";
$script .= "print(pp);";
$this->IncludeJS($script);
}
}
$pdf=new PDF_AutoPrint();
$pdf->AddPage();
$pdf->SetFont('Arial','',20);
$pdf->Text(90, 50, 'Print me!');
//Open the print dialog
$pdf->AutoPrint(true);
$pdf->Output();
?>
StackOverflow에 오신 것을 환영합니다. 사용자가 문제를 더 잘 이해할 수 있도록 현재 사용중인 정확한 코드를 게시하십시오. –
우선, 내 게시물에 답해 주셔서 감사합니다. 내가 사용하는 코드를 첨부하여 내 게시물을 편집합니다. –