473,748 Members | 2,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.
Feb 11 '07 #1
17 8457
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.
Feb 11 '07 #2
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
Feb 11 '07 #3
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('myfil e.pdf')

Launches whatever is registered as .PDF viewer and user
can then print, save, zoom, etc. on their own.

-Larry
Feb 12 '07 #4
On 2007-02-12, Larry Bates <la*********@we bsafe.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('myfil e.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!!
Feb 12 '07 #5
Grant Edwards wrote:
On 2007-02-12, Larry Bates <la*********@we bsafe.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('myfi le.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
Feb 12 '07 #6
os.start does not work.. attribute error.
regards.
Krishnakant.
Feb 12 '07 #7
On 2007-02-12, Larry Bates <la*********@we bsafe.comwrote:
On 2007-02-12, Larry Bates <la*********@we bsafe.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('myf ile.pdf')

Eh? I don't see os.start() it either 2.5 or 2.44
documentatio n, 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('us er.pdf')
sh: user.pdf: command not found
32512
>>>
--
Grant Edwards grante Yow! Eisenhower!! Your
at mimeograph machine upsets
visi.com my stomach!!
Feb 12 '07 #8
On Feb 12, 3:06 pm, "krishnakan t Mane" <researchb...@g mail.comwrote:
os.start does not work.. attribute error.
regards.
Krishnakant.
It's os.system('thef ile') or os.system('star t 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.freede sktop.org/wiki/>

It works standalone. Even seems it would not take too much
effort to port it to python if you want.
Feb 12 '07 #9
Grant Edwards wrote:
On 2007-02-12, Larry Bates <la*********@we bsafe.comwrote:
>On 2007-02-12, Larry Bates <la*********@we bsafe.comwrote:
>>>>I at least need the code for useing some library for
connectin g 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('my file.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('us er.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
Feb 12 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
86471
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.
6
1778
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: python name of my program / the libary to search and what kind of file it is example a .pdf file So if my program name was test.py and the library name was library1 and the test type i wanted to find was, a .pdf file I should write python...
4
6169
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 values from a html form that consists of about 10 checkbox and a textbox where user have to key in a value to perform a search. From python tutors, I learned that I have to use the following method:
4
2389
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 line. It also works when pulling the options from a file.
6
3294
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 a # coding of cp932 (this is Windows) at the top of the file, I read a list of Japanese strings into a list, say, catlis. With this code for item in catlis: print item
1
1836
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?
5
2613
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 = '\x00\x01\xFF 456\x0889abcde~' import sys for c in ln:
3
2911
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 files? Thanks. Kou
5
1365
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: ---------------------------------- import sys, os # find odbc module in Python distribution tree:
0
8984
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9312
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8237
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4593
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2206
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.