473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PDF Printing support from Python

Hi all... Is there a way to print a PDF file directly from Python
without having Acrobat installed? I know about ReportLab. It's a python
module that lets you create almost any PDF document, but I still don't
know if it supports printing, so I'm looking for a Python module that
could do it. I want to print a PDF file just like if I were doing it
from Acrobat.

Daniel.

Jul 19 '05 #1
19 3150
On 2005-04-22, dcrespo <dc*****@gmail.com> wrote:
Hi all... Is there a way to print a PDF file directly from
Python without having Acrobat installed?
Assuming your printing system was setup competently:

os.system("lpr %s" % filename)
I know about ReportLab. It's a python module that lets you
create almost any PDF document, but I still don't know if it
supports printing, so I'm looking for a Python module that
could do it. I want to print a PDF file just like if I were
doing it from Acrobat.


Not sure what you mean by "just like if I were doing it from
Acrobat".

--
Grant Edwards grante Yow! I have seen these
at EGG EXTENDERS in my
visi.com Supermarket... I have read
theINSTRUCTIONS...
Jul 19 '05 #2
Hi Grant Edwards...

Your solution requires a previous installation of Acrobat. Internally,
the OS is sending the pdf file to the Acrobat PDF Driver and then it is
sent to the printer. So you have to have Acrobat installed. Don't you?
I want to avoid it installing a module that could do it (maybe I'm
dreaming:( ). If there's no solution, then I will be very sad :-S

This is what exactly I need to do:
Generate an invoice of 216cm width and 93cm height (1/3 of the height
of a letter paper size), and print it respecting these dimensions. So,
when I print this page on a dot matrix printer, it stops at those 93cm
of height for continuous printing.

What I tried:
I created a pdf file manually with these dimensions, and right-click on
the pdf file, and selected "print". It just work under Windows XP with
Acrobat Reader 7.0, but I want to do it from a Win98 as well.
Unfortunately, there's no Acrobat version under Win98 (the maximun is
5.1) that supports this kind of printing (what I had seen until now).
It prints, but the all paper at letter size :(

Any help? Any other tools? Any one like Cristal Report but for Python?
I heard that wxPython supports some kind of reporting, but I don't know
it. Anyone knows?

Daniel

Jul 19 '05 #3
"dcrespo" <dc*****@gmail.com> writes:
Hi Grant Edwards...

Your solution requires a previous installation of Acrobat. Internally,
the OS is sending the pdf file to the Acrobat PDF Driver and then it is
sent to the printer. So you have to have Acrobat installed. Don't you?
I want to avoid it installing a module that could do it (maybe I'm
dreaming:( ). If there's no solution, then I will be very sad :-S

This is what exactly I need to do:
Generate an invoice of 216cm width and 93cm height (1/3 of the height
of a letter paper size), and print it respecting these dimensions. So,
when I print this page on a dot matrix printer, it stops at those 93cm
of height for continuous printing.

What I tried:
I created a pdf file manually with these dimensions, and right-click on
the pdf file, and selected "print". It just work under Windows XP with
Acrobat Reader 7.0, but I want to do it from a Win98 as well.
Unfortunately, there's no Acrobat version under Win98 (the maximun is
5.1) that supports this kind of printing (what I had seen until now).
It prints, but the all paper at letter size :(

Any help? Any other tools? Any one like Cristal Report but for Python?
I heard that wxPython supports some kind of reporting, but I don't know
it. Anyone knows?

Daniel

When you say "OS", are you talking MS Windows by any chance? On *NIX
(e.g., CUPS+ghostview+foomatic), PDF printing is not via Adobe code.

You could also consider pdf2ps, pdftops, and XPDF.
--
ha************@boeing.com
6-6M21 BCA CompArch Design Engineering
Phone: (425) 294-4718
Jul 19 '05 #4
On 2005-04-22, dcrespo <dc*****@gmail.com> wrote:
Your solution requires a previous installation of Acrobat.
Probably not. Most printing systems I'm familiar with use
ghostscript to render PDF into either postscript (the case on
my machines at home) or whatever raster format the printer
desires (the case at my office).
Internally, the OS is sending the pdf file to the Acrobat PDF
Driver and then it is sent to the printer.
Nope. It's usnig the foomatic print filters which in turn use
ghostscript to render PDF.
So you have to have Acrobat installed. Don't you?
No you just need a good printing system. CUPS + foomatic works
great for me. It knows what to do with postcript, text, PDF,
dvi, and a whole boatload of other fileformats that I don't
ever use.
I want to avoid it installing a module that could do it (maybe
I'm dreaming:( ). If there's no solution, then I will be very
sad :-S

This is what exactly I need to do: Generate an invoice of
216cm width and 93cm height (1/3 of the height of a letter
paper size), and print it respecting these dimensions. So,
when I print this page on a dot matrix printer, it stops at
those 93cm of height for continuous printing.

What I tried: I created a pdf file manually with these
dimensions, and right-click on the pdf file, and selected
"print". It just work under Windows XP with Acrobat Reader
7.0, but I want to do it from a Win98 as well.


Ah. You're using Windows. I didn't know that. I've no clue
what to do under Windows.

--
Grant Edwards grante Yow! .. someone in DAYTON,
at Ohio is selling USED
visi.com CARPETS to a SERBO-CROATIAN
Jul 19 '05 #5
Grant's example is not for Windows, Daniel, but it does illustrate a
certain principle: if you have a printer driver that understands PDF,
or some other external software such as Acrobat Reader that understands
PDF, then printing the PDF is as simple as telling the OS to just print
the file.

If you are looking for some software that acts as a PDF-understanding
interpreter, that must run under Windows 98, I don't know of any
written in Python. However, you might want to research some of the
available non-Python utilities. Ghostscript, for example, is available
at http://www.cs.wisc.edu/~ghost/ and has a version for Win32. You
could easily use Python to drive GhostScript.

Does that fit your needs?

---Peter

Jul 19 '05 #6
"dcrespo" <dc*****@gmail.com> writes:
Hi Grant Edwards...

Your solution requires a previous installation of Acrobat. Internally,
the OS is sending the pdf file to the Acrobat PDF Driver and then it is
sent to the printer. So you have to have Acrobat installed. Don't you?
I want to avoid it installing a module that could do it (maybe I'm
dreaming:( ). If there's no solution, then I will be very sad :-S [...] Acrobat Reader 7.0, but I want to do it from a Win98 as well.
Unfortunately, there's no Acrobat version under Win98 (the maximun is
5.1) that supports this kind of printing (what I had seen until now).
It prints, but the all paper at letter size :(
That doesn't sound like a fundamental problem with AR 5.1 to me --
sounds like you just need to ask it more nicely ;-)

Have you tried the latest version of APFL ghostscript, though (8.51)?

Any help? Any other tools? Any one like Cristal Report but for Python?
I heard that wxPython supports some kind of reporting, but I don't know
it. Anyone knows?


First, decide what qualities you need from your output format, then
decide which format you want, and how to generate and print it. Is it
important that you have one, other, or both of bitmap or vector
output, for example?
John
Jul 19 '05 #7
Thanks a lot... I'm attemping to give it a try :)

Jul 19 '05 #8
> That doesn't sound like a fundamental problem with AR 5.1 to me --
sounds like you just need to ask it more nicely ;-)

AR 7.0 has the function to print exactly the page size you set. AR 5.1
doesn't. Instead, it print it on an existing page size like letter, but
without changing the relative layout of the each line of text respect
each other.

Daniel

Jul 19 '05 #9
>> Your solution requires a previous installation of Acrobat.
Probably not. Most printing systems I'm familiar with use
ghostscript to render PDF into either postscript (the case on
my machines at home) or whatever raster format the printer
desires (the case at my office).
Acrobat (windows) and Ghostscript are PDF drivers.
Internally, the OS is sending the pdf file to the Acrobat PDF
Driver and then it is sent to the printer.

Nope. It's usnig the foomatic print filters which in turn use
ghostscript to render PDF.
What I mean is that the pdf file is sent to a pdf driver (some program
to interpret it)... In your case is ghostscript, and in my case is
Acrobat.
No you just need a good printing system. CUPS + foomatic works
great for me. It knows what to do with postcript, text, PDF,
dvi, and a whole boatload of other fileformats that I don't
ever use.


CUPS + foomatic are the whole megadriver... So it's just a manner of
saying PDF Driver for my study case.

Really thanks for all the information :) I didn't know about
Ghostscript.

Daniel

Jul 19 '05 #10
On 2005-04-22, dcrespo <dc*****@gmail.com> wrote:
Your solution requires a previous installation of Acrobat.
Probably not. Most printing systems I'm familiar with use
ghostscript to render PDF into either postscript (the case on
my machines at home) or whatever raster format the printer
desires (the case at my office).
Acrobat (windows) and Ghostscript are PDF drivers.


No, ghostscript isn't a "driver". it's a normal user-space
application, but I'm not sure what you're point is. My
statement that printing PDF doesn't depend on Acrobat is true
regardless of whether ghostscript is a driver or application.
Internally, the OS is sending the pdf file to the Acrobat PDF
Driver and then it is sent to the printer.
Nope. It's usnig the foomatic print filters which in turn use
ghostscript to render PDF.


What I mean is that the pdf file is sent to a pdf driver (some
program to interpret it)... In your case is ghostscript, and
in my case is Acrobat.


That's not a driver. At least not in my world. Drivers live
in kernel space. Acrobat and ghostscript are just applications
that run in user-space.
No you just need a good printing system. CUPS + foomatic works
great for me. It knows what to do with postcript, text, PDF,
dvi, and a whole boatload of other fileformats that I don't
ever use.


CUPS + foomatic are the whole megadriver... So it's just a
manner of saying PDF Driver for my study case.


You're use of the word "driver" is one with which I'm not
familiar. But I don't really "do windows" so it's probably a
Widnowism.
Really thanks for all the information :) I didn't know about
Ghostscript.


I'm sure you can use ghostscript to do the same thing under
Windows (render PDF into the raster format preferred by your
printer), but I've no idea how one would go about it.

--
Grant Edwards grante Yow! Hmmm... a CRIPPLED
at ACCOUNTANT with a FALAFEL
visi.com sandwich is HIT by a
TROLLEY-CAR...
Jul 19 '05 #11
"dcrespo" <dc*****@gmail.com> writes:
Hi Grant Edwards...

Your solution requires a previous installation of Acrobat. Internally,
the OS is sending the pdf file to the Acrobat PDF Driver and then it is
sent to the printer. So you have to have Acrobat installed. Don't you?
No, you don't. My print system does that, and I don't have acrobat
installed. I have ghostscript installed, which includes pdf2ps - which
handles this particular translation.
This is what exactly I need to do:
Generate an invoice of 216cm width and 93cm height (1/3 of the height
of a letter paper size), and print it respecting these dimensions. So,
when I print this page on a dot matrix printer, it stops at those 93cm
of height for continuous printing.


Ok, I'm a masochist. When I have problems like this (i.e. - printing
CD labels, addressing envelopes, etc) I just have the python generate
raw postscript. That gives you more than enough control over the
output to solve the problem. Integrating it with a GUI is another
matter, though.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 19 '05 #12
> You're use of the word "driver" is one with which I'm not
familiar. But I don't really "do windows" so it's probably a
Widnowism.


It could be that he means that creating PDFs on windows is done using a fake
printer that will produce the pdf when being printed to - and that fake
printer is implemented as a driver.

And traditionally in printing one often speaks of printer drivers - even if
they are mere filters that can't be considered drivers in the kernel driver
way.
--
Regards,

Diez B. Roggisch
Jul 19 '05 #13
On 2005-04-23, Diez B. Roggisch <de*********@web.de> wrote:
You're use of the word "driver" is one with which I'm not
familiar. But I don't really "do windows" so it's probably a
Widnowism.


It could be that he means that creating PDFs on windows is
done using a fake printer that will produce the pdf when being
printed to - and that fake printer is implemented as a driver.

And traditionally in printing one often speaks of printer
drivers - even if they are mere filters that can't be
considered drivers in the kernel driver way.


I think it's the latter. I believe he wants to know how to
print a PDF file without using any external programs (or
"drivers") like Acrobat Reader or ghostscript that understand
PDF. AFAIK, the only way to do what he wants would be for him
to write a PDF engine in Python that renders PDF into whatever
raw format is understood by his printer.

--
Grant Edwards grante Yow! I'LL get it!! It's
at probably a FEW of my
visi.com ITALIAN GIRL-FRIENDS!!
Jul 19 '05 #14
On Fri, 22 Apr 2005 17:41:22 -0500, Mike Meyer <mw*@mired.org> declaimed
the following in comp.lang.python:
No, you don't. My print system does that, and I don't have acrobat
installed. I have ghostscript installed, which includes pdf2ps - which
handles this particular translation.
Okay, so you've converted one page layout language (PDF) to
another (PS)... To actually print it you still need a RIP. A PostScript
laser printer has the RIP built-in, but consumer level Windows printers
do not have a PostScript RIP -- and some printers don't even have their
own specific RIP built-in ("winprinters" put the RIP into the software
driver that runs on the Windows machine, rather than sending drawing
commands to the printer for rendering).

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 19 '05 #15
> You're use of the word "driver" is one with which I'm not
familiar. But I don't really "do windows" so it's probably a
Widnowism.

It is a windowism but not exclusively ;).
http://www.collaborium.org/onsite/ro...nprinters.html

This is the first link I found that mentioned drivers, but the last
time I installed Linux-Mandrake I saw a document that went into detail
about CUPS and windows printing.
It seems that cups is available for windows( they also use the word
driver )
http://www.cups.org/windows/index.php
Ghostscript for windows available here
http://www.ghostscript.com/
http://www.cs.wisc.edu/~ghost/

Jul 19 '05 #16
Dennis Lee Bieber <wl*****@ix.netcom.com> writes:
On Fri, 22 Apr 2005 17:41:22 -0500, Mike Meyer <mw*@mired.org> declaimed
the following in comp.lang.python:
No, you don't. My print system does that, and I don't have acrobat
installed. I have ghostscript installed, which includes pdf2ps - which
handles this particular translation.

Okay, so you've converted one page layout language (PDF) to
another (PS)... To actually print it you still need a RIP. A PostScript
laser printer has the RIP built-in, but consumer level Windows printers
do not have a PostScript RIP -- and some printers don't even have their
own specific RIP built-in ("winprinters" put the RIP into the software
driver that runs on the Windows machine, rather than sending drawing
commands to the printer for rendering).


RIP? That term is to generic for google to be much use.

If you're saying you need a tool to convert from PDF to whatever the
printer understands, you're right. You can't avoid that. On Unix, PS
is used as the "universal" printer language. Unix vendors selling
printers sold PS printers 20 years ago. That's when apsfilter showed
up on the scene, automatically converting everything to PS to send it
to the printer. (These days, magicfilter is a much better tool than
apsfilter, though it's harder to install). That's why a "competent"
printer installation these days will include ghostscript (or something
equivalent) to drive the printer, and why my primary printer speaks
PostScript.

I disagree with your description of WinPrinters. Those are printers to
stupid to handle flat ASCII, so your computer has to convert flat
ASCII files to postscript or some other graphics format before you can
print them. (This is where magicfilter beats apsfilter - apsfilter
converts ASCII to PS to graphics images, whereas magicfilter can pass
the text straight through. This has caused apsfilter to fail on some
systems where magicfilter would work like a charm). Such printers
typically only come with drivers for Windows, and are completely
useless - unable to even print flat ASCII text - on other systems,
hence the moniker "WinPrinters". Non-winprinters can be used to print
flat ASCII without a driver of any kind. GhostScript now includes
graphics drivers for several winprinters.

The only way to have Python render PDF (or PS, or JPEG, or any other
graphics format) without a "driver" of some kind is to write the
driver in Python. That's a pretty silly thing to want to do. For one
thing, the performance will probably suck. For another, there are lots
of drivers already written that you can use.

The only thing better than writing it in Python is finding that
someone else has already written it.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 19 '05 #17
On 2005-04-23, Mike Meyer <mw*@mired.org> wrote:
No, you don't. My print system does that, and I don't have
acrobat installed. I have ghostscript installed, which
includes pdf2ps - which handles this particular translation.

Okay, so you've converted one page layout language
(PDF) to another (PS)... To actually print it you still need a
RIP. A PostScript laser printer has the RIP built-in, but
consumer level Windows printers do not have a PostScript RIP
-- and some printers don't even have their own specific RIP
built-in ("winprinters" put the RIP into the software driver
that runs on the Windows machine, rather than sending drawing
commands to the printer for rendering).


RIP? That term is to generic for google to be much use.


Raster Image Processor. It renders postscript into a raster
image at the proper image.

--
Grant Edwards grante Yow! If this is the DATING
at GAME I want to know your
visi.com FAVORITE PLANET! Do I get
th' MICROWAVE MOPED?
Jul 19 '05 #18
On Sat, 23 Apr 2005 17:31:22 -0500, Mike Meyer <mw*@mired.org> declaimed
the following in comp.lang.python:

RIP? That term is to generic for google to be much use.
Raster Image Processor -- on a PostScript compatible laser
printer, this is the software and computer that converts PostScript
programs into the actual bitmap needed to print the page. Used to cost
extra to get PostScript capability on top of the printer native (HP PCL,
for example). Normally it runs inside the printer itself.
I disagree with your description of WinPrinters. Those are printers to
stupid to handle flat ASCII, so your computer has to convert flat
IE, absolutely NO RIP at all. Those that handle plain ASCII
still have a RIP to convert ASCII bytecodes to bit patterns for the
printhead.
-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 19 '05 #19
>>>>> "Diez B. Roggisch" <de*********@web.de> (DBR) wrote:
You're use of the word "driver" is one with which I'm not
familiar. But I don't really "do windows" so it's probably a
Widnowism.
DBR> It could be that he means that creating PDFs on windows is done using
DBR> a fake printer that will produce the pdf when being printed to - and
DBR> that fake printer is implemented as a driver.


But that is about creating a PDF file, whereas the OP was speaking about
printing an existing PDF file, For that you need a PDF interpreter, not a
PDF printer driver.
--
Piet van Oostrum <pi**@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: pi**@vanoostrum.org
Jul 19 '05 #20

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

Similar topics

5
by: Donnal Walter | last post by:
We want to be able to print HTML or PDF files to a given printer from Python in a kind of batch mode (without opening a preview window or printer dialog for each file). The printer is on a network,...
2
by: David Isaac | last post by:
I'd like to try personal financial management using Python. I just found PyCheckbook, but it does not support check printing. Is there a Python check printing application kicking around? Thanks,...
8
by: David Isaac | last post by:
"Alan Isaac" <aisaac0@verizon.net> wrote in message news:_A34e.2207$1r6.248@trnddc02... > I'd like to try personal financial management using Python. > I just found PyCheckbook, but it does not...
10
by: Mario | last post by:
Hello all, I'm trying hard to make possible to print some simple text from python to the default printer using wxPython, after days of internet searches I found this page:...
12
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but...
7
by: Burhan | last post by:
Hello Group: I am in the planning stages of an application that will be accessed over the web, and one of the ideas is to print a barcode that is generated when the user creates a record. The...
8
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web...
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
7
by: SpaceMarine | last post by:
hello, i have an application that builds up a large "incident report" for a law enforcement agency. In the end this is represented in a large object containing many properties and collections...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.