GTWVT / GTXWC Printing

744 views
Skip to first unread message

Gmail

unread,
Jun 7, 2013, 10:23:07 AM6/7/13
to harbou...@googlegroups.com
Hello all,
 
 
    I would like to add printing to my little program but I realized that I never did any routine for printing in Harbour (I know how to generate PDF or to print as it was in Clipper).
 
    Sorry... It may be very basic to many of you but I need some help with that...
 
    I use GTWVT but I would like something that could work with Linux too (GTXWC seems to be GTWVT equivalent for *nix? I hope I will be able to compile for both OS’es) so Win32Prn and Windows only solutions are not an option.
 
    What do you suggest to use as printing solution? I would like to print simple (old style Clipper – very simple reports) and complex (like forms with lines, pictures, colors, different sizes, different fonts, barcode, etc). Please look both examples (attached).
 
    Do you have any example, please?
 
    Thanks for any input.
 
    Regards,
 
 
Qatan
 
 
simple.txt
complex.gif

Teo Fonrouge

unread,
Jun 7, 2013, 11:09:44 AM6/7/13
to harbou...@googlegroups.com
Hello Qatan,

To print complex reports/documents I use an .html file which has tokens with the fields to 'fill' in the final .html file, the 'fill' process is made by parsing the tokens in the .html file to generate a new .html file which has the real values from the app, images can be inserted too.

I choose the .html format because it is easy to edit for end users with any html editor.

The .pdf is generated by using the linux utility 'wkhtmltopdf' from any .html file.
Attached you will find the following files:

fmt_cfd_fa.html  -  is the .html file with the tokens
FA_7529.html :  is the final .html parsed
FA_7529.pdf  : is the .pdf version

HTH


best regards,

Teo


PD: Because this is a fiscal document I already scrambled the digital signature to invalidate the document.

FA_F7529.html
FA_F7529.pdf
fmt_cfd_fa.html

Alain Aupeix

unread,
Jun 7, 2013, 11:26:52 AM6/7/13
to harbou...@googlegroups.com, Teo Fonrouge
Le 07/06/2013 17:09, Teo Fonrouge a écrit :
Hello Qatan,


On Friday, June 7, 2013 9:23:07 AM UTC-5, Qatan wrote:
Hello all,
 
 
    I would like to add printing to my little program but I realized that I never did any routine for printing in Harbour (I know how to generate PDF or to print as it was in Clipper).
Don't remember how it was with Clipper, it's so long ...
But to print under Linux, you have to unstall some packets relating to cups.
I don't have in mind the exact names, but I think of libcups2-dev (perhaps libcups2 too, but I think it's already installed)
Use synaptic and search for cups (if synaptic not installed : sudo apt-get install synaptic)

A+
--

Alain Aupeix
http://jujuland.pagesperso-orange.fr/
http://pissobi-lacassagne.pagesperso-orange.fr/

U.buntu 12.04 | G.ramps 3.4.5-1 | H.arbour 3.2.0dev (r2013-05-29 15:14) | HbIDE (Rev.223) | FiveLinux (r138) | Hw.Gui (2062)

Francesco Perillo

unread,
Jun 7, 2013, 12:05:07 PM6/7/13
to harbou...@googlegroups.com
I see that a lot of people using Harbour is working in the pharma business.... :-)

Teo idea is really smart.

I'd create a pdf directly using harupdf... but Teo solution is better since its form can have placeholder that can "expand" and he doesn't have to take care of this.
I mean, from what I understand, that {Cfd:CadenaOriginal} can expand to 1 or 5 lines and the html renderer will take care of it...

but what happens when there are too many lines and you need to print 2 pages ?


SD

unread,
Jun 7, 2013, 3:25:29 PM6/7/13
to harbou...@googlegroups.com
Dear Qatan:

You've initiated a good topic!. Thanks for it and hope we will have good inputs in this thread...

Actually many among us who are still into Dos printing mode, are still wondering for a "REAL-LIFE REASONABLE METHOD" to cope with Windows Printing keeping compatibility with DOS also. There could be many ways.....

1)Old clipper style can be adopted. Run the report and re-direct the output to a text file (the old clipper way) and then have "WINDOWS PRINTING ROUTINE" using Harbour. Printer Dialog Box can be invoked for printer selection. And HERE along with other windows/dos printers, we can have any free Printer Pdf pre-installed so that the output could be re-directed to a Pdf file without using any source for printing to a pdf file.

2)The power of OLE could be used here - like exporting to Excel. I've found this method generates the true excel report, where one can have complete control of the format of the report and can perform calculations/modify the excel report like it was created "manually" and not "programtically". Just too perfect.....

3)Using Tbrowse - we can redirect the report to a text file and then browse the textfile using tbrowse. And now from here you can export it to clipboard..then to notepad..word...excel....etc.

4)Have seen in HMG or somewhere else, the report engine creates an "IMAGE" of the actual report in tiff/bmp or in any other image format. And this image can be printed...

5) Exporting to Html - The implementation of Teo Fonrouge is just amazing

6)Exporting to XML 

Like you, I'm also looking for the best possible and reasonable to implement solution. Currently using the old clipper way..... but have experimented with steps 1 to 3 on real application.


Dear Teo Fonrouge:

Great job! This (or XML) could be THE BEST seeing current scenario (browser dependency increasing) Wondering what you are doing here... are you first transferring the report to tbrowse or dbf then exporting to HTml? Long time ago saw a routine somewhere tbrowse to Html...

With Teo's method, how a multiple pages report could be generated and print of the same can be taken would be an interesting thing.

Regards,
Swapan

Teo Fonrouge

unread,
Jun 9, 2013, 2:43:47 AM6/9/13
to harbou...@googlegroups.com
Hi Francesco,

On Friday, June 7, 2013 11:05:07 AM UTC-5, fperillo wrote:
I see that a lot of people using Harbour is working in the pharma business.... :-)

Teo idea is really smart.

I'd create a pdf directly using harupdf... but Teo solution is better since its form can have placeholder that can "expand" and he doesn't have to take care of this.
I mean, from what I understand, that {Cfd:CadenaOriginal} can expand to 1 or 5 lines and the html renderer will take care of it...

Exactly, the central word here is 'renderer' .

The html language, (powerful enough to fuel the complexity in the current internet web pages) is enough to help to create complex business reports that contains; tables, embedded images, formated text, font sizes/types, colors, etc..., as a plus there is also the CSS.

So, as any renderer (i.e. one that is based in construct a bit-image) one need to do some homework to 'fit' the result in the final media where the output will be embodied, i.e. different paper sheet sizes or an page preview with hypertext links.
 
but what happens when there are too many lines and you need to print 2 pages ?

 In the harbour dir 'contrib/hbtip/tests/' you'll find a good simple sample on how to build an html file filled with data in records from a .dbf (of course the data source can be of ANY type you imagine): dbtohtml.prg, give it a try.

This scenario is different on my provided sample above, here the html is completely builded from scratch in order to contain an unknown size of data on records, and of course here you have the possibility to calculate the rows per paper sheet, and add an header/footer per .html file generated.

In my sample, I use the .html file as a 'mask' on how the final .html will lock just by replacing the tokens with the actual data, in the file 'fmt_cfd_fa.html' you'll found a tag:

<PartidaBase>
</PartidaBase>

This tag in my implementation, is repeated in the resulting .html by the number of items appearing in the invoice, and in my case, the final .html is not required to be printed in any paper sheet, it is just been sent via e-mail to the customer.


best regards,

Teo

Teo Fonrouge

unread,
Jun 9, 2013, 2:52:31 AM6/9/13
to harbou...@googlegroups.com


On Friday, June 7, 2013 2:25:29 PM UTC-5, SD wrote:
Dear Qatan:

You've initiated a good topic!. Thanks for it and hope we will have good inputs in this thread...

Actually many among us who are still into Dos printing mode, are still wondering for a "REAL-LIFE REASONABLE METHOD" to cope with Windows Printing keeping compatibility with DOS also. There could be many ways.....

1)Old clipper style can be adopted. Run the report and re-direct the output to a text file (the old clipper way) and then have "WINDOWS PRINTING ROUTINE" using Harbour. Printer Dialog Box can be invoked for printer selection. And HERE along with other windows/dos printers, we can have any free Printer Pdf pre-installed so that the output could be re-directed to a Pdf file without using any source for printing to a pdf file.

2)The power of OLE could be used here - like exporting to Excel. I've found this method generates the true excel report, where one can have complete control of the format of the report and can perform calculations/modify the excel report like it was created "manually" and not "programtically". Just too perfect.....

3)Using Tbrowse - we can redirect the report to a text file and then browse the textfile using tbrowse. And now from here you can export it to clipboard..then to notepad..word...excel....etc.

4)Have seen in HMG or somewhere else, the report engine creates an "IMAGE" of the actual report in tiff/bmp or in any other image format. And this image can be printed...

5) Exporting to Html - The implementation of Teo Fonrouge is just amazing

6)Exporting to XML 

Like you, I'm also looking for the best possible and reasonable to implement solution. Currently using the old clipper way..... but have experimented with steps 1 to 3 on real application.


Dear Teo Fonrouge:

Great job! This (or XML) could be THE BEST seeing current scenario (browser dependency increasing) Wondering what you are doing here... are you first transferring the report to tbrowse or dbf then exporting to HTml? Long time ago saw a routine somewhere tbrowse to Html...

With Teo's method, how a multiple pages report could be generated and print of the same can be taken would be an interesting thing.

Please see the answer to Francesco.

Creating the .html and printing it are two different things. However there a plenty of options/tools in any OS/Platform to send to printing an .html file, even in GUI toolkits like Qt, or wxWidgets there are classes that allow to do a 'preview' or print an .html file.
 
Regards,
Swapan

On Friday, 7 June 2013 20:39:44 UTC+5:30, Teo Fonrouge wrote:
To print complex reports/documents I use an .html file which has tokens with the fields to 'fill' in the final .html file, the 'fill' process is made by parsing the tokens in the .html file to generate a new .html file which has the real values from the app, images can be inserted too.

I choose the .html format because it is easy to edit for end users with any html editor.


best regards,

Teo
 

Gmail

unread,
Jun 9, 2013, 4:42:43 AM6/9/13
to harbou...@googlegroups.com
Hello Teo,
 
    Your idea is very good. Thanks for your suggestion and for answering.
    Somehow here it does not show correctly. The accented words are wrong and the logo is not showing completely... I am using Win 7 Pro 32bits and IE 9.0.8112.16421. Am I missing something? (look the attached files to see what I got).
    I think HTML is a good option because it seems to be portable and pretty flexible. There is other programmer that does it using CSS to have options of presentation in his reporting system but it seemed a bit too much for me.
    I used HaruPDF that is very nice but you have to handcraft the reports and it is a lot of work. Any change is a pain... HMG 3 has a nice system but it is a Windows only solution although there is HMG 4 that uses GT but I do not like it and anyway I am interested in GTWVT.
    I would like to know how to do multipage in HTML in a way that it would work flawlessly in any OS and browser taking into account that the data could vary from report to report.
    Thanks again for your prompt response.
    Regards,
 
Qatan
 
 

 
To print complex reports/documents I use an .html file which has tokens with the fields to 'fill' in the final .html file, the 'fill' process is made by parsing the tokens in the .html file to generate a new .html file which has the real values from the app, images can be inserted too.
 
I choose the .html format because it is easy to edit for end users with any html editor.
 
The .pdf is generated by using the linux utility 'wkhtmltopdf' from any .html file.
HTML.jpg
Temporary.pdf

Gmail

unread,
Jun 9, 2013, 4:29:18 PM6/9/13
to harbou...@googlegroups.com
Hello Teo / Everyone else,
 
    I was looking your HTML file and I would like to know how do you build the HTML template.
    Do you use some type of editor? How do you do it?
    I am also interested to know how do you do to save the image (logo) as string “base64...etc...”
    It seems interesting.
   
    By the way I found this interesting article about reports and user customization needs: http://beyondrelational.com/modules/2/blogs/28/posts/10500/creating-reports-that-the-end-user-can-customize.aspx
 
    Other thing... maybe someone could help me with this. I use HaruPDF and sometimes it is very difficult to print long texts inside a box (like you do with your example in “Cadena original” where the text auto-adjust to the box). I would like to create something to do it automatically in HaruPDF, something like Windows Notepad does with WORD-WRAP but it may be complex... and has to take in consideration the font type and size... How to do it? Anyone with any idea?
 
    Thanks for your help.
 
Qatan
 

Gmail

unread,
Jun 10, 2013, 5:18:08 AM6/10/13
to harbou...@googlegroups.com
Hello M., Ronaldo,
 
    That’s a good option.
    What I like in HaruPDF is that the final report looks very nice and professional but it demands a lot of work even with pre arranged functions (or methods)...
 
    Also thanks for the tip (I think this is what I was missing in HaruPDF):
 
------8<------
HPDF_Page_BeginText( ::oPage )
HPDF_Page_TextRect( ::oPage, nLeft, ::Page_Height__-( nTop ), nRight, ::Page_Height__-( nBottom ), cTxt, nAlignment, NIL )
HPDF_Page_EndText( ::oPage )
------>8------
 
    I also like the idea from having a “report engine” based on external TXT files. Look this one from Alexander Kresin (it’s old stuff but I like the idea): http://www.kresin.ru/en/prcother.html
   
    I am trying to have something very simple but with professional results. As very simple I mean something easy to build and to do maintenance (reports may change all the time...) 
    I even think about creating a way for the user to customize the report...
    The question is to use HaruPDF or HTML? And how? I think HTML is easier but I do not have any experience with it. Maybe a combination of Kresin’s report engine and HTML template? (or even HaruPDF).
 
    Just my thoughts...
    Thanks for sharing your work. Nice job.
 
Qatan
 
 
Sent: Monday, June 10, 2013 3:03 AM
Subject: Re: [harbour-users] Re: GTWVT / GTXWC Printing
 
*** Qatan write: I use HaruPDF and sometimes it is very difficult to print long texts inside a box

Did you see MR-Print: will show how simple int can be ( uses harupdf )

https://github.com/downloads/MRonaldo/MR-Tools/MR_Print.PDF
https://github.com/downloads/MRonaldo/MR-Tools/MR-Print_v1_r20121121.rar


regards

Teo Fonrouge

unread,
Jun 10, 2013, 3:58:26 PM6/10/13
to harbou...@googlegroups.com
Hi Qatan,


On Sunday, June 9, 2013 3:42:43 AM UTC-5, Qatan wrote:
Hello Teo,
 
    Your idea is very good. Thanks for your suggestion and for answering.
    Somehow here it does not show correctly. The accented words are wrong and the logo is not showing completely... I am using Win 7 Pro 32bits and IE 9.0.8112.16421. Am I missing something? (look the attached files to see what I got).

Seems that IE needs explicitly 'charset="utf-8"' in the <meta> tag:

<meta ............. charset="utf-8">

There are another things were the IE complains, but the .html get's converted on to .pdf as is with my procedure.

Teo Fonrouge

unread,
Jun 10, 2013, 4:04:03 PM6/10/13
to harbou...@googlegroups.com


On Sunday, June 9, 2013 3:29:18 PM UTC-5, Qatan wrote:
Hello Teo / Everyone else,
 
    I was looking your HTML file and I would like to know how do you build the HTML template.
    Do you use some type of editor? How do you do it?

I use XCode to edit the .html template, no big deal.
 
    I am also interested to know how do you do to save the image (logo) as string “base64...etc...”
    It seems interesting.

In this case I use the openssl tool that comes with Linux:

openssl enc -base64 -A -in myimage.jpg  > base64encoded.txt


But I'm sure that you also can use the base64 routines that has Harbour.

M., Ronaldo

unread,
Jun 10, 2013, 5:46:16 PM6/10/13
to harbou...@googlegroups.com
Hi Qatan !

You can create personal report's ( .prg files editable by users ) then running it as script :)

see this link:

https://groups.google.com/forum/#!searchin/harbour-users/hb_compilebuf/harbour-users/Tbwqrul9n_w/UFeQujLJdz0J

Gmail

unread,
Jun 11, 2013, 1:24:48 AM6/11/13
to harbou...@googlegroups.com
Hello M., Ronaldo,
 
 
>You can create personal report's ( .prg files editable by users ) then running it as script :)
>see this link:
>
https://groups.google.com/forum/#!searchin/harbour-users/hb_compilebuf/harbour-users/Tbwqrul9n_w/UFeQujLJdz0J
 
 
    Thanks for the suggestion. I will look into it.
    Regards,
 
Qatan

Gmail

unread,
Jun 11, 2013, 1:26:33 AM6/11/13
to harbou...@googlegroups.com
Hello Teo,
 
    Thanks for explaining it.
    It’s interesting to know how you do with reports. Good idea.
    Regards,
 
Qatan
 

Gmail

unread,
Jul 3, 2013, 3:50:44 AM7/3/13
to harbou...@googlegroups.com
Hello M., Ronaldo,
I just found it and I liked your idea and that one too...
I am basically making my own from scratch (in a way that is easier for me to use and understand) but I am basically doing it from Antonio’s and your’s idea.
Regards,
 
Qatan

Dragan Cizmarevic

unread,
Jul 3, 2013, 6:15:02 AM7/3/13
to harbou...@googlegroups.com
No, it's not same

FiveWin is commercial product, mr_print is free additional for harbour, not perfect but working

Gmail

unread,
Jul 3, 2013, 6:54:41 AM7/3/13
to harbou...@googlegroups.com
Hello Dragan,
 
 
>No, it's not same
Sorry... did I say anything that they are the same?
 

>FiveWin is commercial product, mr_print is free additional for harbour, not perfect but working
And what do you mean? I know FiveWin is commercial product.
You do not need to use FiveWin to run the example. Do you?
Please check again.
Regards,
 
Qatan
Reply all
Reply to author
Forward
0 new messages