Printing pdf file with Printers unit produces ps file instead lazarus / 31-LCL ---------------------------------------------------------------------- jalphonse · 2016-05-02 17:54 Hello, I work with Lazarus 1.6 for Windows 7. I wish to print into a pdf file, using the installed Adobe printer. For some reason, my program creates a Postscript file instead of the expected pdf file. This is my trial pocedure: PrintDialog1.Options:=[poPrintToFile]; if PrintDialog1.Execute then with Printer do begin   BeginDoc;   Canvas.Font.Name := 'Courier New';   Canvas.TextOut(100, 100, 'Hello Lazarus!');   EndDoc; end; Thanks, jalphonse ---------------------------------------------------------------------- tk · 2016-05-02 19:25 Maybe you should not call PrintDialog1.Options:=[poPrintToFile];? Did you also check if Printer.PrinterIndex really matches your selected printer? ---------------------------------------------------------------------- jalphonse · 2016-05-02 21:15 Quote from: tk on May 02, 2016, 09:25:10 pmMaybe you should not call PrintDialog1.Options:=[poPrintToFile];? Did you also check if Printer.PrinterIndex really matches your selected printer? If I do not call PrintDialog1.Options:=[poPrintToFile], no file is created. I checked PrinterIndex (=3) and PrinterName (=Adobe PDF). This seems correct to me. ---------------------------------------------------------------------- jalphonse · 2016-05-15 14:59 Quote from: jalphonse on May 02, 2016, 07:54:06 pm... using the installed Adobe printer (...) For some reason, my program creates a Postscript file instead of the expected pdf file. ... I eventually found the answer myself: FileName has to be empty and Title set to the name of the output file (e.g. Printer.Filename:=''; Printer.Title:='file'). This is mandatory in order to create a pdf file using the Adobe PDF printer. ---------------------------------------------------------------------- tk · 2016-05-18 15:40 Quote from: jalphonse on May 02, 2016, 11:15:14 pmIf I do not call PrintDialog1.Options:=[poPrintToFile], no file is created. A PDF printer should IMHO always produce a PDF file, that's why I've suggested this. However, I don't know Adobe PDF printer, been using another PDF printers. Important is that your fix works for you. ---------------------------------------------------------------------- jalphonse · 2016-05-20 09:47 Quote from: tk on May 18, 2016, 05:40:07 pmA PDF printer should IMHO always produce a PDF file, that's why I've suggested this. I agree with you. I have no idea about why under certain parameters I get a postscript file. However, looking into the Properties of the Adobe PDF printer, several fields indeed refer to Postscript options. To be more specific, here is the result of the various combinations of  Printer.Filename and Printer.Title: Filename empty + Title non empty: ok, pdf file generated, name of file corresponds to Title Filename non empty + Title empty: opens a window asking for file name, postscript file generated Filename empty + Title empty: no file generated Filename non empty + Title non empty: opens a window asking for file name followed by postscript error ---------------------------------------------------------------------- rvk · 2016-05-20 09:57 When you're using poPrintToFile, isn't the whole Adobe PDF-creation procedure then bypassed? Adobe PDF printer uses a Postscript driver to create a file (itself) and in the process after that the file is converted to a PDF. (That's also how other PDF-printers work) What happens if you leave Filename empty + Title non empty and remove the poPrintToFile? If the PDF-file then also correctly created? In that case you should never use poPrintToFile yourself because you instruct the Postscript driver to skip the post-process part and just output its raw content to file (and that's just postscript-code). ---------------------------------------------------------------------- jalphonse · 2016-05-20 14:30 Quote from: rvk on May 20, 2016, 11:57:51 amWhen you're using poPrintToFile, isn't the whole Adobe PDF-creation procedure then bypassed? Adobe PDF printer uses a Postscript driver to create a file (itself) and in the process after that the file is converted to a PDF. (That's also how other PDF-printers work) What happens if you leave Filename empty + Title non empty and remove the poPrintToFile? If the PDF-file then also correctly created? In that case you should never use poPrintToFile yourself because you instruct the Postscript driver to skip the post-process part and just output its raw content to file (and that's just postscript-code). Thanks for the information about the pdf printers. The poPrintToFile itself is not a problem: it only displays the checkbox "Print to file", unchecked. If I check it, then the "whole Adobe PDF-creation procedure then bypassed" as you explain.