2012-11-16 11:45
浏览 155


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();";
    $script .= "pp.interactive = pp.constants.interactionLevel.full;";
    $script .= "pp.interactive = pp.constants.interactionLevel.automatic;";
$script .= "pp.printerName = '\\\\\\\\".$server."\\\\".$printer."';";
$script .= "print(pp);";

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";

All with no luck.

图片转代码服务由CSDN问答提供 功能建议

我有一个脚本,使用 FPDF 。 我已经能够使自动打印功能正常工作,从而打开了打印对话框 在前一个名为AutoPrintToPrinter的链接上有另一个函数,它应该有条件地允许大声打印的静音。

  function AutoPrintToPrinter($ server,$ printer,$ dialog = false)
 //在共享打印机上打印(至少需要Acrobat 6)
 $  script =“var pp = getPrintParams();”; 
 if($ dialog)
 $ script。=“pp.interactive = pp.constants.interactionLevel.full;”; 
 $ script。=“pp  .interactive = pp.constants.interactionLevel.automatic;“; 
 $ script。=”pp.printerName ='\\\\\\\\“。$ server。”\\\\“。$ printer。”'  ;“; 
 $ script。=”print(pp);“; 
 $ this-> IncludeJS($ script); 

我知道打印机和服务器名称但没有任何反应。 即使我要求“大声”打印,我甚至都没有得到对话框。

我还看了 Adob​​e Tutorials 围绕此事并拥有 尝试了以下修改后的代码

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


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

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.

    解决 无用
    打赏 举报

相关推荐 更多相似问题