如何通过打印机名称部分将 PDF 文件打印到打印机

问题描述

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

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

* 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

解决方法

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

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

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...