100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > delphi 获取打印机默认纸张_如何设置一台打印机打印不同尺寸的纸张

delphi 获取打印机默认纸张_如何设置一台打印机打印不同尺寸的纸张

时间:2023-07-13 20:46:14

相关推荐

delphi 获取打印机默认纸张_如何设置一台打印机打印不同尺寸的纸张

Delphi(Pascal) codevar

PrtInfo2: PPrinterInfo2;//具体的内容 查查MSDN

DeviceMode: PDeviceMode;//具体的内容 查查MSDN

strPrintName:string;//打印机名称

.............

Printer.SetPrinter(pchar(Printer.Printers[Printer.PrinterIndex]), PrtInfo2.pDriverName, PrtInfo2.pPortName, 0);//不修改系统默认打印机,仅修改当前程序所使用的打印机

.......

DeviceMode^.dmPaperSize := 256; //要设为其它可查API中的DevMode,自定义纸张

DeviceMode^.dmPaperLength := Trunc(StrToFloat(XMLPrintM.DocumentElement.AttributeNodes[3].text) * 100);

DeviceMode^.dmPaperWidth := Trunc(StrToFloat(XMLPrintM.DocumentElement.AttributeNodes[2].text) * 100);

DeviceMode^.dmFields := DeviceMode^.dmFields or DM_ORIENTATION;

DeviceMode^.dmFields := DeviceMode^.dmFields or DM_PAPERSIZE;

DeviceMode^.dmFields := DeviceMode^.dmFields or DM_PAPERLENGTH;

DeviceMode^.dmFields := DeviceMode^.dmFields or DM_PAPERWIDTH;

StrPCopy(DeviceMode^.dmDeviceName, strPrintName);

ResetDC(Printer.Handle, DeviceMode^);

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。