Printing - Page number paradox

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
Rathinagiri
Posts: 5096
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 93 times
Been thanked: 107 times
Contact:

Printing - Page number paradox

Post by Rathinagiri » Thu Oct 20, 2016 5:15 am

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: 2742
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 91 times
Been thanked: 32 times
Contact:

Post by mol » Thu Oct 20, 2016 5:46 am

I had the same idea, but no idea hot to realize that :-)

User avatar
Pablo César
Posts: 4052
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 175 times

Post by Pablo César » Thu Oct 20, 2016 11:17 am

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: 1729
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 218 times
Been thanked: 39 times
Contact:

Post by serge_girard » Thu Oct 20, 2016 1:56 pm

Rathi,

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

Serge

User avatar
Anand
Posts: 169
Joined: Tue May 24, 2016 4:36 pm
DBs Used: DBF
Has thanked: 14 times
Been thanked: 28 times

Post by Anand » Thu Oct 20, 2016 5:04 pm

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 2941 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 2941 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 2941 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
Image

User avatar
mol
Posts: 2742
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 91 times
Been thanked: 32 times
Contact:

Post by mol » Thu Oct 20, 2016 5:11 pm

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: 5096
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 93 times
Been thanked: 107 times
Contact:

Post by Rathinagiri » Thu Oct 20, 2016 5:40 pm

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: 4052
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 175 times

Post by Pablo César » Thu Oct 20, 2016 6:24 pm

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: 3880
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 13 times
Been thanked: 107 times

Post by Roberto Lopez » Thu Oct 20, 2016 7:25 pm

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 2904 times
Again... maybe I'm missing something important... sorry in advance.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
tonton2
Posts: 241
Joined: Sat Jun 29, 2013 1:26 pm
Location: Algerie
Has thanked: 3 times
Been thanked: 3 times
Contact:

Post by tonton2 » Thu Oct 20, 2016 7:41 pm

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 68 times
L'Algerie vous salut
Y.TABET

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest