Discussion:
[reportlab-users] Help to Auto open generated pdf files
Umar Yusuf
2014-06-29 09:40:01 UTC
Permalink
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20140629/62e143b6/attachment.html>
T. Kort
2014-06-29 10:46:58 UTC
Permalink
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.


On Sun, 29 Jun 2014 10:40:01 +0100
Post by Umar Yusuf
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.
Werner
2014-06-30 05:45:35 UTC
Permalink
Hi,
Post by Umar Yusuf
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20140630/f397770c/attachment.html>
Dom Dom
2014-07-01 06:26:56 UTC
Permalink
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20140630/ba079704/attachment.html>
Loading...