By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,526 Members | 2,207 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,526 IT Pros & Developers. It's quick & easy.

Print a PDF transparently

P: n/a
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
Share this Question
Share on Google+
13 Replies


P: n/a

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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
> 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

P: n/a
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

P: n/a
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

P: n/a
> 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

P: n/a

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

P: n/a

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

P: n/a
> 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

P: n/a
> 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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.