Different paper sizes
Hi there,
I'd like to implement dynamic component positioning depending on the paper
size that the user chooses in the print dialog. So the report itself should
stay in A4 format but through the setting in the print dialog it should
somehow pass the new component coordinates to the printer. Furthermore it
should be completely done in RAP.
I tried different events like BeforePrint and OnPrintDialogClose and used
the paper name setting of TppPrinterSetup, but this seems to work only if I
set the paper size manually in the paper setup. If I do not modify the
report and go to preview mode directly, the paper name is seemingly not
updated after choosing a new one in the printer dialog.
So how should I do that?
regards,
Andreas Kr?gersen
I'd like to implement dynamic component positioning depending on the paper
size that the user chooses in the print dialog. So the report itself should
stay in A4 format but through the setting in the print dialog it should
somehow pass the new component coordinates to the printer. Furthermore it
should be completely done in RAP.
I tried different events like BeforePrint and OnPrintDialogClose and used
the paper name setting of TppPrinterSetup, but this seems to work only if I
set the paper size manually in the paper setup. If I do not modify the
report and go to preview mode directly, the paper name is seemingly not
updated after choosing a new one in the printer dialog.
So how should I do that?
regards,
Andreas Kr?gersen
This discussion has been closed.
Comments
paper size needed?
I guess not So how would I do it in RAP?
regards,
Andreas Kr?gersen
which are custom built for the best fit for each paper size. Depending on
which size you want to print, you can load one of these templates into the
report and print it.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
in the CodeBased thread. Then you can measure the extents of the page
definition. Read Report.PrinterSetup.PaperHeight and PaperWidth. Also
subtract the margin values in the printer setup from the width and height to
get the area that is available. You'll have to measure each component and
reposition them individually. This feature is not in RB, although soft
coded anchors is a good idea!
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
print dialog closes, the settings of PrinterSetup are seemingly not updated.
If I select A3 for the printer and click OK, when the report itself is still
A4, PrinterSetup.PaperName is not updated with 'A3'. So the problem is not
how to change component positions but how to know, which paper size the user
selected (And perhaps, where and when to look for it. I used
OnPrintDialogClose)
regards,
Andreas Kr?gersen
the controls in the bands of the report. Here is the code to access the
properties of the print dialog after it is closed. You are right, they are
not reflected on the Report object.
procedure TForm1.ppReport1PrintDialogClose(Sender: TObject);
var
lPrinter: TppPrinter;
lPrintDialog: TppPrintDialog;
begin
lPrintDialog := TppPrintDialog(ppReport1.PrintDialog);
lPrinter := TppPrinter(lPrintDialog.Printer);
if (lPrinter.PrinterSetup.Orientation <>
ppReport1.PrinterSetup.Orientation) then
FixLayout(lPrinter.PrinterSetup.Orientation);
end;
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
object is a private field.
regards
Andreas Kr?gersen
it is enough to access the Printer object out of the report. It's quite
strange: The Printer object in the report reflects all changes immediately
but the PrinterSetup object does only show changes made in the designer.
regards
Andreas Kr?gersen
generation cycle. Section-type subreports can change the printer settings
(even the printer) as the report generates. These settings are not
appropriate for the main report, which usually needs to retain its' original
settings. For this reason, the PrinterSetup property is NOT changed based on
the user selections in the Print dialog.
You can force Report.PrinterSetup to contain the settings as selected by the
user in the Print dialog by setting Report.SavePrinterSetup to True.
However, this save happens AFTER the report has generated - which is why the
code Jim posted is the correct answer in this case...
Cheers,
Tom Ollar
Digital Metaphors Corporation
http://www.digital-metaphors.com
info@digital-metaphors.com