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

Printing Missing Pages if Preview first...

edited October 2003 in General
Hello,

I have RB 7 with D6 Enterprise - and I am running into a interesting
problem. If I show the print preview form (RB's standard one!) - and
then print from that form - I don't get all the pages of the report.
For example - the report I want has 3 pages. I show the frist one in
the print preview - then choose to print - and the printed report only
shows pages 2 and 3 - not 1.

I use JIT Pipelines to get the data for report - so it is my guess that
the preview and the report are using the same instance (?) of the
pipeline and because it has already gotten the data for the first page -
when I ask it to print - it doesn't reset before printing - thus I only
get pages 2 and 3. The JIT Pipelines I am using do not get their data
from database tables - but on my own internal objects.

If this seems like a reasonable reason why this is happening - then any
suggestions as to how to deal with it? Is there an event where I can
reset things so that the printing starts at the first page instead of
after the last page of preview? NOTE: I am caching the report...


Bradley MacDonald

bradley_AT_telus_DOT_net

Comments

  • edited October 2003

    Try running the JITPipeline demos in the RBuilder\Demos\Reports\Demo.dpr.
    Run the project and then select example number 136. It does not exhibit this
    behavior.

    My guess is that there is an error in your JITPipeline event-handler
    implementation.

    Depending upon whether Report.CachePages is set to True, when you Print
    after previewing page 1, the first page will either be pulled from the
    report's page cache or it will be regenerated.

    Make sure that you are not manipulating the JITPipeline.RecordIndex or
    RecordCount properties after the initial call to report.Print.

    Try looking at the JITPipeline demos. If you would like to create a simple,
    minimal demo (perhaps modify demo 136) and send to
    support@digital-metaphors.com in zip format, we can check it out here.




    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited October 2003
    Nard,

    I agree it is an issue with my event handler implementation. Let me
    explain what I am trying to do... and the ask a few questions...

    The issue is that I am getting the data from a custom tree object. If I
    understand things correctly - I can't really use the RecordCount and
    InitialIndex properties - as I traverse the tree skipping certain nodes
    (depending on certain criteria).

    So

    The CheckEOF event checks to see if I have progressed to the last node
    in the Tree (ie. CurrNode = Nil).

    The OpenDataSet event sets the starting node (depending on which one in
    the tree is selected). ** This is what I need to be able to reset to
    start the report over again at the begining **

    The TraverseBy event calls a routine that gets the next node to print -
    which may or may not skip over certain nodes. So - I don't know how
    many nodes (detail lines) will be in the report ahead of time.

    So - I cannot simply iterate through a simple list - at least as far as
    I can tell.

    Before I call the Print method - I do the following with the Cache...
    ppReport_Report.CachePages := False;
    ppReport_Report.CachePages := True;

    The example 136 - uses a simple list - so it can use a the RecordCount,
    etc.


    My Questions:

    1. Am I using the TraverseBy method correctly? How do you handle the
    situations when you don't know how many records there will be in the
    detail band before you call print? And then it not simply a matter of
    cruising through a list - I need to be able to pick and choose which
    records print...
    2. Is there a way I can reset the CurrNode variable - when it is
    printed?

    Any thoughts would be welcome.



    Bradley MacDonald


    In article <3f82cb94$1@dm500.>, "Nard Moseley \(Digital Metaphors\)"
  • edited October 2003

    1.It would simplify things if you traverse your tree structure ahead of time
    and build an index of the nodes to be printed. You can assign each node a
    unique id.

    2. TraverseBy can be positive or negative.

    3. The picking and choosing which records can be handled by number one
    above.

    This article shows how to construct a simple index:

    ----------------------------------------------------
    Tech Tip: Using a JITPipeilne to Display Sorted Data
    ----------------------------------------------------

    Question
    --------

    I am using JITpipeline and I want to know is there a way
    to sort the data?


    Solution
    --------

    You can implement this functionality by creating an
    index for your data.


    A simple index can be made using a StringList. You can
    iterate through your data and for each row add an entry
    to the stringlist. Each entry will contain the string
    value to sort and the row index.

    myIndex := TStringList.Create;

    for liRow := 0 to RowCount-1 do
    myIndex.AddObject(StringValueToSort, TObject(liRow));



    Once you load the data, then you can sort the StringList:

    myIndex.Sort;


    Now you have an index in which each item in
    the stringlist contains a pointer to the correct row.

    To get the data for the first row:

    liRowIndex := Integer(myIndex.Object[0]);


    --
    Tech Support mailto:support@digital-metaphors.com
    Digital Metaphors http://www.digital-metaphors.com



    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited October 2003
    Hello Nard,

    Thanks for the fast reply.

    I will take a look at the StringList Solution. It looks like it should
    work.

    However, it is a little frustrating (maybe too harsh of a word) that RB
    cannot deal with unstructured data. That it requires me to use the
    RecordCount and RecordIndex to move through the data is an issue with
    me. I would be nice if the Traverse by would allow me to move through
    my data - and if there was an event that would allow me to reset my
    starting point (much like somewhere in your RB code it resets the
    InitialIndex property). That would seem to be a more flexible solution.
    Maybe a suggestion for a patch or the next release.

    Thank you for your time.

    Bradley

    In article <3f84322f$1@dm500.>, "Nard Moseley \(Digital Metaphors\)"
  • edited October 2003

    ReportBuilder can handle it, but you will have to code a more sophisticated
    implementation of the event-handlers. I was trying to keep things simple.

    BTW, if you have many reports that will print from this specific structure
    you should implement a custom datapipeline descendant. That way it can be
    reused over and over.

    All DataPipelines must support:

    1. Bidirectional navigation.

    That means traversal forward and backward. (The parameter to the TraverseBy
    can be positive or negative.)

    2. Bookmarking.

    The GetBookmark and GotoBookmark methods/events enable the report engine to
    jump around in the dataset. This requires some sort of indexing or recordID
    implementation.




    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com

    Best regards,

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