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

Runtime margins

edited July 2008 in General
Hi,

I use a pagestyle (set to print for page 1 only) to print an
address-label on my report. The position of the label is set runtime
(user-settings).
The position is relative to the left/top (0,0) of the report. Because
reports (I use this method for multiple reports) always have some
margin-settings I temporarily change the margins (I'm setting the
Report.Engine.Page.PrinterSetup.Margin... property's) to 0 in the
BeforePrint-event of the pagestyle. The original margins are then
restored in the AfterPrint-event.
This method seems to work fine for the Top and Bottom-margin but have no
effect on the Left- and Right-margin.

What am I doing wrong?

For the record, I'm using RB-Enterprise 10.09 on Delphi2007-Pro.

Any suggestions,

TIA,

Ronald

Comments

  • edited July 2008
    You migh try setting the margins prior to generating the report.


    myReport.PrinterSetup.MarginLeft := 0.0;
    //etc...

    myReport.Print;



    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited July 2008
    I only want to change the margins when the pagestyle is printed! It works
    for Top and Bottom but not for Left and Right. Why is that?
    Maybe I should catch all drawcommands for the pagestyle and change them.

  • edited July 2008

    1. If you need to print the first page as an adress label, you might want to
    create a main report with no header/footer and place two subreports in the
    detail band, set to pbSection. Section style subreports can have their own
    PrinterSetup. So the first section could be the address label and the second
    section the report.

    main
    section1 - address label
    section2 - report

    To use the same address label layout with many different reports you can
    save/load the layout to an .rtm. (Subreport.Report can have its own .rtm
    layout).


    2. To use your existing design and print the first page to a different
    margin setting try the following code in the Report.OnStartPage event.

    procedure TForm1.ppReport1StartPage(Sender: TObject);
    begin
    if ppReport1.AbsolutePageNo = 1 then
    ppReport1.Engine.Page.PrinterSetup.MarginLeft := 0.0
    else
    ppReport1.Engine.Page.PrinterSetup.MarginLeft := 0.25;
    end;


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.