2

Possible Duplicate:
Delphi: How to print a PDF without showing it?

I am encountering different behavior while printing on different printers. On my printer the PDF print is correct but with "Brother" printers the same PDF is printed as gibberish (the content of the file gets printed). If the same PDF file is directly sent to printer using Adobe Reader, its printed correctly on the brother printer also.

To print the PDF file, I read the content in a TMemoryStream object using LoadFromFile function. The docinfo values specified are as below -

DocInfo.pDocName := pChar('My Document');
DocInfo.pOutput := Nil;
DocInfo.pDatatype := pChar('RAW');

After that Using the WritePrinter function, the command is sent to the printer handle.

Looks to me as if brother printer is not able to read the PDF encoding format.

Any help in this regard is appreciated.

P.S : My application is in Delphi4.

Community
  • 1
  • 1
Vic
  • 21
  • 1
  • @ Jeroen, I have tried printing the same pdf with ShellExecute command as below ShellExecute(Application.Handle, 'printto','Filename', PChar(printerInfo), nil, SW_HIDE) ; However with this, I was able to print it,but on the other hand it opens a Adobe reader pop-up which is annoying. Is there any option that I have missed to hide this pop-up. Thanks. – Vic Oct 07 '12 at 08:34
  • @Vic Welcome to stackoverflow. Please read the other options that my answer refers to. In addition: you should comment on an answer, not to the question. That is the only way that people posting an answer will get notified of comments. – Jeroen Wiert Pluimers Oct 07 '12 at 17:11

1 Answers1

3

WritePrinter is for sending raw printer specific data to a printer.

Some printers understand PDF, some don't.

You should have an application that understands PDF print it to the printer.

Many applications can do that, the most prominent of course Adobe Reader.

This answer shows three ways of doing that: Adobe Reader ActiveX, Adobe Reader application, GhostView/GhostPrint. It also references a few other ways.

Community
  • 1
  • 1
Jeroen Wiert Pluimers
  • 23,965
  • 9
  • 74
  • 154
  • Thanks Jeroen. My concern is when I read and send the command using WritePrinter,everything is printed as garbage, but sending the document directly to printer has no issues. This only happens with Brother printers, for other printers no issue. Also, i tried to check the other options provided in the post, but unfortunately my application is in Delphi 4 so not a lot of 3rd party components available and am not sure if i'll be allowed to buy a 3rd party component. I can directly send the document to the printer but the Adobe pop-up generated doesnt look good. – Vic Oct 08 '12 at 08:00
  • @Vic the Adobe Reader solutions mentioned in my answer will most likely work with Delphi 4 too, but keep in mind that Delphi 4 was one of the most buggy versions of Delphi ever. – Jeroen Wiert Pluimers Oct 08 '12 at 17:22