dongnai8013 2012-11-16 11:45
浏览 180
已采纳

如何使用FPDF和PHP进行静默打印

I have a script which creates letters as PDFs dynamically using FPDF. I have been able to get the AutoPrint function working which brings up the print dialog on load.

There is another function on the previous link called AutoPrintToPrinter which is supposed to conditionally allow silent of loud printing.

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

I know the printer and server name but nothing happens. Even if i ask for 'loud' printing, I don't even get the dialog box.

I've also looked at the Adobe Tutorials around the matter and have tried the following ammended code

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

All with no luck.

  • 写回答

1条回答 默认 最新

  • duanouyong4228 2012-11-16 12:33
    关注

    Basically PHP cannot easily connect Hardwares.

    You can user shell execute comment to print a file in php as follows

    For windows server

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

    For linux server

    exec("lp file.pdf");
    

    I am not sure about this. Hope this will help you ... Try this.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法