Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Retaining Printer Properties set by user

edited October 2009 in General
Hi

By mistake I have just attached the question below to an old thread, rather
than creating this new thread. Sorry for the duplication.


In order to retain the printer settings when printing a batch of invoices
which use different templates, we have implemented the following code...

for j := 0 to number of invoices-1 do
begin
setup invoice, required template etc...
Template.LoadFromFile;
save pdf etc....

if j > 0 then //2nd invoice load printer settings from stream
begin
ppViewer1.Report.ShowPrintDialog := FALSE;
printerStream.Position := 0;
PrinterSetup.LoadDeviceSettingsFromStream(printerStream);
end;

print invoice etc.

if j > 0 then ppViewer1.Report.ShowPrintDialog := FALSE else
ppViewer1.Report.ShowPrintDialog
:= TRUE;
ppviewer1.Print;

//1st Invoice save printer settings to stream
if j = 0 then PrinterSetup.SaveDeviceSettingsToStream
(printerStream);

next invoice
end;


This works well if the printer used in the Print Dialog is the default
printer. If however the user changes the printer in the Print Dialog, the
1st document prints OK but subsequent documents fail with the error

"Windows cannot print due to a problem with the current printer setup. The
specified resource type cannot be found in the image file"

Advice greatfully received.

Philip L Jackson
This discussion has been closed.