473,396 Members | 2,121 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,396 software developers and data experts.

Print a PDF transparently

Hi to all,

I want to print a PDF right from my python app transparently. With
"transparently" I mean that no matter what program handles the print
petition, the user shouldn't be noticed about it.

For example, when I want to print a PDF, Adobe Acrobat fires and keep
opened. This is what I don't want to happen (and I thing there are a
lot of people who want this too). So I just want to send the PDF to the
right handler and print it. That's all.

I've seen some things like Adobe's Postscript driver that can read a
PDF, or Ghostscript, but I still don't know how to use it.

Any help for printing a PDF transparently?

Thank you

Daniel

Feb 17 '06 #1
13 2997

Daniel Crespo wrote:
Hi to all,

I want to print a PDF right from my python app transparently. With
"transparently" I mean that no matter what program handles the print
petition, the user shouldn't be noticed about it.

For example, when I want to print a PDF, Adobe Acrobat fires and keep
opened. This is what I don't want to happen (and I thing there are a
lot of people who want this too). So I just want to send the PDF to the
right handler and print it. That's all.

I've seen some things like Adobe's Postscript driver that can read a
PDF, or Ghostscript, but I still don't know how to use it.

Any help for printing a PDF transparently?


The only way I was able to find to do it (for free) was to install
GhostScript and GSView. GSView comes with GSPrint.exe, which you can
call with a regular command line to send PDF files to a printer. It
uses GhostScript for you behind the scenes because GhostScript is not
exactly the friendliest program to work with.

Feb 17 '06 #2
In article <11**********************@o13g2000cwo.googlegroups .com>,
Daniel Crespo <dc*****@gmail.com> wrote:
Hi to all,

I want to print a PDF right from my python app transparently. With
"transparently" I mean that no matter what program handles the print
petition, the user shouldn't be noticed about it.

For example, when I want to print a PDF, Adobe Acrobat fires and keep
opened. This is what I don't want to happen (and I thing there are a
lot of people who want this too). So I just want to send the PDF to the
right handler and print it. That's all.

I've seen some things like Adobe's Postscript driver that can read a
PDF, or Ghostscript, but I still don't know how to use it.

Any help for printing a PDF transparently?

Feb 17 '06 #3
On 2006-02-17, Daniel Crespo <dc*****@gmail.com> wrote:
I want to print a PDF right from my python app transparently. With
"transparently" I mean that no matter what program handles the print
petition, the user shouldn't be noticed about it.
This works for me:

system("lpr whatever.pdf")

Or alternatively,

os.popen("lpr"."w").write(myBigStringContainingPDF )
For example, when I want to print a PDF, Adobe Acrobat fires and keep
opened. This is what I don't want to happen (and I thing there are a
lot of people who want this too). So I just want to send the PDF to the
right handler and print it. That's all.


See above.

--
Grant Edwards grante Yow! hubub, hubub, HUBUB,
at hubub, hubub, hubub, HUBUB,
visi.com hubub, hubub, hubub.
Feb 17 '06 #4
Hi, Thanks for all the answers.

My main purpose is to print on Windows systems (98,2000,XP) and permit
to print pages of 1/3 of a letter height, and make the printer to stop
at that point (in dot matrix printers). When I have a PDF with that
paper size and send it to print from Acrobat, it prints and stops
perfect (in Win98, I have to create a custom form consisting of that
paper size). The problem is that PDF files have to be handled by
external applications, or non-free drivers.

Based on all this, I have been investigating about postscript files. I
realize that printers do handle this language, so I think if I have a
..ps file and send it directly to the printer, it should do the job,
right? (this is certainly a question) If the answer is True, no matter
in what platform I am, if I send the same .ps to the printer, it should
print the same result.

And if all of these is true, then, my problem reduces to generate the
..ps file.

Comments please

Daniel

Feb 17 '06 #5
> Based on all this, I have been investigating about postscript files. I
realize that printers do handle this language, so I think if I have a
.ps file and send it directly to the printer, it should do the job,
right? (this is certainly a question) If the answer is True, no matter
in what platform I am, if I send the same .ps to the printer, it should
print the same result.


No. There are PostScript-Printers out there - but your off-the-shelf InkJet
isn't, and that's the reason why there usually has to be some sort of
driver in-between. Which is either GS or, in case of PDF, the acrobat-* or
any other PDF-printer-emulator.

maybe you can go down the rocky road of automation here, remote-controlling
acrobat reader. But I doubt that it wouldn't at least flash up with its
window for as long as the printing lasts.

Diez
Feb 17 '06 #6
In article <45************@uni-berlin.de>,
Diez B. Roggisch <de***@nospam.web.de> wrote:
Based on all this, I have been investigating about postscript files. I
realize that printers do handle this language, so I think if I have a
.ps file and send it directly to the printer, it should do the job,
right? (this is certainly a question) If the answer is True, no matter
in what platform I am, if I send the same .ps to the printer, it should
print the same result.


No. There are PostScript-Printers out there - but your off-the-shelf InkJet
isn't, and that's the reason why there usually has to be some sort of
driver in-between. Which is either GS or, in case of PDF, the acrobat-* or
any other PDF-printer-emulator.

maybe you can go down the rocky road of automation here, remote-controlling
acrobat reader. But I doubt that it wouldn't at least flash up with its
window for as long as the printing lasts.

Diez


Right. It's possible, barely, to achieve the desired result
with Ghostscript, but it's going to take considerable care in
installation and configuration. We do this sort of thing, but
only on hosts we control; the thought of full-blown "producti-
zation" (let alone the licensing) intimidates me.
Feb 17 '06 #7
On 2/17/2006 9:02 AM, Daniel Crespo wrote:
Hi to all,

I want to print a PDF right from my python app transparently. With
"transparently" I mean that no matter what program handles the print
petition, the user shouldn't be noticed about it.

For example, when I want to print a PDF, Adobe Acrobat fires and keep
opened. This is what I don't want to happen (and I thing there are a
lot of people who want this too). So I just want to send the PDF to
the right handler and print it. That's all.

I've seen some things like Adobe's Postscript driver that can read a
PDF, or Ghostscript, but I still don't know how to use it.

Any help for printing a PDF transparently?

Thank you

Daniel

You may find that RedMonEE is a useful piece to your puzzle. I find it
to be stable and quite invaluable.

http://www.is-foehr.de/ RedMon - Redirection Port Monitor EE

Transparent PostScript printing from Windows NT, W2K and XP. Overview
The RedMon EE port monitor redirects a special printer port to a
program. RedMon EE is commonly used with Ghostscript and a
non-PostScript printer to emulate a PostScript printer.

RedMon EE can be used with any program that accepts data on standard
input.

Using RedMon EE you create a redirected printer port. If you connect
a Windows printer driver to the redirected printer port, all data
sent to the redirected port will be forwarded by RedMon to the
standard input of a program. The output of this program can be sent
to different printer port, or the program can generate whatever
output it desires.

A PostScript Windows printer redirected to a RedMon port can shared
on a network. When this printer is configured to use Ghostscript and
a non-PostScript printer, it appears as a PostScript printer to other
network clients.

Feb 17 '06 #8
> Adobe has a Windows PostScript driver for free; but that still
leaves you out... It works as a "printer" but you still have to run the
normal application to print /to/ it -- and that is what you say you
don't want! http://www.adobe.com/support/downloa...jsp?ftpID=1500


Yes, I've seen it, but that's it: another program that I have to
install, which I want to avoid.

I'd be happy if I just do "printer.Print(file.pdf/.ps)" and walá, the
printing just starts (in 98,2000,XP... sounds like a dream), without
having another window opened. If it opens, but then closes, it's
perfect too. I have tried installing Ghostscript, and having a .ps when
I order that file to print, it does the job. The thing here is that I
have to install it.

All this has to be easilly installed (with InnoSetup, for example),
because I have to install it on 70 offices. So I can't leave it to
another installation process. All of these offices have a dot matrix
printers Epson LX-300, which has PostScript level 3 built-in.

Where can I find how to send a .ps directly to the printer?

Daniel

Feb 17 '06 #9

Daniel Crespo wrote:
Yes, I've seen it, but that's it: another program that I have to
install, which I want to avoid.

I'd be happy if I just do "printer.Print(file.pdf/.ps)" and walá, the
printing just starts (in 98,2000,XP... sounds like a dream), without
having another window opened. If it opens, but then closes, it's
perfect too. I have done such thing a few years back, just use the file association
and the "print/printto" action. All you need is to have Acrobat
installed. You can try it by right click on the desktop on a .PDF file
and select print. A modeless dialog would still be visible but would
close itself. This was using ancient Acrobat Reader.

You need to read the WIN32 API(I faintly remembered about Shell
something) that tells you how to do it programmatically(I used C).

All this has to be easilly installed (with InnoSetup, for example),
because I have to install it on 70 offices. So I can't leave it to
another installation process. All of these offices have a dot matrix
printers Epson LX-300, which has PostScript level 3 built-in.

Where can I find how to send a .ps directly to the printer?

Again, in the WIN32 API and unfortunately 98 and NT family has
completely different mechanism.

Feb 17 '06 #10

Where can I find how to send a .ps directly to the printer?


Have you seen this?
http://tgolden.sc.sabren.com/python/...o_i/print.html
In particular, the section on using win32print directly.

Brian.

Feb 18 '06 #11
> Have you seen this?
http://tgolden.sc.sabren.com/python/...o_i/print.html
In particular, the section on using win32print directly.


Yes, I have. The problems is that an external program is launched for
handling the file and print it. In the case of PDF, acrobat is
launched. In the case of PS, Ghostview is launched. When printing a
PDF, acrobat keeps alive, so the user has to close it manually. On the
other hand, Ghostview is opened, prints the file and closes
automatically. The last one is which I find the best for me, until now,
(because the Ghostview closes automatically). If I decide to go this
way, my problem then is to transform a pdf to ps, or generate a ps
directly.

For further information on what I want, please, refer to my first two
posts in this topic.

Any other help?

Thank you very much

Feb 20 '06 #12
> Have you seen this?
http://tgolden.sc.sabren.com/python/...o_i/print.html
In particular, the section on using win32print directly.


Yes, I have. The problems is that an external program is launched for
handling the file and print it. In the case of PDF, acrobat is
launched. In the case of PS, Ghostview is launched. When printing a
PDF, acrobat keeps alive, so the user has to close it manually. On the
other hand, Ghostview is opened, prints the file and closes
automatically. The last one is which I find the best for me, until now,
(because the Ghostview closes automatically). If I decide to go this
way, my problem then is to transform a pdf to ps, or generate a ps
directly.

For further information on what I want, please, refer to my first two
posts in this topic.

Any other help?

Thank you very much

Feb 20 '06 #13
This seems to work ok with acrobat 7 (don't know if it will work
with earlier versions). The only thing I had to tweak was
acrobat's security setting for allowing print via script operations.
I didn't try to figure out how to wait until the print was finished.

hth
Roger
import win32com.client, time
ie = win32com.client.Dispatch('InternetExplorer.Applica tion')
## ie.Visible=1
ie.Navigate('somedocument.pdf')
while ie.Busy:
time.sleep(1)
ie.Document.printPages(1,3)

"Daniel Crespo" <dc*****@gmail.com> wrote in message news:11**********************@f14g2000cwb.googlegr oups.com...
Have you seen this?
http://tgolden.sc.sabren.com/python/...o_i/print.html
In particular, the section on using win32print directly.


Yes, I have. The problems is that an external program is launched for
handling the file and print it. In the case of PDF, acrobat is
launched. In the case of PS, Ghostview is launched. When printing a
PDF, acrobat keeps alive, so the user has to close it manually. On the
other hand, Ghostview is opened, prints the file and closes
automatically. The last one is which I find the best for me, until now,
(because the Ghostview closes automatically). If I decide to go this
way, my problem then is to transform a pdf to ps, or generate a ps
directly.

For further information on what I want, please, refer to my first two
posts in this topic.

Any other help?

Thank you very much


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Feb 21 '06 #14

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

Similar topics

12
by: Michael Foord | last post by:
Here's a little oddity with 'print' being a reserved word... >>> class thing: pass >>> something = thing() >>> something.print = 3 SyntaxError: invalid syntax >>> print something.__dict__...
14
by: Marcin Ciura | last post by:
Here is a pre-PEP about print that I wrote recently. Please let me know what is the community's opinion on it. Cheers, Marcin PEP: XXX Title: Print Without Intervening Space Version:...
0
by: Jim Hammond | last post by:
I have a client-side component that captures an image and saves it in a file on the client system's hard drive. Although I can return text data from the component and transparently get that text...
4
by: Jim Hammond | last post by:
Is there any way to transparently get an image file from the client machine to the server? I already have a way to transparently generate the file and query for the file name (all done on the...
0
by: denz | last post by:
Hi, Basically, in the client proxy that is refering to a web service, i want to be able to switch automatically and transparently, from one URL to another (location of the mirrored service) when...
1
by: Steff | last post by:
I am wandering if my code is making sense... I use a lot the print function. Is it weird in this case where I have to display an array ? I thought it would be better to have the entire array in php...
3
by: James J. Besemer | last post by:
I would like to champion a proposed enhancement to Python. I describe the basic idea below, in order to gage community interest. Right now, it's only an idea, and I'm sure there's room for...
0
by: Chris Newby | last post by:
I'm looking for a way to transparently encrypt cookie data using Asp.Net 1.1. Ideally, developers could still do things like: HttpCookie cookie = new HttpCookie( "clearTextKey",...
6
by: ken | last post by:
is there a way to make a php page only output content that is generated from php statements, such as print, or echo? ie: if I have whitespace (or other text) outside my <?php .... ?block i do not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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:
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...
0
Oralloy
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,...
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...
0
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,...

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.