How to print a PDF file using Win32 API

Hi,
Any sample code available for printing a PDF file to a printer?
Your response would be greatly appreciated.
Thanks,
Kannan
[156 byte] By [kannanbalu] at [2007-11-19 4:18:40]
# 1 Re: How to print a PDF file using Win32 API
Do you want to be able to print it from within your program yourself ?

Or, do you want to print it from within your program, but indirectly through Adobe ?
If it is the latter, you may want to try

1. ShellExecute with "print" as verb. I prefer this, since it would let windows do the dirty work of finding the right executable and invoking the proper command.

2. CreateProcess and send the following string ..
"C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe" /p /h "%1"

where %1 is the path to your .pdf file
kirants at 2007-11-9 13:13:52 >
# 2 Re: How to print a PDF file using Win32 API
Hi,
Thanks for your response. I was hoping to print the pdf without going through Adobe. Going through Adobe puts a hard condition on the customers to have Adobe installed on their machine.
Can't I do the same through Win32 API programatically?

Thanks,
Kannan
kannanbalu at 2007-11-9 13:14:50 >
# 3 Re: How to print a PDF file using Win32 API
Well. sure you could.. But, then you'd have to know what the pdf format is, right ? Is that your problem ?
kirants at 2007-11-9 13:15:49 >
# 4 Re: How to print a PDF file using Win32 API
> Well. sure you could.. But, then you'd have to know what the pdf format is, right ? > Is that your problem ?
Do you mean to say if I want to print an image, I need to know its format??

I was hoping that passing the PDF file to the printer driver through Win32 API could fix the problem or atleast if I could pass on the raw data to the printer that I know supports pdf format for sure.

Isn't that possible?

Thanks,
Kannan
kannanbalu at 2007-11-9 13:16:54 >
# 5 Re: How to print a PDF file using Win32 API
Do you mean to say if I want to print an image, I need to know its format??

Yes. It works like that. When one prints a bitmap or a Word document , you need to do all that stuff of specifying what color to use, what font to use what lines to draw and all that. That is all the detailed working of printing. And that is why you would see that they work on most printers.

I was hoping that passing the PDF file to the printer driver through Win32 API could fix the problem or atleast if I could pass on the raw data to the printer that I know supports pdf format for sure.

Not sure about pdf files. But there are times when there is some proprietary printer, say a plotter, that needs a proprietary command to be sent. In that case, you can stream in raw data to the printer.. When you say printer supports pdf format, what do you mean ?
kirants at 2007-11-9 13:17:51 >
# 6 Re: How to print a PDF file using Win32 API
I guess you mean postscript printers.

May be these links will lead you somewhere...
http://www.codeproject.com/printing/printingtricksandtips.asp?df=100&forumid=4144&exp=0&select=443983#xx443983xx

This one is just some info:
http://www.adobe.com/print/features/psvspdf/main.html
kirants at 2007-11-9 13:18:50 >
# 7 Re: How to print a PDF file using Win32 API
I have never found the PDF dcumentation format, have you found it ? It could serve, but I think that Adobe not made it public, or yes ?

Bye :)
Elementer at 2007-11-9 13:19:56 >
# 8 Re: How to print a PDF file using Win32 API
Try http://www.wotsit.org and search for pdf; you'll find PDF file format specifications.

Snakekaa
Snakekaa at 2007-11-9 13:20:59 >
# 9 Re: How to print a PDF file using Win32 API
Yeah. That's a good site.. I found it very useful too ..
kirants at 2007-11-9 13:21:55 >