问题描述
如何从桌面应用程序在 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)