can't find a way to display and print pdf through python.

Antoon Pardon apardon at forel.vub.ac.be
Tue Feb 13 10:24:29 EST 2007


On 2007-02-11, krishnakant Mane <researchbase at gmail.com> wrote:
> hello all,
> I am stuck with a strange requirement.
> I need a library that can help me display a pdf file as a report and
> also want a way to print the same pdf file in a platform independent
> way.
> if that's not possible then I at least need the code for useing some
> library for connecting to acrobat reader and giving the print command
> on windows and some thing similar on ubuntu linux.
> the problem is that I want to display reports in my application.  the
> user should be able to view the formatted report on screen and at his
> choice click the print button on the screen to send it to the printer.
> I have reportlab installed and that is sufficient to generate pdf reports.
> but I still can't fine the way to display it directly and print it directly.
> Please help me.
> Krishnakant.

I think the best way to handle this under a unix like system is by using
the mailcap module, something like the following:

import mailcap
import os

mc = mailcap.getcaps()
cmd = mailcap.findmatch(mc, 'image/pdf' , filename='/tmp/dummy')[0]
os.system(cmd)

-- 
Antoon Pardon



More information about the Python-list mailing list