簡體   English   中英

如何使用FPDF和PHP靜默打印

[英]how to silent print with FPDF and PHP

我有一個腳本,可以使用FPDF動態地將字母創建為PDF。 我已經能夠使用自動打印功能 ,該功能在加載時彈出打印對話框。

在先前的鏈接上還有另一個功能稱為AutoPrintToPrinter,該功能應有條件地允許靜音打印。

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);
}

我知道打印機和服務器的名稱,但是什么也沒有發生。 即使我要求“大聲”打印,我什至都沒有對話框。

我還查看了有關此問題的Adobe教程 ,並嘗試了以下擴展代碼

var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.automatic;
pp.printerName = "Adobe PDF";
this.print(pp);

一切都沒有運氣。

基本上,PHP無法輕松連接硬件。

您可以按以下步驟用用戶shell執行注釋以在php中打印文件

對於Windows Server

shell_exec("'C:\Program Files\Adobe\Acrobat 6.0\Reader\acrord32.exe' /t c:\filename.pdf \\myserver\myprinter");

對於linux服務器

exec("lp file.pdf");

我對此不確定。 希望這會對您有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM