[python-win32] Printing PDFs without external tools

Tim Roberts timr at probo.com
Tue Mar 4 05:52:21 CET 2014


On Mar 3, 2014, at 1:14 PM, Andreas Holtz <A.Holtz at gmx.net> wrote:
> 
> I need want to print PDF files without the usage of tools like Adobe, Foxit, etc.
> THe printer does understand PDF files, but I have no idea how to do it.

I doubt that.  PDFs contain PostScript, but there’s more to it than just PostScript.  What printer, exactly are you talking about?


> I played around with
>     win32api.ShellExecute(0, "print", pdf, None, ".", 0)
> but I am missing the possibilities to change layout and paper size.

That function will run whatever program is registered to render PDF files, which is usually the Acrobat Reader, and asks that it to print without presenting a dialog


> Is there really no way to print PDFs with Python setting whatever print settings I want?
> I thought Python can do anything... :’-(

Python can do anything, but Python is not always the EASIEST way to do something.  In this case, you have encountered limitations of the Win32 API, not of Python.  The Acrobat Reader can be controlled via COM to set layout and paper size, but I want to find out what your printer is before going any deeper.
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list