Setting the printer orientation at runtime
I am building a report that has multiple view options (List, Labels, Envelopes)
I want to change the paper orientation at runtime (RAP) as List is Landscape
and Labels are Portrait.
I added the following code in the BeforePrint or the AfterOpenDatapipes and
it only adjust the orientation on the second print... (If I call PreviewReport
twice)
I see the new param value if I edit the report at runtime but the preview
still build the report with the old value... I suppose that the value is
picked up too late at these events.
if ParamsDBPipeline['FORMAT'] = 0 then
Report.PrinterSetup.Orientation := poLandscape
else if ParamsDBPipeline['FORMAT'] = 1 then
Report.PrinterSetup.Orientation := poPortrait;
Is there a way of doing this at runtime ?
Thanks,
Pascal
I want to change the paper orientation at runtime (RAP) as List is Landscape
and Labels are Portrait.
I added the following code in the BeforePrint or the AfterOpenDatapipes and
it only adjust the orientation on the second print... (If I call PreviewReport
twice)
I see the new param value if I edit the report at runtime but the preview
still build the report with the old value... I suppose that the value is
picked up too late at these events.
if ParamsDBPipeline['FORMAT'] = 0 then
Report.PrinterSetup.Orientation := poLandscape
else if ParamsDBPipeline['FORMAT'] = 1 then
Report.PrinterSetup.Orientation := poPortrait;
Is there a way of doing this at runtime ?
Thanks,
Pascal
This discussion has been closed.
Comments
Setting the Orientation of the report inside the AfterOpenDatapipelines
event is too late to have an effect on the report. You would need to
use the OnInitializeParameters event to do so for the main report.
As a test I tried creating an empty main report with only a detail band.
Inside the detail band I placed a single Section subreport. The
Section subreport will act as your existing report. Then from the
AfterOpenDataPipelines event I toggled the orientation of the subreport
rather than the main report. This seemed to function correctly.
Subreport1.Report.PrinterSetup.Orientation := ...;
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Strange... it didn't work for me... I had to do it in Delphi before running
the report.
I am still on 14.02... I don't know if it will make a difference when I will
update...
Thanks for the tip anyway!
Hello Nico,