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), however it does not work for "Microsoft print to PDF" nor "Microsoft XPS Document Writer"
What is the correct way to set the filename in the print dialog invoked when Printer.BeginDoc is called? If setting Printer.Title is the correct way, then is there a workaround for "Windows print to PDF"?
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;