Change duplex mode on the fly
I have an old application (written in D7, RB7.04) for which I've been
asked to add code to change the duplex setting 'between pages'.
That is, in a multi-page (30+ pages) report, I need to change between
dpVertical and dpNone.
The report prints manufacturing work orders (always a single page) -
and most of the time a drawing is attached (printed within a subreport
in a second detail band).
If the data looks like:
wo1 dwg1
wo2 dwg2
wo3 nil
wo4 dwg4
I need to see:
page 1 dpVertical (wo1 main)
page 2 dpVertical (dwg1 subreport)
page 3 dpVertical (wo2 main)
page 4 dpVertical (dwg2 subreport)
page 5 dpNone (wo3 main)
page 6 dpVertical (wo4 main)
page 7 dpVertical (dwg4 subreport)
etc
I wrote this thing in 2005 - and it's rather complicated...
So, can you please:
1) suggest which events I should be investigating to test changing
duplex mode 'on the fly'; and,
2) let me know if there's anything in more recent RB that would
facilitate this - *without* breaking my really old, really complicated,
report**
Thanks!
** for example, I added registration code for a couple of custom
graphic types. Would something like the following 'break'? -
//---EJB---2005.08.29-----------------------------
procedure TfrmRepPSIView.ppReport1PageRequest(Sender,
aPageRequest: TObject);
begin
if Assigned(ppReport1.PrintDialog) then begin
FPgSetting:= TppPageRequest( aPageRequest ).PageSetting;
FPgRange:= TppPageRequest( aPageRequest ).PageRange;
end;
end;
--
EdB
This discussion has been closed.
Comments
Try altering the Duplex property inside the OnStartPage of the report.
procedure TForm1.ppReport1StartPage(Sender: TObject);
begin
if ppReport1.AbsolutePageNo = 5 then
ppReport1.Engine.Page.PrinterSetup.Duplex := dpNone;
end;
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Actually, that's the first thing I tried...
procedure TForm1.ppReport1StartPage(Sender: TObject);
begin
mmo1.Lines.Add(Format('start page:%d',[ppReport1.AbsolutePageNo]));
if (ppReport1.AbsolutePageNo=5) then begin
mmo1.Lines.Add(Format('found page :%d',[ppReport1.AbsolutePageNo]));
if (ppReport1.PrinterSetup.Duplex<>dpNone) then begin
ppReport1.PrinterSetup.Duplex:=dpNone;
end;
end
else
begin
if (ppReport1.PrinterSetup.Duplex<>dpHorizontal) then begin
ppReport1.PrinterSetup.Duplex:=dpHorizontal;
end;
end;
end;
If I print the report with starting with .Duplex=dpHorizontal,
everything is 'duplexed'. If I start with .Duplex=dpNone, then
everything is 'non-duplex'. That is, nothing changes.
I'll test it on a different machine/printer combination just in case
it's the drivers - but can you suggest anything else?
Thanks!
(BTW - I just checked, looks like the last time I posted here was in
2006!).
EdB
Rather than accessing the Report.PrinterSetup, try accessing the
Report.Engine.Page.PrinterSetup.
This may however be a printer specific behavior. ReportBuilder handles
duplexing similar to the other printer setup options (orientation, bin
name, etc.) which can generally be changed mid-report by accessing the
Page.PrinterSetup property. Each time a new page is generated,
ReportBuilder attempts to update the printer device mode with that
page's PrinterSetup options. This includes duplex. If for some reason
the printer treats duplex as a job-wide setting, it may simply ignore
that setting.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Huh, didn't even notice the difference (Engine.Page) in our code.
Unfortunately, it didn't make a difference with the printer I'm using
for testing.
I threw labels in header and footer, and did OnGetText to show Duplex
mode - the page reports that it is dpNone where it should be, but the
printer just keeps doing double-sided.
I'll try on a different printer - thanks for you input.
EdB
Tried it on the production printer (instead of cheap test printer) - it
works the way it should.
Many thanks!
EdB