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

Printing to printer instead of file or archive

edited June 2003 in Subreports
I have a main report with 10 different sub reports which I load dynamically
at run time. Because some are portait while others are landscape, I have
them as section style with NewPrintJob set to true.

Whenever I print to a file, be it an archive or using the TextraDevices, I
get the file ouput but the report also goes to the printer. What am I doing
wrong? I have my allowprinttofile and allowprinttoarchive set to true. Also
if there is a better way to do this, please let me know. My code is below.

procedure TMainForm.previewButtonClick(Sender: TObject);
begin
buildReports('Screen');
end;

procedure TMainForm.printButtonClick(Sender: TObject);
begin
buildReports('Printer');
end;

procedure TMainForm.buildReports(mode : String);
var
r : cRpt;
i : integer;

begin
... checking for valid selections

if MyReportList.count > 1 then begin
mainReport.Template.FileName := curDrive +
'\ctrus\reports\projmgr\db\emptyReport.rtm';
mainReport.template.LoadFromFile;
disableSubReports; //turns all subreports invisible initially

for i := 0 to MyReportList.Items.Count-1 do begin
r := rptList.getInfo(myReportList.items.strings[i]);
if r = nil then continue;
if not FileExists(r.rptPath) then continue;

case i of
0: begin rpt1.template.filename := r.rptPath;
rpt1.template.loadFromFile; Report1.visible := True;end;
1: begin rpt2.template.filename := r.rptPath;
rpt2.template.loadFromFile; Report2.visible := True;end;
2: begin rpt3.template.filename := r.rptPath;
rpt3.template.loadFromFile; Report3.visible := True;end;
3: begin rpt4.template.filename := r.rptPath;
rpt4.template.loadFromFile; Report4.visible := True;end;
4: begin rpt5.template.filename := r.rptPath;
rpt5.template.loadFromFile; Report5.visible := True;end;
5: begin rpt6.template.filename := r.rptPath;
rpt6.template.loadFromFile; Report6.visible := True;end;
6: begin rpt7.template.filename := r.rptPath;
rpt7.template.loadFromFile; Report7.visible := True;end;
7: begin rpt8.template.filename := r.rptPath;
rpt8.template.loadFromFile; Report8.visible := True;end;
8: begin rpt9.template.filename := r.rptPath;
rpt9.template.loadFromFile; Report9.visible := True;end;
9: begin rpt10.template.filename := r.rptPath;
rpt10.template.loadFromFile; Report10.visible := True;end;
end;

end; //end of report loop

mainReport.AllowPrintToFile := True;
//show the report
mainReport.DeviceType := mode;
mainReport.PrintReport;
end;

end;



Thanks in advance,

Karen

Comments

  • edited June 2003
    If you want to print and have the report automatically create the device
    based on the Report.DeviceType, then call Report.Print. If you want to print
    the report to a specfic device that you create, then you have to call
    Report.PrintToDevices after you assign the Report.Publisher to the device
    object you instantiate.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited June 2003
    Jim,

    It didn't used to be that complicated. If you clicked, print to file, and
    using Walers ExtraDev, selected PDF - the file only was output to pdf
    format. Now it not only goes to PDF, but to the printer as well. I was
    wondering if it was because of some way I had setup my subreports.

    Karen

  • edited June 2003
    It shouldn't be that complicated. All you should have to do is select
    PDFFile for the report's device type in the OI, or use the print dialog, and
    then when the print dialog closes it should print to file, not also print to
    the printer. It shouln't print to two devices as a result of a call to
    Report.Print. If it is doing this, then send us an example that shows this
    problem (support@digital-metaphors.com). Otherwise, to see what the problem
    is with the device creation, then change your library path to point to
    RBuilder/Source and place a breakpoint in ppProd.pas in the PrintToPrinter
    routine to see which device it is trying to create.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited June 2003
    I was able to duplicate this using a small sample program. I sent it to
    address you specified. Please let me know what I am doing wrong or if it is
    a bug. I had to recompile the Walers ExtraDevices with the change you made
    to 7.02, but the problem also occurs with the Report Builders Archive
    function.

    Thanks,

    Karen

  • edited June 2003
    One of your subreports is set to StartNewPrintJob = True. This will cause
    the subreport to create a new printer device and it will print to the
    printer, even though the main report is printing to another device, such as
    a file device. Toggle this property to keep the subreports from printing to
    the printer.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited June 2003
    I listed this in my initial post to you asking if it was the problem.

    My problem is that I have a combination of landscape and portrait reports
    and any combination can be selected by the user. Don't you have a way to
    use the same device, but allow the page orientation to change?

    Thanks,

    Karen

This discussion has been closed.