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

Printing from Preview

edited August 2001 in General
I know this issue has been discussed before, I've read all the posting on
it, although I am none of the wiser as to the solution.

When previewing a report and selecting the Print button from within the
preview, the report either doesn't print, prints just some of the bands or
in one case, just accumulates thousands of blank pages when the report is
only one page.

Previous suggestions have been setting CachedPages to True and PassSetting
to psTwoPass; neither of these worked. We have found that if you don't load
from a template, it prints OK, but this isn't an option because we allow the
users to change the report file being loaded. We also found that if there is
no OnBeforePrint event for the Report, it prints OK after a preview.

For the record, we're using D5, RB Ent 5.56

Thanks,

Jason Sweby,
Carval Computing Ltd,
Plymouth, UK.

Comments

  • edited August 2001
    Further to this, I can now state that loading from a template has nothing to
    do with it; whether or not the report is loaded from a template or not, the
    error occurs, so we can eliminate that from our enquiries.

    Jason.
  • edited August 2001
    Do you have variables for the report in your form unit which are used in the
    event handlers? Be sure to reinitalize all of the variables in the
    Report.BeforePrint event. When the report previews, all of the pages are
    generated. When the report is told to print from the preview, all of the
    pages are regenerated.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited October 2001
    OK, you say "Be sure to reinitalize all of the variables in the
    Report.BeforePrint event" because "When the report previews, all of the
    pages are generated. When the report is told to print from the preview, all
    of the pages are regenerated".

    Attached is the ASCII of a tiny RTM file which emulates what one of my
    reports does. There is a global integer variable, MyVar, which is
    initialised to zero both in the OnBeforePrint and the OnStartPass events of
    the report (through RAP, although the same occurs when using the Delphi
    TppReport events).

    On the DetailBand is a ppVariable (Integer) which has its value set to 1 in
    its OnCalc event. Also, MyVar has its value increased to the new value of
    the ppVariable.

    On the Summary band is another ppVariable, Integer, whose OnCalc event
    simply states: Value := MyVar;

    If the report is previewed, both Variables come out as 1. If the report is
    printed directly, both Variables come out as 1. If the report is previewed
    then printed from within the preview, Variable1 comes out as 1 but Variable2
    comes out as 2. Why is this, bearing in mind the quote from the top?

    beforeprintdemo.rtm:

    object ppReport1: TppReport
    PrinterSetup.BinName = 'Default'
    PrinterSetup.DocumentName = 'Report'
    PrinterSetup.PaperName = 'Letter 8 ? x 11 in'
    PrinterSetup.PrinterName = 'Default'
    PrinterSetup.mmMarginBottom = 6350
    PrinterSetup.mmMarginLeft = 6350
    PrinterSetup.mmMarginRight = 6350
    PrinterSetup.mmMarginTop = 6350
    PrinterSetup.mmPaperHeight = 279401
    PrinterSetup.mmPaperWidth = 215900
    PrinterSetup.PaperSize = 1
    Template.FileName = 'c:\temp\beforeprintdemo.rtm'
    Template.Format = ftASCII
    DeviceType = 'Screen'
    Left = 160
    Top = 32
    Version = '6.02'
    mmColumnWidth = 0
    object ppDetailBand1: TppDetailBand
    mmBottomOffset = 0
    mmHeight = 13229
    mmPrintPosition = 0
    object ppVariable1: TppVariable
    UserName = 'Variable1'
    CalcOrder = 0
    DataType = dtInteger
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Name = 'Arial'
    Font.Size = 10
    Font.Style = []
    Transparent = True
    mmHeight = 3969
    mmLeft = 5292
    mmTop = 1852
    mmWidth = 14817
    BandType = 4
    end
    end
    object ppSummaryBand1: TppSummaryBand
    mmBottomOffset = 0
    mmHeight = 13229
    mmPrintPosition = 0
    object ppVariable2: TppVariable
    UserName = 'Variable2'
    CalcOrder = 0
    DataType = dtInteger
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Name = 'Arial'
    Font.Size = 10
    Font.Style = []
    Transparent = True
    mmHeight = 3969
    mmLeft = 3440
    mmTop = 2910
    mmWidth = 14817
    BandType = 7
    end
    end
    object raCodeModule1: TraCodeModule
    ProgramStream = {
    01060D54726156617250726F6772616D094368696C645479706502110B50726F
    6772616D4E616D6506095661726961626C65730B50726F6772616D5479706507
    0B747450726F63656475726506536F75726365063E70726F6365647572652056
    61726961626C65733B0D0A7661720D0A2020204D795661723A20496E74656765
    723B0D0A626567696E0D0A0D0A656E643B0D0A0001060F5472614576656E7448
    616E646C65720B50726F6772616D4E616D65060F5661726961626C65314F6E43
    616C630B50726F6772616D54797065070B747450726F63656475726506536F75
    726365066970726F636564757265205661726961626C65314F6E43616C632876
    61722056616C75653A2056617269616E74293B0D0A626567696E0D0A0956616C
    7565203A3D20313B0D0A2020094D79566172203A3D204D79566172202B205661
    6C75653B20200D0A656E643B0D0A0D436F6D706F6E656E744E616D6506095661
    726961626C6531094576656E744E616D6506064F6E43616C63074576656E7449
    4402210001060F5472614576656E7448616E646C65720B50726F6772616D4E61
    6D6506115265706F72744265666F72655072696E740B50726F6772616D547970
    65070B747450726F63656475726506536F75726365063D70726F636564757265
    205265706F72744265666F72655072696E743B0D0A626567696E0D0A20202020
    204D79566172203A3D20303B0D0A656E643B0D0A0D436F6D706F6E656E744E61
    6D6506065265706F7274094576656E744E616D65060B4265666F72655072696E
    74074576656E74494402010001060F5472614576656E7448616E646C65720B50
    726F6772616D4E616D65060F5661726961626C65324F6E43616C630B50726F67
    72616D54797065070B747450726F63656475726506536F75726365065470726F
    636564757265205661726961626C65324F6E43616C63287661722056616C7565
    3A2056617269616E74293B0D0A626567696E0D0A0D0A202056616C7565203A3D
    204D795661723B0D0A0D0A656E643B0D0A0D436F6D706F6E656E744E616D6506
    095661726961626C6532094576656E744E616D6506064F6E43616C6307457665
    6E74494402210001060F5472614576656E7448616E646C65720B50726F677261
    6D4E616D6506165265706F72744F6E53746172744669727374506173730B5072
    6F6772616D54797065070B747450726F63656475726506536F75726365064270
    726F636564757265205265706F72744F6E53746172744669727374506173733B
    0D0A626567696E0D0A20202020204D79566172203A3D20303B0D0A656E643B0D
    0A0D436F6D706F6E656E744E616D6506065265706F7274094576656E744E616D
    6506104F6E5374617274466972737450617373074576656E74494402140000}
    end
    end

    Many thanks,

    Jason Sweby
    Carval Computing Limited,
    Plymouth, UK.
  • edited October 2001
    Ok, in RAP, it looks like the Report.BeforePrint doesn't fire again when you
    print from the previewer. The workaround to this is to use a TppVariable in
    the report. Set it to Visible= False and set its timing to reset on
    ReportEnd. Call this variable MyVar and replace your MyVar references with
    MyVar.Value and it should work, as I tried it with your sample report and it
    worked.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.