stchan/PdfScribe

Auto open pdf reader

Closed this issue · 7 comments

Hi,

Thanks for all your support, I'm almost completed my app but there are still a minor problem that app always open the pdf reader automatically whenever it's running.
The reason is because of the ghostscript execution. But, is there anyway prevent this from open the pdf reader?

Thanks again!

Ghostscript doesn't open PDFs on its own. Check the "OpenAfterCreating" setting in the .config file - it should be set to "False" if you don't want the PDF to be opened after it's created.

Same problem as mine. I'm trying to send the PDF file to a thermal printer using verb = "PrintTo" and it always opens the default pdf reader (foxit reader for my case). Is there any idea for preventing this?

Indeed Ghostscript just create the pdf, it doesn't open it.

What you could do is to change the program associated with the ".pdf" extension (foxit reader in your case) to something like http://www.columbia.edu/~em36/pdftoprinter.html (PDFtoPrinter.exe), which directly print the pdf to the default printer (see https://stackoverflow.com/questions/19124808/printing-pdfs-from-windows-command-line/47994723#47994723).

Dont forget to check "always use this program for this extension type" if you make the association from the windows explorer, or follow this guide: https://www.lifewire.com/how-to-change-file-associations-in-windows-2624477.

If you have Acrobat Reader (like me), the association may be reseted for whatever reason (?!) even when checking "always use...". A solution would be to uninstall Acrobat Reader (I always found this software intrusive!).

The PrintTo verb by design launches the default app for printing a doc type, which in your case is the FoxIt reader. I'm not familiar with Foxit, but if it has command line switches to handle silently printing (I am working with the assumption you want the newly created PDF to silently print immediately), you could change the code to use Process.Start() to open FoxIt with the appropriate parameters.
If that doesn't work, you could try using the Acrobat reader - it has switches for printing, but they are poorly documented:
https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/Acrobat_SDK_developer_faq.pdf

And last (and the most work), you could write your own code to render the PDF pages (using a library like iText.net), and send the bitmaps of pages to the printer via GDI/GDI+.

Indeed Ghostscript just create the pdf, it doesn't open it.

What you could do is to change the program associated with the ".pdf" extension (foxit reader in your case) to something like http://www.columbia.edu/~em36/pdftoprinter.html (PDFtoPrinter.exe), which directly print the pdf to the default printer (see https://stackoverflow.com/questions/19124808/printing-pdfs-from-windows-command-line/47994723#47994723).

Dont forget to check "always use this program for this extension type" if you make the association from the windows explorer, or follow this guide: https://www.lifewire.com/how-to-change-file-associations-in-windows-2624477.

If you have Acrobat Reader (like me), the association may be reseted for whatever reason (?!) even when checking "always use...". A solution would be to uninstall Acrobat Reader (I always found this software intrusive!).

You save my day! Thank you very much!

Closing this since thieuquangcuong hasn't posted any more followups, and it seems kisskumam has accepted cedrozor's answer.

Same problem as mine. I'm trying to send the PDF file to a thermal printer using verb = "PrintTo" and it always opens the default pdf reader (foxit reader for my case). Is there any idea for preventing this?

Hi kisskumam,
In my current project I'm also trying to achieve similar thing, i.e. want to send pdf or content to be printed on thermal printer connected to windows system.
It would be great if you can share some background on how did you achieve it.