[reportlab-users] Reportlab PDF viewer

6 views
Skip to first unread message

Paul Henry via reportlab-users

unread,
Jul 23, 2019, 11:31:34 PM7/23/19
to reportl...@lists2.reportlab.com, Paul Henry
I have used reportlab to generate several pdf files using python3 on linux.  Is there anyway to use reportlab to view the files once they are generated? I want to be able to open the file for viewing using python3 code.

Tim Roberts

unread,
Jul 24, 2019, 2:32:01 AM7/24/19
to reportlab-users
On Jul 23, 2019, at 8:31 PM, Paul Henry wrote:

I have used reportlab to generate several pdf files using python3 on linux.  Is there anyway to use reportlab to view the files once they are generated? I want to be able to open the file for viewing using python3 code.

No.  Reportlab can generate PDFs, but it can’t render them.  You need to launch a viewer, like Adobe Acrobat.  On Windows, you can say
    os.system("start xxx.pdf”)
on MacOS
    os.system(“open xxx.pdf”)
and on most Linux distributions
    os.system(“xdg-open xxx.pdf”)
— 
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Robin Becker

unread,
Jul 24, 2019, 4:52:03 AM7/24/19
to reportlab-users
Hi Paul,

The ReportLab toolkit doesn't provide a viewer, but your python3 process could
open a viewer using eg os.system or the subprocess module. That of course
requires you to have a viewer installed in your linux.

On my ubuntu I can do this inside a python3 script


os.system("/usr/bin/evince ./z....er/rml/narf/logo.pdf >/dev/null 2>&1 &")

and evince opens in my main display.

On 24/07/2019 04:31, Paul Henry via reportlab-users wrote:
> I have used reportlab to generate several pdf files using python3 on linux.  Is there anyway to use reportlab to view the files once they are generated? I want to be able to open the file for viewing using python3 code.
>

........

--
Robin Becker
_______________________________________________
reportlab-users mailing list
reportl...@lists2.reportlab.com
https://pairlist2.pair.net/mailman/listinfo/reportlab-users

johnf

unread,
Jul 25, 2019, 9:33:23 AM7/25/19
to reportl...@lists2.reportlab.com

To my knowledge this is not a pure python (3 or 2) module that will open a PDF for view on the display.  There are of course many programs that do as you requested and python can access those programs via the OS.   As pointed out earlier if you are on Ubuntu there is "evince".  And of course there are PDF viewers for other OS's. 

I use ghostscript mostly on windows (only because it does a good job and has a long history) - but requires that it be installed.  Recently, I have been using browsers (they are harder to work with but will display a PDF).

Johnf

Reply all
Reply to author
Forward
0 new messages