0

I have a customer who wants to print to PDF and Physical printer at the same time. They don't want to print the physical copy from the PDF, why I don't know. I tried saving as a temporary RTF file and calling ShellExecute to print to Adobe but doesn't appear this works.

Does anyone have a way without a 3rd party PDF library to print to PDF from a file?

UPDATE: To clarify a bit the user is working with a dynamic document creator. They see preview text on the screen in a TRichEdit and the current print method is the TRichEdit's print command (RichEdit.Print). The first attempt to a pdf was by saving the contents of this rich edit to a temp.rtf file.

Cœur
  • 37,241
  • 25
  • 195
  • 267
James West
  • 771
  • 1
  • 14
  • 26
  • print WHAT exactly ? do you have some file, some document or what ? how do you print it to physical printers ? what does Delphi has to do with it ? – Arioch 'The Oct 03 '12 at 14:28
  • http://stackoverflow.com/search?q=pdf+printer+%5Bwindows%5D – Arioch 'The Oct 03 '12 at 14:29
  • http://stackoverflow.com/search?q=pdf++%5Bdelphi%5D&submit=search There also are a lot of PDF libraries, exposing TCanvas and saving to PDF whatever you draw on that canvas – Arioch 'The Oct 03 '12 at 14:30

2 Answers2

4

You can use our Open Source SynPdf library to export a RichEdit content into a pdf file.

See this forum post for some sample code.

It won't require any printer to be installed. And it will allow easy print preview, custom footer & header, additional title or text, if needed.

Arnaud Bouchez
  • 42,305
  • 3
  • 71
  • 159
  • I wasn't wanting to use a 3rd party lib but I think this may be the ticket since it creates a great pdf right from the RTF control. – James West Oct 03 '12 at 17:26
1

I have used PDFForge in the past. It installs a virtual printer, and printing into this printer creates a PDF. However, it also has options to also immediately print to a physical printer, hence you will be producing a PDF and physicall copy simultaneously. See documentation here if it help you:

http://www.pdfforge.org/content/print

mikijov
  • 1,552
  • 24
  • 37
  • This may be the way to go but I'm not getting good results calling it from command line. Still digging in – James West Oct 03 '12 at 15:10
  • I never called it from command line. It can easily be configured for automatic operation, so your and any other app can print normally, and a PDF and physical copy are created automatically. Do you have any particular concerns we can help with? – mikijov Oct 03 '12 at 15:16
  • 1
    James, I think the point with PDFCreator is that *you* don't have to write any code at all. Your customer can install that product and use your program's standard print command. The customer will select the PDFCreator printer from the list, and your program will print to it just as it prints to any other selected printer. If the customer also wants a physical printout, then he or she can still select the PDFCreator printer, but also choose its "print" option, at which point PDFCreator will print to the selected physical printer. – Rob Kennedy Oct 03 '12 at 16:13