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

Different paper sizes

edited August 2002 in General
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

Comments

  • edited August 2002
    Well, are YOU going to copy about 100 different reports for us for every
    paper size needed?
    I guess not ;) So how would I do it in RAP?

    regards,

    Andreas Kr?gersen


  • edited August 2002
    It is going to be much easier to simply create different report templates
    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

  • edited August 2002
    You'll have to use a report object loop as given in the TechTips newsgroup
    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

  • edited August 2002
    I have already tried that with PrinterSetup. But the problem is, when the
    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

  • edited August 2002
    In the FixLayout procedure called in the following code, you can reposition
    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

  • edited August 2002
    TppPrintDialog does not have a public property named Printer. The printer
    object is a private field.

    regards

    Andreas Kr?gersen


  • edited August 2002
    I've now found a simple solution: You don't need to access the PrintDialog,
    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


  • edited August 2002
    The Printer object reflects the settings as needed by the ongoing report
    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
This discussion has been closed.