【问题标题】:How to print PDF file to printer by printer name part如何通过打印机名称部分将 PDF 文件打印到打印机
【发布时间】:2021-02-19 20:28:07
【问题描述】:

如何从桌面应用程序将 pdf 文件打印到 Windows 10 中名称包含“labelprinter”的打印机?

我在 Visual Foxpro 中尝试了以下代码,但它打印到 Windows 默认打印机。 可以用一些bat文件来按名称设置打印器吗?

* cPDFFile - name of PDF file to print

nprinter  = aprinters(aprinterid)
for i=1 to nPrinters
  if 'labelprinter'$lowe( aprinterid[i,1] )
    DECLARE INTEGER ShellExecute IN shell32.dll ;
    INTEGER hndWin, ;
    STRING cAction, ;
    STRING cFileName, ;
    STRING cParams, ;
    STRING cDir, ;
    INTEGER nShowWin
    set printer to name (aprinterid[i,1])
    ShellExecute(0, "print", cPDFFile , "", "", 1)
    exit
    endif
  endfor

【问题讨论】:

    标签: pdf printing visual-foxpro windows-scripting


    【解决方案1】:

    您可以使用“printto”动词来指定打印机名称:

    ShellExecute(0, "printto", cPDFFile , "printername", "", 1)
    

    【讨论】:

    • 谢谢。很好的解决方案。我在搜索过程中没有找到这个。我只提示使用 api 调用更改 Windows 默认打印机
    猜你喜欢
    • 1970-01-01
    • 2014-08-25
    • 2014-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-01
    • 2014-12-21
    • 2011-12-23
    相关资源
    最近更新 更多