Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fill Full page till footer space in detail in FRX Report in VFP

Sng1

Programmer
Aug 3, 2021
65
0
6
IN
I have a report of sales invoice in which I want to fill the page with blank spaces in the last page of invoice if data finishes in half page. Below is the sample that is required.
In image JB2 after data is completed blank space is inserted to cover full page
 

Attachments

  • JB1.jpg
    JB1.jpg
    158.2 KB · Views: 20
  • Jb2.jpg
    Jb2.jpg
    120.1 KB · Views: 18
No, If Item Name doesn't fit in 1 line, it stretches to next line. Also There is variable length band below if user enters any remark or declaration
 
Last edited:
can yo determine that in advance?
i.e. accurately count the number of lines
or insert extra details with the second line on them?
 
I can run report in advance to know the space available in pixel or inches by pre running report with no output. But how to insert blank space to say 2 inches at second pass
 
Griffs idea is based on the number of lines you can print in the middle section being precisely 18 lines. If you know exactly how many items cause a line break you can still determine the number of empty records you need to shift the totals down.

To me it seems simple to define the totals into the page footer and let that start where the totals begin. The totals then also shouldn't be in data, they are report variables summing to the totals that you then print in the page footer.
 
But I can't predetermine how much space will summary band take because it again depends on the Data. If User has entered remark , declaration then summary band will increase. also I am displaying HSN summary at the bottom of report which is summary of data and variable length. I can do it at runtime. But then how to expand detail band to that many pixels
 

Attachments

  • Capture.PNG
    Capture.PNG
    18.7 KB · Views: 2
Hi,

You may want to move the subtotals and the totals to the page footer and make it flexible with "Print only when expression is true" and "Remove line if blank". Demo attached

hth

MarK
 

Attachments

  • Sing.zip
    3.9 KB · Views: 1
Can't you just create a bunch of controls in the detail section of the report and add a condition when to print, like PrintWhen lineCnt = 1, 2 ,3 and so on. Or Invoice Detail line, whatever. We have quite a few similar reports to print Utility bills, Invoices etc. Each Invoice have a header and detail and detail has a line number of how many invoice details exists in a view thaty drives the report. Say I have an invoice with 5 detail lines but the report detail section has 20 possible lines, Report control 6 has a condition PrintWhen lineNo = 6. Since there is no line 6, it will not print anything, just blank space. I am not at work right now but I can double check the logic tomorrow
 
Thanks igorsandler,
I think this logic could be workaround but if Item name doesn't fit it's stretch with overflow is arked so it goes to next row. So if 4 items overflow then from 10 items which I can print , I practically get space of 6 items. So I am trying to instantiate reportlistner object and in the method - adjustobjectsize , I am trying to do something like below . Will come will proper solution if it succeeds

Define Class Invoice_Listener As ReportListener
PROCEDURE INIT
LPARAMETERS r_frxfile
THIS.AddProperty("nPageFooterPos",170) &&& 170 comes from 0.177(height of page footer band) * 960
*-----------------------------
&& ADDING THE COMMENTS OF THE USER TO THE REPORT OBJECT
&& called for the refrence in the
closefiles( 'frxfile0')
LOCAL al
al = ALIAS()
SELECT 0
USE &r_frxfile ALIAS frxfile0 AGAIN
LOCAL cc
cc= "This.Addproperty('USERVALEUS(" + ALLTRIM(STR( RECCOUNT())) +",3)','')"
&cc
*-----------------------------
SELECT frxfile0
SCAN
This.UserValeus( RECNO(),1) = RECNO()
This.UserValeus( RECNO(),2) = UPPER(ALLTRIM(frxfile0.user))
This.UserValeus( RECNO(),3) = ALLTRIM(frxfile0.expr)
&& storing the values of the user field in the property UserValeus of the report object
ENDSCAN
*------------------------------
IF !EMPTY(al)
SELECT &al
ENDIF
ENDPROC

Procedure AdjustObjectSize
Lparameters tnFRXRecno, toObjProperties, toFRX
*-- If it won't fit, increase the height of
*-- the shape to fill up the rest of the page
NOTE In Frx in "User" Comment field - 'ITEM : PRINT_CUR'
If 'ITEM' $ Capt(This.UserValeus( tnFRXRecno,2))
CURNAMEV = Alltrim(GETWORDNUM(This.UserValeus( tnFRXRecno,2),2,':'))
If !Empty(CURNAMEV)
**- Note 1) 210 is calculated as 0.0229 * 960
*- 2) By putting Messageboxes and noting diif. for 2 consecutive lines
*!* messagebox( toObjProperties.Top )
*!* messagebox( toObjProperties.maxheightavailable ) &&-> Max Height Available
*!* messagebox( &CURNAMEV..MX * 220 )
*!* IF BETWEEN(RECNO('&CURNAMEV'),56,59)
*!* messagebox( toObjProperties.Top )
*!* messagebox( &CURNAMEV..MX * 210 )
*!* messagebox( toObjProperties.maxheightavailable )
*!*
*!* ENDIF
NOTE : 210 IS THE HEIGHT OF DETAIIL BAND

If (&CURNAMEV..MX-&CURNAMEV..MARK+1) * 210 > toObjProperties.maxheightavailable
&& Go To The Next page , so increasing height of the object
toObjProperties.Height = toObjProperties.maxheightavailable
* messagebox( toObjProperties.Height )
* REPLACE PRT WITH .T. IN &CURNAMEV
toObjProperties.Reload = .T.
* BROWSE
ENDIF
* BROWSE
Endif
Endif
DoDefault()
Endproc
Enddefine
 
I wonder if it can be done simpler. The core problem to solve is the number of lines needed for the items, knowing which one - if any - cause line breaks.

You have text wisdth measuring functions with TXTWIDTH(). Knowing the printer dpi would enable you to know in advance which item texts will cause a line break.

It may be simpler with your idea of a reportlistener, but both ways are indeed harder than figuring out a general fixed hieght or offset.

Do you also print the lines, or are they preprinted on the sheets and your report only adds the text?
 
The core problem to solve is the number of lines needed for the items, knowing which one - if any - cause line breaks.
No that I have figured out at which line page break is occurring. Only problem is the last page where I have to extend first detail band along with lines so that summary band - terms and conditions etc.vcomes at the end of the page
 
Well, as Griff and I already suggested that's adding empty records to the data. It'll always be N records per page, so you can know that, N just needs to be reduced by the number of double line items, as you know that count you also know how many records are necessary to fill up the pages, especially the last page.

Also, I assume - or you'd need to change that, data in the rpoert driving cursor is not holding the totals data, neither the total sum you can compute during the report run, nor such things as the terms and conditions text. You'd provide such things as variables, if they need to change. So report drivng data is only header data, perhaps that would also reside in variables or in the first few records, then the rest of the report driving cursor only is items.

And ideally all of the main report driving cursor is just items. All captions, titles/ header notes, etc. belong into something separate, either they are constant (labels) on the report, or they are data in variables. Don't overload the report driving cursor to contain all data of the report. That just leads to the need of awkward grouping or additional bands only to separate out the "gold" from the rest of the records.
 
Last edited:
Yes Chris , you are right. Will try it and reply as it is the easiest solution
 
If you determine the number of double line items by report listener, you could still add records at the end of the preview phase, as there is always the ability to detmerine whether you're in a preview pass or the actual ouput pass of a report by using the reportlistener TwoPassProcess property and then detmermine the pass by the CurrentPass property, or using the old _PAGETOTAL trick or SYS(2040).
 
OK, I am not sure adding some blank records to the dataset that drives the report will work as, if I understand correctly, there could be unlimited(theoretically) number of lines per invoice.
If you have an item description on the invoice too long for the report control, that control could be set with stretch with overflow and it's just expends the textbox on the report, pushing other boxes down, that's all. Obviously needs to be tested
 
Well, nmo matter what, the maxximum number of blank lines you could add is the number that would fill a whole page, so say 14 records. Then the rpeort listener will be guaranteed to end on a page that's surplus and can be removed. Reportlistner rendering events will give you the last record that printed on the page before that and that could be used to reduce the data.

All that can be done during multi pass reporting. The worst thing that could happen is a preview rendering that surplus page which wouldn't get printed.

And if that disturbs you, you could make the first phase of reporting just determining the necessary record number and then restart the whole report, i.e. make the first run a run without preview AND without printing, actually, a listener that has a dummy file output you later delete. In the second report (not just the second pass, the second complete report run) you could signal the records have been determined and the preview and ouput phase can run normally.
 

Part and Inventory Search

Sponsor

Back
Top