How to set filename when printing to “Microsoft print to PDF” in delphi

前端 未结 2 1135
礼貌的吻别
礼貌的吻别 2021-01-06 02:49

I am trying to set the filename when printing to PDF. Setting (Printers.pas) Printer.Title works to default the PDF filename for most PDF printing engines (Adobe, CutePDF),

2条回答
  •  情话喂你
    2021-01-06 03:02

    You can try.

    var
      DeviceMode: THandle;
      Device, Driver, Port: array[0..80] of Char;
    begin
      Printer.PrinterIndex := Printer.Printers.IndexOf('Microsoft Print to PDF');
      Printer.GetPrinter(Device, Driver, Port, DeviceMode);
      Printer.SetPrinter(Device, Driver, 'C:\Temp\Test.pdf', 0);
    
      Printer.BeginDoc;
      Printer.Canvas.TextOut(100, 100, 'Test');
      Printer.EndDoc;
    end;
    

提交回复
热议问题