
| Subject: | Implement a PrintToFile capability |
| Posted by: | David Tetard (…@Spam.com) |
| Date: | Fri, 15 Aug 2008 |
Hi,
I'm looking at a way to implement a Print-To-File capability for my
application. Here are my wonderings:
- The TPrintDialog has the poPrintToFile option allowing to show the Print
To File check box. That's good for the user to be able to choose to do so
(good start).
- The TPrinter object does no support printing to files. DocInfo contains a
lpszOutput param but in the TPrinter.BeginDoc, it is always set to Nil. I'm
wondering if it would actually be very simple to implement a Print-To-File
function by simply having the DocInfo.lpszOutput be initialised for the call
to Windows's StartDoc and let the printer driver do the rest. Am I correct
here? I suggested to QC to add a TPrinter.OutputFilename property for that,
I hope I'm not wrong here.
- Also, I found that you can have a printer port set to "File:" so that the
printer prints to a file. When I tried that, it seemed to me that the
printer drivers was asking for a filename (the one I had was an ugly little
dialog with a simple Edit and OK, Cancel buttons, quite unappealing!!!) then
created successfully the file print-out (as postscript file, which I'm
after). My questions regarding this one: for the Print-To-File to work (as
described in my second point above), do I have to also have the printer port
set to "File:" or is this behaviour emulated with DocInfo.lpszOutput set to
a valid filename (what I mean is: if StartDoc has a DocInfo.lpszOutput
specified to a filename, would the print-out be redirected to the file even
if the printer port is set to "LPT1:" rather than "File:")? I'd guess that
both methods (set port to "File:" or have DocInfo.lpszOutput) are
independent ways of doing the same thing but I'm not sure. And in this case,
it means the VCL stops us from using the second because TPrinter does not
support the DocInfo.lpszOutput param.
Thanks for any clarifications.
David.