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. 17 8431
Are you trying to:
a) Make the PDF file open in it's default application?
b) Create a PDF-reader in Python?
....because your question is somewhat unclear. Report Lab has no PDF viewer.
You would need a PDF/PostScript parser to do that and that's more of a job
than I think you're looking for.
well yes,
I need to view reports on line and also print them from within my app.
so yes I need to display the pdf in my app and print it as well.
regards.
Krishnakant
krishnakant Mane 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.
Just let the registered .PDF viewer do it for you.
os.start('myfile.pdf')
Launches whatever is registered as .PDF viewer and user
can then print, save, zoom, etc. on their own.
-Larry
On 2007-02-12, Larry Bates <la*********@websafe.comwrote:
>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.
Just let the registered .PDF viewer do it for you.
os.start('myfile.pdf')
Eh? I don't see os.start() it either 2.5 or 2.44
documentation, and it's sure not there in 2.4.3:
$ python
Python 2.4.3 (#1, Dec 10 2006, 22:09:09)
[GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>import os print os.start
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'start'
I did find os.startfile() in the docs, but it's shown as
windows-only (it's not present under Linux).
Launches whatever is registered as .PDF viewer and user
can then print, save, zoom, etc. on their own.
Really?
--
Grant Edwards grante Yow! Civilization is
at fun! Anyway, it keeps
visi.com me busy!!
Grant Edwards wrote:
On 2007-02-12, Larry Bates <la*********@websafe.comwrote:
>>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.
>Just let the registered .PDF viewer do it for you.
os.start('myfile.pdf')
Eh? I don't see os.start() it either 2.5 or 2.44
documentation, and it's sure not there in 2.4.3:
$ python
Python 2.4.3 (#1, Dec 10 2006, 22:09:09)
[GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>import os
>>print os.start
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'start'
I did find os.startfile() in the docs, but it's shown as
windows-only (it's not present under Linux).
>Launches whatever is registered as .PDF viewer and user can then print, save, zoom, etc. on their own.
Really?
My bad. os.system()
-Larry
os.start does not work.. attribute error.
regards.
Krishnakant.
On 2007-02-12, Larry Bates <la*********@websafe.comwrote:
On 2007-02-12, Larry Bates <la*********@websafe.comwrote:
>>
>>>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.
>>Just let the registered .PDF viewer do it for you.
os.start('myfile.pdf')
Eh? I don't see os.start() it either 2.5 or 2.44 documentation, and it's sure not there in 2.4.3:
My bad. os.system()
That doesn't work either:
$ ls -l user.pdf
-rw------- 1 grante users 35640 2005-11-21 14:33 user.pdf
$ python
Python 2.4.3 (#1, Dec 10 2006, 22:09:09)
[GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>import os os.system('user.pdf')
sh: user.pdf: command not found
32512
>>>
--
Grant Edwards grante Yow! Eisenhower!! Your
at mimeograph machine upsets
visi.com my stomach!!
On Feb 12, 3:06 pm, "krishnakant Mane" <researchb...@gmail.comwrote:
os.start does not work.. attribute error.
regards.
Krishnakant.
It's os.system('thefile') or os.system('start thefile') but
that's windows only. It seems like there's no
platform-independent way to launch a preferred application to open
a file, but...
based on <http://cweiske.de/howto/launch/allinone.html>
I would suggest (by looking at sys.platform) to use "start" on
windows, "open" on mac, and on linux to use the xdg-open shell
script which is part of XdgUtils...
<http://portland.freedesktop.org/wiki/>
It works standalone. Even seems it would not take too much
effort to port it to python if you want.
Grant Edwards wrote:
On 2007-02-12, Larry Bates <la*********@websafe.comwrote:
>On 2007-02-12, Larry Bates <la*********@websafe.comwrote:
>>>>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. Just let the registered .PDF viewer do it for you.
os.start('myfile.pdf') Eh? I don't see os.start() it either 2.5 or 2.44 documentation, and it's sure not there in 2.4.3:
My bad. os.system()
That doesn't work either:
$ ls -l user.pdf
-rw------- 1 grante users 35640 2005-11-21 14:33 user.pdf
$ python
Python 2.4.3 (#1, Dec 10 2006, 22:09:09)
[GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>import os
>>os.system('user.pdf')
sh: user.pdf: command not found
32512
>>>
Works fine on my system. You linux guys just have it hard.
The op said "windows". I can't answer for ubuntu linux but
maybe you can help there?
-Larry
On 2007-02-12, Larry Bates <la*********@websafe.comwrote:
Grant Edwards wrote:
>On 2007-02-12, Larry Bates <la*********@websafe.comwrote:
>>On 2007-02-12, Larry Bates <la*********@websafe.comwrote: >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. Just let the registered .PDF viewer do it for you. > os.start('myfile.pdf') Eh? I don't see os.start() it either 2.5 or 2.44 documentation, and it's sure not there in 2.4.3: My bad. os.system()
That doesn't work either:
$ ls -l user.pdf -rw------- 1 grante users 35640 2005-11-21 14:33 user.pdf
$ python Python 2.4.3 (#1, Dec 10 2006, 22:09:09) [GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
> >>import os >>os.system('user.pdf')
sh: user.pdf: command not found 32512
> >>>
Works fine on my system. You linux guys just have it hard.
The op said "windows".
The posting to which you replied specified Linux.
I can't answer for ubuntu linux but maybe you can help there?
I don't see how. Pdf files just aren't executable.
--
Grant Edwards grante Yow! FIRST, I'm covering
at you with OLIVE OIL and
visi.com PRUNE WHIP!!
Grant Edwards kirjoitti:
On 2007-02-12, Larry Bates <la*********@websafe.comwrote:
>Grant Edwards wrote:
>>On 2007-02-12, Larry Bates <la*********@websafe.comwrote: On 2007-02-12, Larry Bates <la*********@websafe.comwrote: >>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. >Just let the registered .PDF viewer do it for you. >> >os.start('myfile.pdf') Eh? I don't see os.start() it either 2.5 or 2.44 documentation, and it's sure not there in 2.4.3: My bad. os.system() That doesn't work either:
$ ls -l user.pdf -rw------- 1 grante users 35640 2005-11-21 14:33 user.pdf
$ python Python 2.4.3 (#1, Dec 10 2006, 22:09:09) [GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>import os >>os.system('user.pdf') sh: user.pdf: command not found 32512 >>>
Works fine on my system. You linux guys just have it hard. The op said "windows".
The posting to which you replied specified Linux.
>I can't answer for ubuntu linux but maybe you can help there?
I don't see how. Pdf files just aren't executable.
On Windows, this (where fileName is xyz.PDF, for example):
webbrowser.open(r'file://' + fileName)
starts Acrobat Reader with the document read in. I have no idea why,
because Acrobat Reader sure ain't my browser;)
Maybe someone could try this out on Linux.
Cheers,
Jussi
On Feb 13, 7:44 pm, Jussi Salmela <tiedon_j...@hotmail.comwrote:
Grant Edwards kirjoitti:
On 2007-02-12, Larry Bates <larry.ba...@websafe.comwrote:
Grant Edwards wrote: On 2007-02-12, Larry Bates <larry.ba...@websafe.comwrote: On 2007-02-12, Larry Bates <larry.ba...@websafe.comwrote: >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. Just let the registered .PDF viewer do it for you.
>>>>os.start('myfile.pdf') Eh? I don't see os.start() it either 2.5 or 2.44 documentation, and it's sure not there in 2.4.3: My bad. os.system() That doesn't work either:
> $ ls -l user.pdf -rw------- 1 grante users 35640 2005-11-21 14:33 user.pdf
> $ python Python 2.4.3 (#1, Dec 10 2006, 22:09:09) [GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>import os >>os.system('user.pdf') sh: user.pdf: command not found 32512
Works fine on my system. You linux guys just have it hard.
The op said "windows".
The posting to which you replied specified Linux.
I can't answer for ubuntu linux but maybe you can help there?
I don't see how. Pdf files just aren't executable.
On Windows, this (where fileName is xyz.PDF, for example):
webbrowser.open(r'file://' + fileName)
starts Acrobat Reader with the document read in. I have no idea why,
because Acrobat Reader sure ain't my browser;)
Maybe someone could try this out on Linux.
Cheers,
Jussi
Works on Ubuntu -- this opens a tab in my browser and then launches
Document Viewer to view the PDF.
peter@astro:~$ python
Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02)
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>import webbrowser webbrowser.open(r'file:///home/peter/appa.pdf')
On Feb 12, 4:56 pm, Larry Bates <larry.ba...@websafe.comwrote:
krishnakant Mane 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.
Just let the registered .PDF viewer do it for you.
os.start('myfile.pdf')
Launches whatever is registered as .PDF viewer and user
can then print, save, zoom, etc. on their own.
-Larry
os.startfile('pathToTheFile') should work. Under Library Reference- >
os -Process Management
On 2007-02-11, krishnakant Mane <re**********@gmail.comwrote:
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
I'm using Suse Linux which has five program that
will open a pdf file from a shell command line.
Acrobat Reader is one of the five.
A right button click on the file should give a
list of programs that will open a PDF file.
Im using a KDE desktop
Open a shell, add the path to the directory where
the PDF file lives, and on the command line type;
xpdf myfile.pdf ## may also work on a Gnome
## Desktop
or any of these for the KDE desktop;
kpdf myfile.pdf
Kghostview myfile.pdf
konqueror myfile.pdf ## my browser + myfile.
Acrobat Reader is also listed on my system. It
open files as adobe reader using the mouse to
open a pdf file but not from the command line
with an arg, and I haven't spent the time to
figgure out why.
You will have to import os and some combination of
any of the exec.. args, or the popen, spawn, or
system modules.
os.execvep() ## or others like execl, execle ....
os.spawnv(),
os.spawnve(),
os.popen()
hope this give some direction.
jim-on-linux
On Tuesday 13 February 2007 03:44, Jussi Salmela
wrote:
Grant Edwards kirjoitti:
On 2007-02-12, Larry Bates
<la*********@websafe.comwrote:
Grant Edwards wrote: On 2007-02-12, Larry Bates
<la*********@websafe.comwrote:
>>On 2007-02-12, Larry Bates
<la*********@websafe.comwrote:
>>>>>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. > Just let the registered .PDF viewer do it for you. > os.start('myfile.pdf')
Eh? I don't see os.start() it either 2.5 or 2.44 documentation, and it's sure not there in 2.4.3:
My bad. os.system()
That doesn't work either:
$ ls -l user.pdf -rw------- 1 grante users 35640 2005-11-21 14:33 user.pdf
$ python Python 2.4.3 (#1, Dec 10 2006, 22:09:09) [GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
>>import os >>os.system('user.pdf')
sh: user.pdf: command not found 32512
Works fine on my system. You linux guys
just have it hard. The op said "windows".
The posting to which you replied specified
Linux.
I can't answer for ubuntu linux but maybe
you can help there?
I don't see how. Pdf files just aren't
executable.
On Windows, this (where fileName is xyz.PDF,
for example): webbrowser.open(r'file://' +
fileName) starts Acrobat Reader with the
document read in. I have no idea why, because
Acrobat Reader sure ain't my browser;)
Maybe someone could try this out on Linux.
Cheers,
Jussi
Dennis Lee Bieber kirjoitti:
On Tue, 13 Feb 2007 08:44:18 GMT, Jussi Salmela
<ti*********@hotmail.comdeclaimed the following in comp.lang.python:
>On Windows, this (where fileName is xyz.PDF, for example): webbrowser.open(r'file://' + fileName) starts Acrobat Reader with the document read in. I have no idea why, because Acrobat Reader sure ain't my browser;)
Most likely Adobe installed the Acrobat plug-in for the browser...
The browser identifies the file as PDF and passes it to the plug-in for
rendering.
I can read PDFs with the browser if I open them in there.
But as I was trying to tell the line above starts the Acrobat Reader EXE
in its own window. The mechanism is probably caused by something I must
have done/installed, but I don't know what.
Anyway: it works just as I want although this may not be the general
behaviour.
(OS: Win XP SP2, Python 2.4.3)
Cheers,
Jussi
For those who care,
the file below should run on a unix/ linux style
system. And "xpdf", amoung others, will run a pdf
file.
import os
def Printpdf():
os.system( 'xpdf form.pdf' )
if __name__ == '__main__' :
Printpdf()
jim-on-linux
On Tue, 13 Feb 2007 08:44:18 GMT, Jussi Salmela
<ti*********@hotmail.comdeclaimed the
following in comp.lang.python:
On Windows, this (where fileName is xyz.PDF,
for example): webbrowser.open(r'file://' +
fileName) starts Acrobat Reader with the
document read in. I have no idea why, because
Acrobat Reader sure ain't my browser;)
Most likely Adobe installed the Acrobat
plug-in for the browser... The browser
identifies the file as PDF and passes it to the
plug-in for rendering.
--
Wulfraed Dennis Lee Bieber KD6MOG wl*****@ix.netcom.com wu******@bestiaria.com HTTP://wlfraed.home.netcom.com/
(Bestiaria Support
Staff: we******@bestiaria.com) HTTP://www.bestiaria.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kay Lee |
last post by:
Hi,
I looked up os module to find out some method to move and copy files in
python,
but os doesn't support such methods.
Is there any way to move & copy files in python?
Thanks in adv.
|
by: Peter Hansen |
last post by:
Greetings.
Im trying to write a program that can be run from the command line.
If I want to search for example after a file with the ending .pdf, I should
be able to write in the command line:...
|
by: Shufen |
last post by:
Hi,
I'm a newbie that just started to learn python, html and etc. I have
some questions to ask and hope that someone can help me on.
I'm trying to code a python script (with HTML) to get...
|
by: News |
last post by:
Hi Everyone,
The attached code creates client connections to websphere queue managers
and then processes an inquiry against them.
The program functions when it gets options from the command...
|
by: JKPeck |
last post by:
I am trying to understand why, with nonwestern strings, I sometimes get
a hex display and sometimes get the string printed as characters.
With my Python locale set to Japanese and with or without...
| |
by: walterbyrd |
last post by:
Lets suppose, I want a listing of what hardware and software is
installed on my
windows box. Can I do that with Python?
|
by: CC |
last post by:
Hi:
I'm building a hex line editor as a first real Python programming exercise.
Yesterday I posted about how to print the hex bytes of a string. There
are two decent options:
ln =...
|
by: koutoo |
last post by:
Is it possible to display messages in the python shell? I want to
display error messages based on parameters in my scripts to the
users. Is there another way to display messages other than log...
|
by: boblatest |
last post by:
Hello,
it's still me, being unable to load certain modules (for instance,
odbc) in scripts that run though IDLE. I've now written a self-
containing script that illustrates the whole problem:
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |