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

combine two reports at runtime

edited August 2002 in General
Hello,
We have integrated our application with RightFax and are able to fax
ReportBuilder reports from our application. The next step i would like to
take is to provide the ability to allow a user to fax two reports as a
single fax instead of having to fax each report by itself. Is there a way to
have two reports be sent as the same job to the printer? or combine two
reports and have the combination sent to the printer? Id rather not have to
build a new report that is a combination of the two because there are times
when they just want the one report by itself. I hope this makes sense and
thanks for your help

matt

Comments

  • edited August 2002
    You have a couple of options here. The simpler one is to dynamically create
    another report, put two subreports inside it, and load the two reports into
    these subreports. The other one is to actually take control of the printing
    process. You would print both reports to cache, combine all the pages into a
    single list, programatically create the device you use for printing/faxing
    and manually submit it the list of pages.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited August 2002
    The first suggestion sounds like a great solution. is this the basic
    concept?
    var
    tempReport : TppReport;
    subReport1 : TppSubReport;
    subReport2 : TppSubReport;
    myReport1 : TppReport;
    myReport2 : TppReport;
    begin

    myReport1 := report1; //first report i want to include
    myReport2 := report2; //second report i want to include

    tempReport := TppReport.Create(nil);
    subReport1 := TppSubReport.Create(nil);
    subReport2 := TppSubReport.Create(nil);

    subReport1.createreport(myReport1);
    subReport2.createreport(myReport2);

    tempReport.AddChild(subReport1);
    tempReport.AddChild(subReport2);

    tempReport.print;
    end;

    im getting errors on the 'CreateReport' method. how do you assign a report
    to a subreport?

    thanks for your help



    "Alexander Kramnik (Digital Metaphors)" wrote
  • edited August 2002
    never mind - here is the solution i ended up with - may not be pretty but
    its working:


    var
    itinReport : TppReport;
    tenCommandReport : TppReport;

    lDevice : TppDevice;
    lPrinterDevice : TppPrinterDevice;
    index : integer;
    begin

    lPrinterDevice := TppPrinterDevice.Create(nil);
    lPrinterDevice.Printer.PrinterName := FAX_PRINTER;
    //do itinerary
    itinReport := printCarrierItinerary(DEVTYP_RETURNFORFAX);

    lDevice := TppDevice.Create(nil);
    lDevice.Publisher := itinReport.Publisher;

    itinReport.CachePages := true;
    itinReport.ShowPrintDialog := false;
    itinReport.PrintToDevices;

    lDevice.Free;
    lPrinterDevice.StartJob;
    for index := 0 to itinReport.Publisher.PageCount-1 do
    lPrinterDevice.ReceivePage(itinReport.Publisher.pages[index]);

    //do ten comandments
    tenCommandReport := printTenCommandments(DEVTYP_RETURNFORFAX);

    lDevice := TppDevice.Create(nil);
    lDevice.Publisher := tenCommandReport.Publisher;
    tenCommandReport.ShowPrintDialog := false;

    tenCommandReport.CachePages := true;
    tenCommandReport.PrintToDevices;

    lDevice.Free;

    for index := 0 to tenCommandReport.Publisher.PageCount-1 do
    lPrinterDevice.ReceivePage(tenCommandReport.Publisher.pages[index]);

    lPrinterDevice.EndJob;
    lPrinterDevice.Free;


    "Alexander Kramnik (Digital Metaphors)" wrote
This discussion has been closed.