Printing - Page number paradox

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Printing - Page number paradox

Post by Rathinagiri »

Hi,

I have a (basic) doubt in printing.

I want to print in every page of my report as 'Page No. 1/15, Page No. 2/15.....' like that.

The total number of pages can be found only after the last 'end printpage' command is given. So, how can I insert this last number of pages in the first page.

There are two possible ways.

1. First time do everything as we print and at the last instead of 'end printdoc' we can give 'abort printdoc' and find out the last page count. Then as usual print.
2. Insert the page number into every page before end printdoc.

IMHO, first method is possible but logically not right as it will consume double the processing time. For a big report running into pages, it may take much time.

Second method is logically right but is it possible? (to access a page on which already End PrintPage is given.

Or is there any other way?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Printing - Page number paradox

Post by mol »

I had the same idea, but no idea hot to realize that :-)
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Printing - Page number paradox

Post by Pablo César »

This is a big issue but it would wonderful to count with this resource.

I remember when I made EMF Viewer, all graphical printing creates metafiles for each page. Probably there is a way to re-edit it replacing lets say a kind of [TAG] by each number of page in string type. Just an idea...

If you want to look up it, see this topic:
viewtopic.php?p=37162#p37162
Last edited by Pablo César on Fri Oct 21, 2016 11:16 am, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Printing - Page number paradox

Post by serge_girard »

Rathi,

May be it is possible to count the records per page and divide by reccount() + headers + footers + ..?

Serge
There's nothing you can do that can't be done...
User avatar
Anand
Posts: 595
Joined: Tue May 24, 2016 4:36 pm
DBs Used: DBF

Re: Printing - Page number paradox

Post by Anand »

Curious, I did some research.

I use FastReport for Xbase++. It has option to print total number of pages in report as in below image,
2016-10-20_221454.png
2016-10-20_221454.png (8.06 KiB) Viewed 7406 times
I observed that the in preview the total page numbers value change after the all pages of the report is generated. See that there is a "cancel" button on top which changes to "Close" upon completion of report. See also that the total page number value changes after "Close" is shown, as in below gif, (Also note that the position of the "page" text is shifted left)
aa.gif
aa.gif (23.6 KiB) Viewed 7406 times
If you save the report, it saves in XML format, see below image,
2016-10-20_223336.png
2016-10-20_223336.png (15.87 KiB) Viewed 7406 times
So I conclude that FastReport is generating XML file in memory and then doing search and replace in the XML at the end.

Further when I was doing coding in FoxPro (DOS), I used to run the report twice to get the total page numbers. First time I set printer to temp file, SET PRINTER TO TEMPX.TXT and get the total pages value in a variable.
Next time I set SET PRINTER TO PRINT and use the variable. I also found that SET PRINTER TO NUL performed same purpose, albeit very fast.

I do not know if we can implement the above in HMG, but may help other members to get an idea.

Regards,

Anand
Regards,

Anand

Image
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

mol

Post by mol »

serge_girard wrote:Rathi,

May be it is possible to count the records per page and divide by reccount() + headers + footers + ..?

Serge
I'm creating reports with row heights depending from values, so record counting is unusable...
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Printing - Page number paradox

Post by Rathinagiri »

Yes. I am also using wordwrap for long text. So record counting is unusable.

Running two times the print process is a raw solution IMHO. That may be used as a last resort!

Pablo's idea of changing the EMF/WMF file and replacing before start printing seems logical. But, can it be possible?

In HMG_PDF we can just select any page and insert anything even after creating all pages.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Printing - Page number paradox

Post by Pablo César »

Rathinagiri wrote:changing the EMF/WMF file and replacing before start printing seems logical. But, can it be possible?
I think it is possible because inside metafiles can be search a string opening, read and also be replaced, all in low level (I guess).
Each EMF file created by Print preview option has at end of name, the number of page and could it be search the string (lets say) for "Page No. 1/@@" and replace only "@@" by the total quantity of that EMF files. Of course in our report we need to let the string in each page as a footer or as header.

What I see strings is each character spreaded (separated) with Chr(0) which also can be arranged.

I am now without my pc (is in the technician, probably it´s stressed too :lol: ) and I can not do much in this tablet... :oops:
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Printing - Page number paradox

Post by Roberto Lopez »

Hi All,

I don't know anything about the internal structure of the EMF files, but just taking a quick look, it appears to be that strings are there, so, it could be only matter of put a placeholder for total pages in each one and then... DIRECTORY, MEMOREAD, STRTRAN, MEMOWRIT... you know... :)

In the following capture you can see PRINT DEMO string from HMG print demo:
capture.png
capture.png (223.51 KiB) Viewed 7369 times
Again... maybe I'm missing something important... sorry in advance.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
tonton2
Posts: 444
Joined: Sat Jun 29, 2013 1:26 pm
Location: Algerie
Contact:

Re: Printing - Page number paradox

Post by tonton2 »

voila un exemple de Mr Esgici dans facture hmg_hpdf dans viva clipper, dont les pages sont numérotées successivement.
voir le fichier pdf.
google traduction
here is an example of Mr Esgici in hmg_hpdf invoice viva clipper, with pages numbered consecutively.
see the pdf file.
Attachments
HPdfBill.zip
(390.56 KiB) Downloaded 292 times
L'Algerie vous salut
Y.TABET
Post Reply