QHTM in HMG

HMG Samples and Enhancements

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

QHTM in HMG

Post by Pablo César »

esgici wrote:My opinion is same as Daniel :arrow:

Thanks amigo Pablo;

please continue to support HMG by helping community :)

Viva HMG :D
Thank you amigo Esgici !!
Last edited by Pablo César on Tue Dec 11, 2012 12:59 pm, 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
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

QHTM in HMG

Post by Pablo César »

mol wrote:I've tested it, but I had problems with national fonts and CSS.
Is it possible to rsolve these problems?
These problems happen even compiling in UNICODE ? Your source editor it is in UTF-8 format ?

May you show us in captured screen your problem ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: QHTM in HMG

Post by mol »

I've tested with hmg 3.0.46 without UTF.
I didn't think about it.
I'll install new HMG and I'll test it again.

Source html was coded with UTF-8, really. My fault.

Regards, Marek
User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: QHTM in HMG

Post by luisvasquezcl »

Gracias Pablo,
tambien me uno a Daniel y agradezco tu esfuerzo y generosidad.
Saludos cordiales,
Luis Vasquez
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

QHTM in HMG

Post by Pablo César »

luisvasquezcl wrote:Gracias Pablo,
tambien me uno a Daniel y agradezco tu esfuerzo y generosidad.
Saludos cordiales,
Luis Vasquez
Muchas gracias Luis por el apoyo de todos ustedes.

Now Zoom and fonts handling it is possible. Thanks to our friend Claudio Soto. I releasing a new version with provisory printing option, because I am still founding much difficulties to implement QHTM function for printing.

I am with this dificulty in function PrintHTML. I am not getting print functions reconcile the Miniprint with QHTM in HMG.

The QHTM, accurate printing object handle. In MiniGUI hbprn is given by: hbprn:=hbprinter():new() and HMG no longer exists. I tried:

Code: Select all

Static Procedure PrintHTML( cHTMLFile )
Local hContext, nCountPages, Cycle
Local hDC := _HMG_SYSDATA[374] // it is not working with this (It's what I need)

SELECT PRINTER DEFAULT ;
	ORIENTATION	PRINTER_ORIENT_PORTRAIT ;
	PAPERSIZE	PRINTER_PAPER_A4 ;
	QUALITY		PRINTER_RES_MEDIUM  ;
	PREVIEW

// SELECT PRINTER DIALOG TO lSuccess PREVIEW

hContext := QHTM_PrintCreateContext()

START PRINTDOC
If QHTM_PrintSetTextFile( hContext, cHTMLFile )
   nCountPages := QHTM_PrintLayout( hDC, hContext )
   For Cycle := 1 to nCountPages
       START PRINTPAGE
		QHTM_PrintPage( hDC, hContext, Cycle )
	   END PRINTPAGE
   Next
Endif   
END PRINTDOC
QHTM_PrintDestroyContext( hContext )
Return Nil
But here I do not know how to get the object handle which will be necessary for:

nCountPages := QHTM_PrintLayout( HBPrn : hDC, hContext )

and

QHTM_PrintPage( HBPrn : hDC, hContext, Cycle )

As you can see, hbprinter class return a object hbprn which it can get it handle:

Code: Select all

Static Procedure PrintHTML( cHTMLFile )
Local hContext, nCountPages, Cycle

// Init PrintSys
hbprn:=hbprinter():new()

// Select by dialog
hbprn:selectprinter("",.T.)

// If !Empty( HBPRNERROR )
If !Empty( hbprn:error )
   Return nIL
Endif

#define DM_ORIENTATION      0x00000001
#define DMORIENT_PORTRAIT   1
#define DM_PAPERSIZE        0x00000002
#define DMPAPER_A4          9  /* A4 210 x 297 mm  */

// Set orientation PORTRAIT
hbprn:setdevmode(DM_ORIENTATION,DMORIENT_PORTRAIT)
// Set PaperSize DMPAPER_A4
hbprn:setdevmode(DM_PAPERSIZE,DMPAPER_A4)
// Set print margins Top 2 Left 5
hbprn:setviewportorg(2,5)
// Set Preview on
hbprn:PreviewMode := .T.
// Set preview rect 0, 0, GetDesktopRealHeight(), GetDesktopRealWidth()
hbprn:previewrect:={0, 0, GetDesktopRealHeight(), GetDesktopRealWidth()}
// Set preview scale 2
hbprn:previewscale:=2
// Set thumbnails on
hbprn:Thumbnails := .T.

hContext := QHTM_PrintCreateContext()

// Start doc name 'Print form'
hbprn:startdoc('Print form')

If QHTM_PrintSetTextFile( hContext, cHTMLFile )

   nCountPages := QHTM_PrintLayout( HBPrn : hDC, hContext )
   
   For Cycle := 1 to nCountPages
       // Start Page
	   hbprn:startpage()
       QHTM_PrintPage( HBPrn : hDC, hContext, Cycle )
       // End Page
	   If ( _HMG_BeginTabActive , _EndTabPage() , hbprn:endpage() )
   Next
   
Endif

hbprn:enddoc()
QHTM_PrintDestroyContext( hContext )
// Release PrintSys
hbprn:end()
Return Nil
So I tried to fix in this way but hbprinter class there is not present in HMG.

My question is how I can get the object handle in MINIPRINT or how I can replace hbprinter class ? Some colleague could help me, please ?

<Attached file removed, see last message with now release>
Last edited by Pablo César on Tue Dec 18, 2012 12:57 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
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

QHTM in HMG

Post by Pablo César »

With this code:

Code: Select all

Static Procedure PrintHTML( cHTMLFile )
Local hContext, nCountPages, Cycle

SELECT PRINTER DEFAULT ;
	ORIENTATION	PRINTER_ORIENT_PORTRAIT ;
	PAPERSIZE	PRINTER_PAPER_A4 ;
	QUALITY		PRINTER_RES_MEDIUM  ;
	PREVIEW

// SELECT PRINTER DIALOG TO lSuccess PREVIEW

hDC := _HMG_SYSDATA[374] // it should work (this is what I need)

START PRINTDOC NAME "Print form - QHTM"

hContext := QHTM_PrintCreateContext()

If QHTM_PrintSetTextFile( hContext, cHTMLFile )

   nCountPages := QHTM_PrintLayout( hDC, hContext )
   
   For Cycle := 1 to nCountPages
       START PRINTPAGE
          
		  QHTM_PrintPage( hDC, hContext, Cycle )

	   END PRINTPAGE
   Next
Endif   
END PRINTDOC
QHTM_PrintDestroyContext( hContext )
Return Nil
I am close. It has called Preview (two pages and it is in according with my html file) but... in blank... :cry: :x
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: QHTM in HMG

Post by Pablo César »

I found something interesting in this case. If I cut off PREVIEW option, then it will print.

SELECT PRINTER DEFAULT ;
ORIENTATION PRINTER_ORIENT_PORTRAIT ;
PAPERSIZE PRINTER_PAPER_A4 ;
QUALITY PRINTER_RES_MEDIUM
// PREVIEW (take out)

Would it be a bug in our PREVIEW code ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

QHTM in HMG

Post by Pablo César »

I GOT IT !!!

Now Preview it is working with QHTM !! Nothing wrong with our MINIPRINT !
Screen61.PNG
Screen61.PNG (34.72 KiB) Viewed 7108 times
It was a second handle needed.

I also got to change backcolor thru html commands.
Screen62.PNG
Screen62.PNG (34.5 KiB) Viewed 7105 times
Also changed font color of QHTM_MessageBox (It is like our MsgInfo).

<Attached file removed, see last message with now release>
Last edited by Pablo César on Tue Dec 18, 2012 9:07 pm, 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
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: QHTM in HMG

Post by Rathinagiri »

Super Pablo.

So, that means we can format our report in html also and print in the printer. That is so cool.

I have two points to be cleared:

1. Whether html code from a variable can be printed without saving it to a html file.

2. Can we use tables and other alignment formats?
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

QHTM in HMG

Post by Pablo César »

rathinagiri wrote:Super Pablo.

So, that means we can format our report in html also and print in the printer. That is so cool.
:P Yeahh !!
1. Whether html code from a variable can be printed without saving it to a html file.
Yes, we can print by HTML file and by context passed by variable (type character). I put more one button to show both cases.
2. Can we use tables and other alignment formats?
Yes we can use tables and other formats. See Tags.doc file in package attached file.

Thank you Mr. Rathinagiri to show your entusiastic interest for it ! See QHtm\Res\HTML\qhtm.html file for more QHTM Controls.

Remarks: My first message was re-edited for better understanding.
Attachments
QHtm.rar
(1.02 MiB) Downloaded 999 times
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply