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

Changing PrinterSetup in TppArchiveReader

edited January 2003 in Devices
We have an application where documents are "spooled" into a database
as archive blobs for later print.

The archive seems to "remember" the printer details at time of
creation. If I spool print a landscape report set to a laser printer,
and latertry to unspool to a wide carriage dot matrix, it will still
print landscape (ie down the page).

We are overriding the OnInitializePrinterSetup of the ppArchiveReader
to amend the PrinterSetup object to the current Delphi printer: the changes
appear to be in place
using ShowMessage or debugger, but are not reflected in the printout.
Any ideas as to where I am going wrong?

Example (using delphi PrinterObject, with TppArchiveReader name
ppPrintFromFile):

procedure TfmSpooledReports.ppPrintFromFileInitializePrinterSetup(
Sender: TObject);
var
PrinterPath : String;
Idx : Integer;
X, Y : Integer;
begin
X := 1;
Y := 1;
If Printer.Handle > 0 then
begin
X:= GetDeviceCaps(Printer.Handle, LOGPIXELSX);
Y:= GetDeviceCaps(Printer.Handle, LOGPIXELSY);
end;
inherited;
PrinterPath := Printer.Printers[Printer.PrinterIndex];
// location of printer held on Win98: need to strip it out to match
RB
Idx := Pos( ' on ', PrinterPath );
If ( Idx > 0 ) then
SetLength(PrinterPath, Idx-1 );

with ppPrintFromFile.PrinterSetup do
begin
// Shows '1.Landscape 8.2707996.....' for A4 Landscape
if Orientation = poLandscape then
ShowMessage('1.Landscape '+FloatToStr(PaperHeight))
else
ShowMessage('1.Portrait '+FloatToStr(PaperHeight));

// Find our printer in ReportBuilder list
Idx := PrinterNames.IndexOf(PrinterPath);
if Idx >= 0 then
PrinterName := PrinterNames[Idx];

Copies := NumCopies;
DocumentName := Printer.Title;
Orientation := Printer.Orientation;
PaperHeight := Printer.PageHeight/Y;
PaperWidth := Printer.PageWidth/X;

// Shows '2.Portrait 11' for 11" fanfold
// but prints over 11 inches sideways down page!
if Orientation = poLandscape then
ShowMessage('2.Landscape '+FloatToStr(PaperHeight))
else
ShowMessage('2.Portrait '+FloatToStr(PaperHeight));
end;
end;

Comments

This discussion has been closed.