Unicode and HMG_HPDF

HMG Unicode versions 3.1.x related

Moderator: Rathinagiri

User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Unicode and HMG_HPDF

Post by bpd2000 »

IMATECH wrote:Hi Esgici !
Adjusted ( but not tested ! )
..... ...
Regards
Error
Attachments
err.JPG
err.JPG (11.31 KiB) Viewed 10552 times
BPD
Convert Dream into Reality through HMG
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Unicode and HMG_HPDF

Post by esgici »

IMATECH wrote: Adjusted ( but not tested ! )
I tested :

Two REQUEST moved to before Main()
hb_gtsys() moved to after Main()

PROCEDURE() ( and its RETURN ) lines commented;

and the result ( same as Dave's ) :

Error BASE/1302 Argument error: HB_TRANSLATE

Called from HB_TRANSLATE(0)
Called from MAIN(24) -> SELECT HPDFDOC ( hb_Translate( cTarget...

Regards
Viva INTERNATIONAL HMG :D
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: Unicode and HMG_HPDF

Post by IMATECH »

Hi Esgici, bdp !


Adjusted :?
and
Tested ( Works ok )
espãnol.zip
txt and pdf
(2.1 KiB) Downloaded 502 times
#include "hmg.ch"
#include "hfcl.ch"

PROCEDURE Main()

LOCAL i
LOCAL lSelPDF
LOCAL aSourceText
LOCAL cSourceFileName
LOCAL cTargetFileName

hb_langSelect( 'es' )
hb_cdpSelect( "UTF8EX" )

cSourceFileName := "espãnol.txt"

aSourceText := hb_aTokens( hb_Translate( HB_MEMOREAD( cSourceFileName ), 'UTF8EX', 'ESISO' ), CHR(10) )

cTargetFileName := STRTRAN( cSourceFileName, "txt", "pdf" )

SELECT HPDFDOC ( hb_Translate( cTargetFileName, 'UTF8EX', 'ESISO' ) ) TO lSelPDF

IF lSelPDF

_HMG_HPDF_SetEncoding( "WinAnsiEncoding" )

START HPDFDOC

START HPDFPAGE
FOR i := 1 TO Len( aSourceText )
@ ( i * 4 )+15, 20 HPDFPRINT aSourceText[ i ]
NEXT
END HPDFPAGE

END HPDFDOC

IF FILE( cTargetFileName )
MsgInfo( "PDF Builded as " + cTargetFileName )
ELSE
MsgStop( "PDF Building Unsuccessful :(", "Unexpected ERROR !" )
ENDIF

ENDIF lSelPDF

RETURN

// *---------------------------------------------------------------------------*
// hb_gtsys()
// *---------------------------------------------------------------------------*
PROCEDURE hb_gtsys()

REQUEST HB_LANG_ES
REQUEST HB_CODEPAGE_ESISO
REQUEST HB_CODEPAGE_UTF8EX

RETURN


Harbour uses last libHaru sources ( 2.3.0RC2 ) supporting 1~2 bytes UTF8 codes
Then HMG_hbHpdf can be updated to use these new resources

Code: Select all

libHaru 2.3.0RC2

    Changed package naming, no other changes was done.

libHaru 2.3.0RC1

    Added support for 3dMeasures of subtype PD3 and 3DC, projection annotations, ExData and javascript attached to a U3D model. (Robert Würfel)
    Added support for 1- and 2-byte UTF8 codes. (Clayman)
    Added full PDF/A1-b support. (Petr Pytelka)
    Added support for CCITT compression for B/W images. (Petr Pytelka)
    Add support for TwoPageLeft and TwoPageRight layouts. (Vincent Dupont)
    Const-ified arrays used in the sources. (Ilkka Lehtoranta)
    Fixed build with libpng 1.5.0
    Fixed bug in HPDF_GetContents() - isize variable was not initialized. (Vincent Dupont)
    Fixed possible endless loop in PNG handling code. (reported by Mathew Waters)
    Fixed several issues based on the warnings generated by clang-analyzer. (Daniel Höpfl)
    Fixed quite a number of warnings. (Davide Achilli)
    Added 'd' postfix to debug build, fixed wrong filename. (Wim Dumon)
    Fixed HPDF_Text_Rect() not to split words in some obscure cases.

http://libharu.org/
Code Template:

Code: Select all

/* UTF8 */ 
HPDF_UseUTFEncodings( oPdf )

/* Embend Font */ 
HPDF_LoadTTFontFromFile( oPdf, "Any.ttf", .T. )

/* oPdf Font */ 
HPDF_GetFont( oPdf, cFontName, "UTF-8" )
Regards
Last edited by IMATECH on Thu Nov 07, 2013 9:57 pm, edited 1 time in total.
M., Ronaldo

By: IMATECH

Imation Tecnologia
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Unicode and HMG_HPDF

Post by esgici »

IMATECH wrote: Adjusted :?
and
Tested ( Works ok )
Hola Ronaldo,

yes; tested, works ok :arrow:

Thank you very much :D

Two little question ( if no problem ;) )
  • . español .OR. espãnol; which one is correct ? ( It cost me two hours :( )
    . how a function ( hb_gtsys ) runs without calling :o :?
Anyway, thanks again :)

Not only problem solved, but for everything increased my knowledge :D

As Daniel said : everybody learns something by every post ! 8-)

Viva HMG :D
Viva INTERNATIONAL HMG :D
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: Unicode and HMG_HPDF

Post by IMATECH »

Hi Esgici !


. español .OR. espãnol ( just a wrong backspace: shit happens )
Sorry, I don't know nothing about spanish language rules :(

. hb_gtsys
It's a default behavior for any Harbour GT

. HPDF_UseUTFEncodings( oPdf )
After Sr.Rathinagiri just include this function to HMG_HPDF lib any language will be correct created inside pdf files ( japanese, greek, ... )

. everybody learns something by every post !
Some times by every re-edited posts too :lol:
Then my posts can be readed again and again...


Regards
M., Ronaldo

By: IMATECH

Imation Tecnologia
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Unicode and HMG_HPDF

Post by esgici »

IMATECH wrote: . HPDF_UseUTFEncodings( oPdf )
After Sr.Rathinagiri just include this function to HMG_HPDF lib any language will be correct created inside pdf files ( japanese, greek, ... )
Yes, you are right,

Your good news and suggestions about HaruPDF and UT8 is more important than my asked problem,
thanks a lot for this also :)

Hopefully forum management will take into account your guidance :arrow:

Regarding re-editing posts, my humble opinion is:
forum software don't allow deleting answered posts;
this rule must apply to editing posts too, I think.

Because some people abusing it; uses posts as a scratchpad,
and will be very difficult to follow the subjects.
For example, corrects an his erroneous sentences after someone warn it :(

Anyway, thanks to everything and

Viva HMG :D
Viva INTERNATIONAL HMG :D
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: Unicode and HMG_HPDF

Post by IMATECH »

Hi quartz !

It's for you :)

image
Mixed Latin and Greek
Mixed Latin and Greek
capturar.png (13.15 KiB) Viewed 10468 times
pdf using Arial.ttf font
hbhpdf_unicode.zip
Windows Font, Source Sample and PDF File
(463.86 KiB) Downloaded 633 times

Regards
M., Ronaldo

By: IMATECH

Imation Tecnologia
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Unicode and HMG_HPDF

Post by bpd2000 »

IMATECH wrote:Hi quartz !

It's for you :)

image
capturar.png
pdf using Arial.ttf font
hbhpdf_unicode.zip

Regards
Thank you Ronaldo,
Add following 2 line to run above example

#define HPDF_COMP_ALL 0x0F
REQUEST HB_GT_WIN_DEFAULT

Regards
BPD
Convert Dream into Reality through HMG
User avatar
quartz565
Posts: 667
Joined: Mon Oct 01, 2012 12:37 pm
Location: Thessaloniki, Greece
Contact:

Re: Unicode and HMG_HPDF

Post by quartz565 »

Thank you very much Ronaldo. It works perfectly! :)
Thanks all !
Attachments
ABGD.png
ABGD.png (4.14 KiB) Viewed 10433 times
Best Regards,
Nikos.

os: Windows Server 2019 - 64
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: Unicode and HMG_HPDF

Post by IMATECH »

Hi !


Esgici, DanielMaximiliano, BPD and Nikos :)

Thanks for interest and feedback


Best regards
M., Ronaldo

By: IMATECH

Imation Tecnologia
Post Reply