[reportlab-users] Help to Auto open generated pdf files

16 views
Skip to first unread message

Umar Yusuf

unread,
Jun 29, 2014, 5:40:04 AM6/29/14
to reportl...@lists2.reportlab.com
Good day,
I am able to generate .PDF files with python and report lab using the tutorials available.

My question is how do I make a generated PDF to auto open immediately it is generated from my script?

I don't want it to generate only, but to also open in a default PDF reader.


Thanks for helping in advance.



T. Kort

unread,
Jun 29, 2014, 6:47:17 AM6/29/14
to reportl...@lists2.reportlab.com
Hello

This is not a reportlab problem and would fit better to
http://stackoverflow.com/ or similar sites. You need something like
this:

import sys, os, subprocess
if sys.platform.startswith('darwin'):
subprocess.call(('open', path))
elif os.name == 'nt':
os.startfile(path)
elif os.name == 'posix':
subprocess.call(('xdg-open', path))

Regards, T.
_______________________________________________
reportlab-users mailing list
reportl...@lists2.reportlab.com
http://two.pairlist.net/mailman/listinfo/reportlab-users

Werner

unread,
Jun 30, 2014, 1:45:44 AM6/30/14
to reportlab-users
Hi,


On 6/29/2014 11:40, Umar Yusuf wrote:
Good day,
I am able to generate .PDF files with python and report lab using the tutorials available.

My question is how do I make a generated PDF to auto open immediately it is generated from my script?

I don't want it to generate only, but to also open in a default PDF reader.

I use the desktop module:

        try:
            desktop.open(url.strip())
        except OSError:
            text = (_(u'Your default browser could not be opened, \
or the external program was not found or no \
external program is defined for this file.'))

https://pypi.python.org/pypi/desktop

Werner

Dom Dom

unread,
Jul 1, 2014, 2:26:56 AM7/1/14
to reportl...@googlegroups.com, foru...@gmail.com, reportl...@lists2.reportlab.com
Hi,

You may also do:

import ctypes

try:
        shell32 = ctypes.windll.shell32
        shell32.ShellExecuteA(0,"open",doc_name,0,0,5)
except Exception, e:
        print Exception, e

Dominique
  
Reply all
Reply to author
Forward
0 new messages