Click here to Skip to main content
16,016,180 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
https://support.microsoft.com/en-us/kb/322091[^]

I copy pasted code written in article in above link.
But problem is that Printer prints garbage data when I click on button1. File is PDF which contains an image and some texts.

Printer model: M129C
EPSON TM-T88III

Actually I want to print a receipt which contains Logo Image and product info.
Please guide me.
Posted
Updated 29-Jun-15 5:58am
v2

1 solution

That code is for sending raw printer data to a printer, effectively bypassing the printer driver which normally translates it into something the printer hardware can understand. It expects that the data it reads from a file is already compatible with the exact make and model of printer you are using.

A PDF file is not, it's a general purpose file description language, which needs to be translated and sent via the printer driver.

What you are doing at the moment is effectively passing a Japanese-to-Swahili dictionary to a Swedish speaker and expecting him to understand the story... :laugh:

If you want to print a receipt (with an image or not) look at using a PrintDocument[^] instead - the link includes an example.
 
Share this answer
 
Comments
DoingWork 29-Jun-15 14:41pm    
Thanks for your reply.....
I have tried your link. .txt file printing is successful but same problem when path of .PDF file is given. Starts Garbage printing.

Here are Document setting in Under Printing preference option.
Paper conversation: bottom
Print all text as graphic Image: NO
Paper Source: Document [No feed, No cut]
Large device font smoothing: Enable
OriginalGriff 29-Jun-15 14:50pm    
As I said:
"A PDF file is not, it's a general purpose file description language, which needs to be translated and sent via the printer driver."
Which means you need to read the PDF file using a PDF reader of some variety (there are some on the site here if you search, I believe) and print the result - you can't just send a PDF file to a printer and expect it to work out what you want!
If all you are trying to do is print a receipt from your app, then forget PDF completely, and print it directly via a PrintDocument.
DoingWork 7-Dec-15 22:03pm    
Agree with your comments........

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900