HMG_HPDF - Export to PDF made easy...

HMG Samples and Enhancements

Moderator: Rathinagiri

EduardoLuis
Posts: 558
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Been thanked: 33 times

Re: HMG_HPDF - Export to PDF made easy...

Post by EduardoLuis » Mon Mar 12, 2018 4:56 pm

Hi Edward:

Unfortunatly i could not make it work.-
Some questions:
1.- I must have installed your previously new_functions zip ??
2.- About 1, i've download and when i try to decompile it give errors.-
3.- When rebuild library i must rebuild ANSI and Unicode or only ANSI ???
If you please tell me how to perform your excellent work.-
With regards.
Eduardo

edk
Posts: 304
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 81 times
Been thanked: 233 times

Post by edk » Mon Mar 12, 2018 6:31 pm

Hola Eduardo.
Ad.1. For latest functions (Skew, Scaled, Rendered, Circled), you do not need to have the previous New_features.7z installed, but if you want to use the previous new functions, you should have them installed.
Ad.2. What kind of errors?
Ad.3. Personally, I use Unicode.

OK.
I will try to describe step by step:

1. The hmg_hpdf.zip file should be unpacked. The hmg_hpdf.ch file will be created, which should be copied to the "INCLUDE" folder of the HMG 3.4.4 installation, eg C:\hmg.3.4.4\INCLUDE (contains the previous and the newest commands)
hmg_hpdf.zip
(5.39 KiB) Downloaded 45 times
2. The h_HMG_HPDF.zip file should be unpacked. The h_HMG_HPDF.Prg file will be created, which should be copied to the "SOURCE" folder of the HMG 3.4.4 installation, eg C:\hmg.3.4.4\SOURCE (contains previous and new functions)
h_HMG_HPDF.zip
(12.92 KiB) Downloaded 43 times
3. The demo.zip file should be unpacked. The Demo.prg file will be created, which should be copied to the "SAMPLES\HPDF\Demo1" folder of the HMG 3.4.4 installation, eg C:\hmg.3.4.4\SAMPLES\HPDF\Demo1
Demo.zip
(1.58 KiB) Downloaded 41 times
4. From the HMG installation folder 3.4.4 rebuild HMG using BuildLib32.bat, eg C:\hmg.3.4.4\BuildLib32.bat (using eg UNICODE- default)

5. From the HMG 3.4.4 installation folder, run the demo in the "SAMPLES\HPDF\Demo1" folder by running the Build.bat file, eg C:\hmg.3.4.4\SAMPLES\HPDF\Demo1\Build.bat

EduardoLuis
Posts: 558
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Been thanked: 33 times

Post by EduardoLuis » Mon Mar 12, 2018 7:13 pm

Hi Edward:

First thanks for your crystal clear explanation, after send you this respond, i'll follow your suggestions.-

Error - after performing compilation under 3.4.4 Ide - says:

Date:03/12/18 Time: 16:07:53
Error BASE/1081 Argument error: +

Called from _HMG_HPDF_SEEKHARUFONTS(1818)
Called from _HMG_HPDF_SETFONT(1756)
Called from HPDF_RENDERTEXT(357)
Called from MAIN(83)

Perhaps you can have a better idea.-
With regards.
Eduardo

EduardoLuis
Posts: 558
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Been thanked: 33 times

Post by EduardoLuis » Mon Mar 12, 2018 8:30 pm

Hi Edward:

All works like a charm. Absolutly OK.-
Again, thanks for your explanation, efforts, and to share with us all your knowledge.-
With regards.
Eduardo

edk
Posts: 304
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 81 times
Been thanked: 233 times

Post by edk » Mon Mar 12, 2018 9:21 pm

EduardoLuis wrote:
Mon Mar 12, 2018 7:13 pm
Error - after performing compilation under 3.4.4 Ide - says:

Date:03/12/18 Time: 16:07:53
Error BASE/1081 Argument error: +

Called from _HMG_HPDF_SEEKHARUFONTS(1818)
Called from _HMG_HPDF_SETFONT(1756)
Called from HPDF_RENDERTEXT(357)
Called from MAIN(83)

Perhaps you can have a better idea.-
With regards.
Eduardo
Everything was explained :lol: :
edk wrote:
Mon Mar 05, 2018 8:30 pm
New features:

***********************************************************
HMG HPDF

HPDFPRINT command improvements:
(...)

New commands:
(...)
:arrow: Removal of noticed bugs.

User avatar
bpd2000
Posts: 1013
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 163 times
Been thanked: 70 times

Post by bpd2000 » Tue Mar 13, 2018 4:53 am

Edward, how to get following result

Image

Image
BPD
Convert Dream into Reality through HMG

edk
Posts: 304
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 81 times
Been thanked: 233 times

Post by edk » Tue Mar 13, 2018 12:22 pm

Do you mean something like this ?:
Bez tytułu1.png
Bez tytułu1.png (14.83 KiB) Viewed 358 times
Replace the HPDF_CircleText function with this one (by the way, I corrected the rims color error if the color was not defined.):

Code: Select all

Function HPDF_CircleText( nRow, nCol, cFontName, nFontSize, nRColor, nGColor, nBColor, cText, lBold, lItalic, lColor, lFont, lSize, nRadial, lCircle, cAlign)
/* text along a circle */
/* nRow, nCol wspolrzedne srodka */
Local nAngle1, nAngle2, nRlen
Local i, nRad1, nRad2, x, y
Local oFont := Nil
Local cFont := ''
   
Local hPdf        := _HMG_SYSDATA[ 150 ][ 1 ]
Local hPage       := _HMG_SYSDATA[ 150 ][ 7 ]

*Local nWidth      := _HMG_SYSDATA[ 150 ][ 4 ]
Local nHeight     := _HMG_SYSDATA[ 150 ][ 5 ]
Local nxPos       := _HMG_HPDF_MM2Pixel( nCol )
Local nyPos       := nHeight - _HMG_HPDF_MM2Pixel( nRow )
Local nPxAng
Local nRange     := 360

DEFAULT lCircle     := .F. 
DEFAULT nRadial     := 15
default cFontName := ''
default nFontSize := _HMG_SYSDATA[ 150 ][ 9 ]
default nRColor := 0
default nGColor := 0
default nBColor := 0
default lBold := .f.
default lItalic := .f.
default lColor := .f.
default lFont := .f.
default lSize := .f.
DEFAULT cText := ""
DEFAULT cAlign :=""

IF !HB_IsNumeric( nRadial )
	nRadial := 15
ENDIF

IF !HB_IsString( cAlign )
	cAlign := ""
ENDIF

nRLen:= _HMG_HPDF_MM2Pixel( nRadial )

// set color
If lColor
   HPDF_Page_SetRGBFill( hPage, nRColor/255, nGColor/255, nBColor/255 )
else
   HPDF_Page_SetRGBFill( hPage, 0.0, 0.0, 0.0 )
endIf   


IF lCircle
	If lColor
		HPDF_Page_SetRGBSTROKE( hPage, nRColor/255, nGColor/255, nBColor/255 )
	else
		HPDF_Page_SetRGBSTROKE( hPage, 0.0, 0.0, 0.0 )
	endIf   
	HPDF_Page_SetLineWidth (hPage, 1.5)
	HPDF_Page_Circle ( hPage, nxPos, nyPos, nRlen + nFontSize)
	HPDF_Page_Circle ( hPage, nxPos, nyPos, nRlen - (nFontSize /3))
	HPDF_Page_Stroke ( hPage )
	HPDF_Page_SetLineWidth (hPage, 1)
ENDIF

// set font
cFontName := AllTrim(_HMG_HPDF_SetFont( cFontName, lBold, lItalic ))
if HMG_UPPER (cFileExt (cFontName)) == '.TTF' // load ttf font
	cFont := HPDF_LOADTTFONTFROMFILE( hPdf, cFontName, .t. )
	If HMG_LEN( alltrim( cFont ) ) == 0
		_HMG_HPDF_Error( 6 , cFontName )
		Return Nil
	endif
	oFont := HPDF_GetFont( hPdf, cFont, _HMG_SYSDATA[ 150 ][ 10 ] )
else
	If HMG_UPPER( alltrim( cFontName ) ) == "SYMBOL" .or. HMG_UPPER( alltrim( cFontName ) ) == "ZAPFDINGBATS"
		oFont := HPDF_GetFont( hPdf, cFontName, Nil )
	else   
		oFont := HPDF_GetFont( hPdf, cFontName, _HMG_SYSDATA[ 150 ][ 10 ] )
	endIf   
endif

If oFont == Nil
   _HMG_HPDF_Error( 6 , cFontName )
   Return Nil
EndIF
HPDF_Page_SetFontAndSize( hPage, oFont, nFontSize )

SWITCH HMG_UPPER( alltrim( cAlign ) )
	CASE "TOP"   ; nRange := 180 ; EXIT		//Uppper
	CASE "BOTTOM"  ; nRange := 180 ; EXIT   	//Bottom
ENDSWITCH

nAngle1 := nRange / Len( cText )	//monospaced fonts
nAngle2 := 180

//A better solution for non monospaced fonts.
nPxAng := nRange / HPDF_Page_TextWidth( hPage, cText )

HPDF_Page_BeginText ( hPage)
FOR i=1 TO LEN(cText)
	nRad1 := ( nAngle2 - Int((HPDF_Page_TextWidth( hPage, SUBSTR(cText, i, 1) ) * nPxAng) / 2) - 90) / 180 * 3.141592
	nRad2 := nAngle2 / 180 * 3.141592
	
	SWITCH HMG_UPPER( alltrim( cAlign ) )
		CASE "BOTTOM"  
			x := nxPos + cos(nRad2) * (nRlen + nFontSize*(2/3)) 
			y := nyPos - sin(nRad2) * (nRlen + nFontSize*(2/3))

			HPDF_Page_SetTextMatrix( hPage, cos(nRad1), -sin(nRad1), sin(nRad1), cos(nRad1), x, y)
			EXIT   	
	
		OTHERWISE   
			x := nxPos + cos(nRad2) * nRlen  
			y := nyPos + sin(nRad2) * nRlen 
	
			HPDF_Page_SetTextMatrix( hPage, cos(nRad1), sin(nRad1), -sin(nRad1), cos(nRad1), x, y)
	
	ENDSWITCH
	
	HPDF_Page_ShowText ( hPage, SUBSTR(cText, i, 1) )
	
	//nAngle2 -= nAngle1		//monospaced fonts
	
	//A better solution for non monospaced fonts.
	nAngle2 -= (HPDF_Page_TextWidth( hPage, SUBSTR(cText, i, 1) ) * nPxAng) 	 
	
NEXT i
HPDF_Page_EndText ( hPage )

RETURN Nil
Replace #xcommand @ <Row>, <Col> HPDFPRINT CIRCLED TEXT with this one:

Code: Select all

#xcommand @ <Row> , <Col> HPDFPRINT CIRCLED TEXT <cText> ;
	[ <lfont : FONT> <cFontName> ] ;
	[ <lsize : SIZE> <nFontSize> ] ;
	[ <bold : BOLD> [ IF <lBold> ] ] ;
	[ <italic : ITALIC> [ IF <lItalic> ] ] ;
	[ <lcolor : COLOR> <aColor> ] ;
 	[ <lrad : RADIUS> <nRad> ] ;
	[ <lrims: RIMS> ] ;
	[ <align : TOP, BOTTOM> ] ; 
	=> ;
	HPDF_CircleText ( <Row> , <Col> , <cFontName> , <nFontSize> , <aColor>\[1\] , <aColor>\[2\] , <aColor>\[3\] , <cText> ,;
		<.bold.> .AND. iif( HB_IsLogical(<lBold>), <lBold>, HB_IsNil(<lBold>) ) ,; 
		<.italic.> .AND. iif( HB_IsLogical(<lItalic>), <lItalic>, HB_IsNil(<lItalic>) ) ,;
		<.lcolor.> , <.lfont.> , <.lsize.> , <nRad> , <.lrims.> , <"align">) 
In your source, use the commands:

Code: Select all

@ 230 , 160 HPDFPRINT CIRCLED TEXT "TIPSQUIRREL" FONT "Times" SIZE 20 BOLD RADIUS 20 RIMS TOP
@ 230 , 160 HPDFPRINT CIRCLED TEXT "  "+chr(149)+"  PS NUTS  "+chr(149)+"  " SIZE 20 BOLD RADIUS 20 BOTTOM
where:
TOP - prints the text in the upper half of the circle
BOTTOM - prints the text in the bottom half of the circle

Edward.
Last edited by edk on Tue Mar 13, 2018 12:33 pm, edited 2 times in total.

User avatar
bpd2000
Posts: 1013
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 163 times
Been thanked: 70 times

Post by bpd2000 » Tue Mar 13, 2018 12:30 pm

WOW!
Thank you Edward, now we can play 360 degree
BPD
Convert Dream into Reality through HMG

EduardoLuis
Posts: 558
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Been thanked: 33 times

Post by EduardoLuis » Tue Mar 13, 2018 1:18 pm

Hi Edward:

Again: WOOOOOOWWWWWWW
Excellent.- With these new functions PDF get all the possible power.-
Thanks for your effort.-
With regards.
Eduardo

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

Post by Rathinagiri » Tue Mar 13, 2018 1:50 pm

Wonderful!

EDward, Can you make it work for unicode encoding also? Especially Indian languages?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

Post Reply