其他分享
首页 > 其他分享> > delphi调用打印机打印Pdf格式文件

delphi调用打印机打印Pdf格式文件

作者:互联网

 use Vcl.Printers, Winapi.ShellAPI;

procedure TForm1.PrintDocument(const documentToPrint: string); var printCommand: string; printerInfo: string; Device, Driver, Port: array[0..255] of Char; hDeviceMode: THandle; begin if Printer.PrinterIndex = ComboBox1.ItemIndex then begin printCommand := 'print'; printerInfo := ''; end else begin printCommand := 'printto'; Printer.PrinterIndex := ComboBox1.ItemIndex; Printer.GetPrinter(Device, Driver, Port, hDeviceMode); printerInfo := Format('"%s" "%s" "%s"', [Device, Driver, Port]); end; ShellExecute(0, PChar(printCommand), PChar(documentToPrint), PChar(printerInfo), nil, SW_NORMAL); end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    ComboBox1.Items.Assign(Printer.Printers);  //本机所有的打印机
end;

 

标签:printCommand,begin,Printer,end,delphi,printerInfo,格式文件,Pdf,ComboBox1
来源: https://www.cnblogs.com/yangxuming/p/16398514.html