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

print pdf file to network printer using python

Well, Ive been searching through google groups and Ive seen a lot about
printing a pdf file, but I havent seen a definite answer. I tried this
code:

f = open(printer_path, 'w')
f.write(pdffile_path)
f.close()

Basically it doesnt work and what it prints out is the value of
pdffile_path variable. If anyone can offer some help, Id appreaciate it
thanks!

--Barry

Jul 21 '05 #1
2 7261
On 2005-07-21, scrimp <sc*******@yahoo.com> wrote:
Well, Ive been searching through google groups and Ive seen a lot about
printing a pdf file, but I havent seen a definite answer. I tried this
code:

f = open(printer_path, 'w')
f.write(pdffile_path)
f.close()

Basically it doesnt work and what it prints out is the value of
pdffile_path variable. If anyone can offer some help, Id appreaciate it
thanks!


You forgot to read the data from the pdf file.

f = open(printer_path, 'w')
f.write(open(pdffile_path,'rb').read())
f.close()

--
Grant Edwards grante Yow! Yow! It's a hole
at all the way to downtown
visi.com Burbank!
Jul 21 '05 #2
I just tried it and all that printed out was garbage. I found another
way to do it. It all depends on what you wanna do. If u want to print
to the default printer (easiest way) then just use this line:

win32api.ShellExecute(0, "print", file_path, None, ".", 0)

file_path of course being the full path of the file

Now, if u wanna print to another printer then u have to add a line:

win32print.SetDefaultPrinter(printer_name)
win32api.ShellExecute(0, "print", file_path, None, ".", 0)

printer_name being the NAME of the printer that is installed on the
machine not the path of the printer

Everything works good and the PDF file comes out perfect. The only
problem I have is that ShellExecute command starts up a blank session
of Acrobat Reader. I need that Acrobat to be terminated. I think by
using ShellExecute it does not provide the correct handle that python
needs to terminate the process. Any suggestions?

Jul 21 '05 #3

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

Similar topics

2
by: Nikolay Seksenov | last post by:
I am developing VB.Net Web application to be used in our department intranet. I created a web-based report using Crystal Reports. I would like to print the report from the web server instead of...
0
by: KohlerTommy | last post by:
In my application I need to give the user the ability to print duplex if the selected printer supports duplex printing. Many of the printer options do not make much sense in my application, and...
0
by: Tessa | last post by:
Is there any security reason why you cannot print to a network printer from ASP.NET under IIS6 on Windows 2003 server? I'm using ASP.NET code to print to a server print queue using...
13
by: Daniel Crespo | last post by:
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...
56
by: peng | last post by:
Hi, I am development a project using C#.Net. Inside application, it needs to print labels on different Zebra label printers on the network. I used a shell script, but it only worked on the...
0
by: John Smith | last post by:
Hello, I am developing a VB.NET 2003 application that will use lots of Crystal Reports. Sometimes the users will preview a report in a Crystal report viewer, and sometimes they will send the...
0
by: jigsmshah | last post by:
i am working on a project (windows service using VB.Net and C#) which gets the check details and check images from the database and prints the check to a printer. Printer name is configured in a...
10
by: Snoopy33 | last post by:
I have a DB that I developed on access XP (2002) and deployed over a year ago. No one has had problems printing any of the reports within the DB until we started loading 2007 on new computers. ...
1
by: =?Utf-8?B?SmJhcmJlcg==?= | last post by:
All users in my XP Professional PC were able to print to a network printer until now. Now, the only account that can print to the network printer is the admin account. I have an HP PSC 2200 series...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.