HaruPDF and accented chars

1,019 views
Skip to first unread message

Qatan

unread,
Oct 19, 2010, 11:53:28 AM10/19/10
to harbou...@googlegroups.com
Hello,
 
    Using Harbour + GTWVT - no codepage selected.
    Is there any function to convert accented chars so it will show corrected in PDF files generated using Haru?
    Some examples: " Á á é í ó ú ç Ç â ê ô Ã ã õ Ü ü "
    Thanks for any hint
 
Qatan
 

Maurizio la Cecilia

unread,
Oct 19, 2010, 11:04:51 AM10/19/10
to harbou...@googlegroups.com
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users
Hi Qatan,
try to convert your string with hb_OEMtoAnsi( ) before to send to HaruPDF output.
Best regards.
Maurizio

David MS

unread,
Oct 19, 2010, 11:56:57 AM10/19/10
to Harbour Users
Hi Qatan

If you are using UTF8 strings, you must use

HB_UTF8TOSTR()

Best Regards
David Montaño.

Qatan

unread,
Oct 19, 2010, 2:21:35 PM10/19/10
to harbou...@googlegroups.com
Hello David,

Thanks for answering.
Didn�t work. I use OEM strings and need to change it to the way PDF
understands it. I am not sure but maybe I should change from OEM to UTF8?
Any hint? Everyone is welcome to help with this.
Regards,

Qatan


----- Original Message -----
From: "David MS" <da...@gesintur.com>
To: "Harbour Users" <harbou...@googlegroups.com>
Sent: Tuesday, 19 de October de 2010 12:56
Subject: [harbour-users] Re: HaruPDF and accented chars


On 19 oct, 17:53, "Qatan" <wanstad...@gmail.com> wrote:
> Hello,
>
> Using Harbour + GTWVT - no codepage selected.
> Is there any function to convert accented chars so it will show corrected
> in PDF files generated using Haru?

> Some examples: " � � � � � � � � � � � � � � � � "


> Thanks for any hint
>
> Qatan

Hi Qatan

If you are using UTF8 strings, you must use

HB_UTF8TOSTR()

Best Regards
David Monta�o.

Maurizio la Cecilia

unread,
Oct 19, 2010, 2:11:15 PM10/19/10
to harbou...@googlegroups.com
Il 19/10/2010 20.21, Qatan ha scritto:
Hello David,

   Thanks for answering.
   Didn´t work. I use OEM strings and need to change it to the way PDF understands it. I am not sure but maybe I should change from OEM to UTF8?
   Any hint? Everyone is welcome to help with this.
   Regards,

Qatan


----- Original Message ----- From: "David MS" <da...@gesintur.com>
To: "Harbour Users" <harbou...@googlegroups.com>
Sent: Tuesday, 19 de October de 2010 12:56
Subject: [harbour-users] Re: HaruPDF and accented chars




On 19 oct, 17:53, "Qatan" <wanstad...@gmail.com> wrote:
Hello,

Using Harbour + GTWVT - no codepage selected.
Is there any function to convert accented chars so it will show corrected in PDF files generated using Haru?
Some examples: " Á á é í ó ú ç Ç â ê ô Ã ã õ Ü ü "
Thanks for any hint

Qatan

Hi Qatan

If you are using UTF8 strings, you must use

HB_UTF8TOSTR()

Best Regards
David Montaño.

Hi Qatan,
test my suggestion. I also use OEM437 in my prgs.
I forgotten to say that i'm configuring:

HPDF_GetFont( ::pdf, ::fontName, "WinAnsiEncoding"  )

and  then

HPDF_Page_TextOut( ::page, x, y, hb_OEMtoAnsi( txt )  )

Here the characters appears fine in pdf.
Let me know if this works fine at your pc.
Best regards.
Maurizio

Maurizio Faccio adinet

unread,
Oct 19, 2010, 2:12:16 PM10/19/10
to harbou...@googlegroups.com
Qatan


I use CP850 and i convert all strings passing through this filter.

FUNCTION CONVIERTECHAR(_string)
_string:=STRTRAN(_string,CHR(161),CHR(237)) && i con tilde A1
_string:=STRTRAN(_string,CHR(160),CHR(225)) && a con tilde A0
_string:=STRTRAN(_string,CHR(130),CHR(233)) && e con tilde 82
_string:=STRTRAN(_string,CHR(162),CHR(243)) && o con tilde. A2
_string:=STRTRAN(_string,CHR(163),CHR(250)) && u con tilde A3
_string:=STRTRAN(_string,CHR(164),CHR(241)) && enie A4
_string:=STRTRAN(_string,CHR(129),CHR(251)) && u con dierisis 81
_string:=STRTRAN(_string,CHR(165),CHR(209)) && enie mayuscula A5
_string:=STRTRAN(_string,CHR(144),CHR(201)) && E con tilde 90
_string:=STRTRAN(_string,"�",CHR(176))

I guess that is more elegant to change the encoding of the pdf :
Please review

http://libharu.sourceforge.net/fonts.html
http://libharu.sourceforge.net/examples.html#encoding_list.c_

El 19/10/2010 04:21 p.m., Qatan escribi�:

Qatan

unread,
Oct 19, 2010, 11:23:10 PM10/19/10
to harbou...@googlegroups.com
Hello,
   
    Thanks for helping.
 
    Here I found that just using "WinAnsiEncoding" as you mentioned will work. It is not necessary to use hb_OEMtoAnsi() because it will produce strange chars here...
    "CP1252" also works fine here.
 
    Follows example of what I use that works fine:
 
   def_font1 := HPDF_GetFont( pdf, "Helvetica", "WinAnsiEncoding"  ) 
   def_font2 := HPDF_GetFont( pdf, "Helvetica-Bold", "WinAnsiEncoding"  )
    Now I have a new problem... I dont know how to create a PDF with barcode (Code 128).
    I was trying:
 
   font_name = HPDF_LoadTTFontFromFile( pdf, "c:\pdf\code128.ttf", HPDF_TRUE )
   def_font3 := HPDF_GetFont( pdf, font_name, "WinAnsiEncoding" )
 
    But it does not create the PDF.
    If I take out the two above lines the program creates the PDF but I will need the Code 128 barcode font.
 
    Any hint?
 
    Regards,
 
Qatan
 
--

Qatan

unread,
Oct 19, 2010, 11:28:43 PM10/19/10
to harbou...@googlegroups.com
Hello Maurizio,

Maurizio la Cecilia gave me the solution.
I configure the PDF codepage this way:

def_font1 := HPDF_GetFont( pdf, "Helvetica", "WinAnsiEncoding" )
def_font2 := HPDF_GetFont( pdf, "Helvetica-Bold", "WinAnsiEncoding" )

It works great. "CP1252" works also.

Thanks for answering.

Qatan


Qatan

http://libharu.sourceforge.net/fonts.html
http://libharu.sourceforge.net/examples.html#encoding_list.c_

--

Jan Sperling

unread,
Oct 20, 2010, 1:40:21 PM10/20/10
to harbou...@googlegroups.com
Hi all:
 
Does anybody know some good lib or DLL to change on the fly the default rectangular button shapes?
 
I´m looking for some way to enhance the look of the buttons, without changing my source...
 
TIA, Jan
 

gvar...@gmail.com

unread,
Nov 24, 2017, 1:05:43 AM11/24/17
to Harbour Users
Hi Qatan:

I'm testing D:\harbour\contrib\hbhpdf\tests\harupdf.prg and I have the following situations:

1. - In Win7 I am good at myharu. pdf.
2. - In Win8, it does not generate myharu. pdf (it gives me error 0x1017 HPDF_FILE_OPEN_ERROR 13), I have to remove the extension ". pdf" so that it generates the file "myharu" (without extension), I appreciate if someone can confirm this to me.
3. - I have not been able to print the vowels with accent, nor the ñÑ and others, I have tried with ENCODING in "CP1252" and "WinAnsiEncoding".

Any TIP?

TIA

BestRegards 
GVS

Klas Engwall

unread,
Nov 24, 2017, 4:33:23 PM11/24/17
to harbou...@googlegroups.com
Hi GVS,
> I'm testing D:\harbour\contrib\hbhpdf\tests\harupdf.prg and I have the
> following situations:
>
> 1. - In Win7 I am good at myharu. pdf.
> 2. - In Win8, it does not generate myharu. pdf (it gives me error 0x1017
> HPDF_FILE_OPEN_ERROR 13), I have to remove the extension ". pdf" so that
> it generates the file "myharu" (without extension), I appreciate if
> someone can confirm this to me.

I don't use hbhpdf, so I cannot really comment on that. Sorry.

But is there a space character in the extension??? You write it like
that three times above. It looks very suspicious.

> 3. - I have not been able to print the vowels with accent, nor the ñÑ
> and others, I have tried with ENCODING in "CP1252" and "WinAnsiEncoding".

You don't say what your codepage in the Harbour application is. What you
do with the ENCODING settings you mentioned is to tell the PDF reader
how to interpret the characters saved in the PDF file. But you have to
first pass those characters in the correct encoding from your
application to hbhpdf.

What you have to do is make sure that the strings you pass to hbhpdf are
coded in a CP1252 compatible codepage. The easiest way to do that, if
your internal Harbour codepage is not a WIN or ISO codepage, is to use
the hb_translate() function. There are many examples of hb_translate()
usage in old messages in this group.

Regards,
Klas

Claudia Neumann

unread,
Nov 26, 2017, 4:28:47 AM11/26/17
to harbou...@googlegroups.com, gvar...@gmail.com
Hi GVS,

I can't comment on Windows, only Linux.

I print the german umlauts by using "WinAnsiEncoding" and preformating the
text with
ctext := HB_Translate( ctext , "DE850" , "DEWIN" )

HTH

Claudia
> > <javascript:>>
> >
> > > To: "Harbour Users" <harbou...@googlegroups.com <javascript:>>
> > > Sent: Tuesday, 19 de October de 2010 12:56
> > > Subject: [harbour-users] Re: HaruPDF and accented chars
> > >
> > > On 19 oct, 17:53, "Qatan" <wanstad...@gmail.com> wrote:
> > >> Hello,
> > >>
> > >> Using Harbour + GTWVT - no codepage selected.
> > >> Is there any function to convert accented chars so it will show
> >
> > corrected
> >
> > >> in PDF files generated using Haru?
> > >> Some examples: " � � � � � � � � � � � � � � � � "
> > >> Thanks for any hint
> > >>
> > >> Qatan
> > >
> > > Hi Qatan
> > >
> > > If you are using UTF8 strings, you must use
> > >
> > > HB_UTF8TOSTR()
> > >
> > > Best Regards
> > > David Monta�o.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Harbour Users" group.
> > Unsubscribe: harbour-user...@googlegroups.com <javascript:>
> > Web: http://groups.google.com/group/harbour-users
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Harbour Users" group.
> Unsubscribe: harbour-user...@googlegroups.com
> Web: http://groups.google.com/group/harbour-users
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Harbour Users" group. To unsubscribe from this group and stop receiving
> emails from it, send an email to
> harbour-user...@googlegroups.com. For more options, visit
> https://groups.google.com/d/optout.

Guillermo Varona Silupú

unread,
Nov 26, 2017, 9:40:40 AM11/26/17
to harbou...@googlegroups.com
Hi Klas, Thank you for your reply.

El 24/11/2017 a las 04:33 p.m., Klas Engwall escribió:
> Hi GVS,
>> I'm testing D:\harbour\contrib\hbhpdf\tests\harupdf.prg and I have
>> the following situations:
>>
>> 1. - In Win7 I am good at myharu. pdf.
>> 2. - In Win8, it does not generate myharu. pdf (it gives me error
>> 0x1017 HPDF_FILE_OPEN_ERROR 13), I have to remove the extension ".
>> pdf" so that it generates the file "myharu" (without extension), I
>> appreciate if someone can confirm this to me.
>
> I don't use hbhpdf, so I cannot really comment on that. Sorry.
>
> But is there a space character in the extension??? You write it like
> that three times above. It looks very suspicious.
I'm sorry for English, I use DeepL to translate.
I use DeepL to translate from Spanish to English and the translator
included the space. I always wanted to say "myharu.pdf.".

>
>> 3. - I have not been able to print the vowels with accent, nor the ñÑ
>> and others, I have tried with ENCODING in "CP1252" and
>> "WinAnsiEncoding".
>
> You don't say what your codepage in the Harbour application is.
I use this in my application:

REQUEST HB_LANG_ES
REQUEST HB_CODEPAGE_ES850M      // Code Page ES
. . .
set( _SET_CODEPAGE, "ES850M" )
hb_langSelect( "ES", "ES850M" )      // Esto es para que muestre
mensajes en español
hb_cdpSelect( "ES850M" )            // Esto lo utilizan la indexación

For editing PRG files I use HbIDE with encoding SV850.

> What you do with the ENCODING settings you mentioned is to tell the
> PDF reader how to interpret the characters saved in the PDF file. But
> you have to first pass those characters in the correct encoding from
> your application to hbhpdf.

I honestly do not understand the operation of the ENCODING.
With the configuration I have, how can I change the characters of my
application to hbhpdf?

>
> What you have to do is make sure that the strings you pass to hbhpdf
> are coded in a CP1252 compatible codepage.
How can I do this?

I have tried the following:
I have added:
. . .
REQUEST HB_CODEPAGE_UTF8EX
REQUEST HB_CODEPAGE_SV850
. . .
cTexto1 := hb_Translate( "áéíóúñѪº@¬&", "ES850M", "UTF8EX" )
cTexto2 := hb_Translate( "áéíóúñѪº@¬&", "ES850M", "SV850" )

but I can not get a correct output, in the created PDF it shows me other
characters.

With hb_OEMToANSI () it works fine for "WinAnsi", "ISO8859-9" and
"ISO8859-15" of hbhpdf.
cTexto3 := hb_OEMToANSI( "áéíóúñѪº@¬&" )
My wish is to use hb_Translate(), since hb_OEMToANSI() is obsolete.

In this context, what would be the equivalent of hb_OEMToANSI() with
hb_Translate()?

> The easiest way to do that, if your internal Harbour codepage is not a
> WIN or ISO codepage, is to use the hb_translate() function. There are
> many examples of hb_translate() usage in old messages in this group.
How can I know if my internal Harbor codepage is WIN or ISO?
Thank you very much please can you give me some examples of the use of
hb_translate () in this context.

Attached PRG file of tests. (See page 1, I do not know why the PDF
begins to be seen on page 7.)

TIA

BestRegards
GVS


harupdfx.prg

Guillermo Varona Silupú

unread,
Nov 26, 2017, 9:58:28 AM11/26/17
to harbou...@googlegroups.com
Hi Claudia:

Thank you very much, it works !!!

However I still do not understand the operation of the ENCODING, so for
the moment, while I investigate, I will only apply your TIP

TVM

BestRegards

GVS

Klas Engwall

unread,
Nov 26, 2017, 1:39:40 PM11/26/17
to harbou...@googlegroups.com
Hi Guillermo,

> Hi Klas, Thank you for your reply.
>
> El 24/11/2017 a las 04:33 p.m., Klas Engwall escribió:
>> Hi GVS,
>>> I'm testing D:\harbour\contrib\hbhpdf\tests\harupdf.prg and I have
>>> the following situations:
>>>
>>> 1. - In Win7 I am good at myharu. pdf.
>>> 2. - In Win8, it does not generate myharu. pdf (it gives me error
>>> 0x1017 HPDF_FILE_OPEN_ERROR 13), I have to remove the extension ".
>>> pdf" so that it generates the file "myharu" (without extension), I
>>> appreciate if someone can confirm this to me.
>>
>> I don't use hbhpdf, so I cannot really comment on that. Sorry.
>>
>> But is there a space character in the extension??? You write it like
>> that three times above. It looks very suspicious.
> I'm sorry for English, I use DeepL to translate.
> I use DeepL to translate from Spanish to English and the translator
> included the space. I always wanted to say "myharu.pdf.".

OK :-). Again, I don't know what might cause the error, as long as the
path is correct, you have write privileges there, and there is not
already a file with the same name that cannot be overwritten.

>>> 3. - I have not been able to print the vowels with accent, nor the ñÑ
>>> and others, I have tried with ENCODING in "CP1252" and
>>> "WinAnsiEncoding".
>>
>> You don't say what your codepage in the Harbour application is.
> I use this in my application:
>
> REQUEST HB_LANG_ES
> REQUEST HB_CODEPAGE_ES850M      // Code Page ES
> . . .
> set( _SET_CODEPAGE, "ES850M" )
> hb_langSelect( "ES", "ES850M" )      // Esto es para que muestre
> mensajes en español
> hb_cdpSelect( "ES850M" )            // Esto lo utilizan la indexación
>
> For editing PRG files I use HbIDE with encoding SV850.

SV850 is the Swedish (!) MSDOS compatible encoding. I am not sure if
that is a good idea for writing a Spanish application. Have you tried ES850?

>> What you do with the ENCODING settings you mentioned is to tell the
>> PDF reader how to interpret the characters saved in the PDF file. But
>> you have to first pass those characters in the correct encoding from
>> your application to hbhpdf.
>
> I honestly do not understand the operation of the ENCODING.
> With the configuration I have, how can I change the characters of my
> application to hbhpdf?

Characters above chr(127) have different locations in the ASCII table
depending on the standards for different languages. And some characters
that exist in one language do not exist in another language. So it is
important to use the correct codepage.

>> What you have to do is make sure that the strings you pass to hbhpdf
>> are coded in a CP1252 compatible codepage.
> How can I do this?
>
> I have tried the following:
> I have added:
> . . .
> REQUEST HB_CODEPAGE_UTF8EX
> REQUEST HB_CODEPAGE_SV850
> . . .
> cTexto1 := hb_Translate( "áéíóúñѪº@¬&", "ES850M", "UTF8EX" )
> cTexto2 := hb_Translate( "áéíóúñѪº@¬&", "ES850M", "SV850" )
>
> but I can not get a correct output, in the created PDF it shows me other
> characters.

When you tell the PDF reader to interpret the text in the PDF file as
CP1252 or WinAnsiEncoding (like you do in your HPDF_GetFont() calls),
then you must also convert the strings from your internal Harbour
codepage (the one used to display and to edit text in Harbour) to
CP1252. UTF8EX is Unicode - you do not use that, do you? And SV850 is,
as I mentioned, the Swedish MSDOS codepage. So translating from ES850 to
SV850 is not going to help. The codepage you need as the output from
hb_translate() (the 3rd argument) is ESWIN or ESMWIN or ESISO. It is
difficult for me to say which of those is the best for you, but I would
guess ESWIN.

> With hb_OEMToANSI () it works fine for "WinAnsi", "ISO8859-9" and
> "ISO8859-15" of hbhpdf.

Isn't ISO8859-9 the Turkish version???

> cTexto3 := hb_OEMToANSI( "áéíóúñѪº@¬&" )
> My wish is to use hb_Translate(), since hb_OEMToANSI() is obsolete.
>
> In this context, what would be the equivalent of hb_OEMToANSI() with
> hb_Translate()?

OEM is "slang" for 850 and 437 codepages. For MSDOS compatible
codepages, in other words. ANSI is approximately the same as ISO, or
WIN, or 1252 is Microsoft's world. The difference between OemToAnsi() /
AnsiToOem() and hb_translate() is that OemToAnsi() and AnsiToOem() do
not fully understand the differences between the various 850 codepages
like SV850 versus ES850. hb_translate() can translate between *any* two
codepages you specify.

So, provided that your internal codepage in Harbour is ES850M and you
need the strings in the PDF in ESWIN encoding, then the call is:

hb_translate( cTheString, "ES850M", "ESWIN" )

And you of course need to REQUEST both of them.

>> The easiest way to do that, if your internal Harbour codepage is not a
>> WIN or ISO codepage, is to use the hb_translate() function. There are
>> many examples of hb_translate() usage in old messages in this group.
>
> How can I know if my internal Harbor codepage is WIN or ISO?
> Thank you very much please can you give me some examples of the use of
> hb_translate () in this context.

Your internal codepage is the one you specify with set(_SET_CODEPAGE)
like in your example above at the top. If you do not set() a specific
codepage, the default EN codepage will be used.

ISO and WIN codepages are generally the same thing, but they can vary a
little. For example when it comes to "1/4" and "2/3" characters.

Regards,
Klas

Guillermo Varona Silupú

unread,
Nov 26, 2017, 6:11:52 PM11/26/17
to harbou...@googlegroups.com
Hi Klas:

Thank you very much for your patience and explanation.

hb_translate( cText, "ES850M", "ESWIN" ), Solved my problem

TVM

BestRegards

GVS

José Quintas

unread,
Nov 28, 2017, 7:38:59 AM11/28/17
to Harbour Users
I use on this way, same codepage as Windows to all:

PROCEDURE Main

   Set( _SET_CODEPAGE, "PTISO" )

...

   VAR    cCodePage         INIT "WinAnsiEncoding" // "CP1252"
...
     ::oPdf := HPDF_New()
      HPDF_SetCompressionMode( ::oPDF, HPDF_COMP_ALL )
      HPDF_SetCurrentEncoder( ::oPDF, ::cCodePage )


José M. C. Quintas

José Quintas

unread,
Nov 28, 2017, 7:48:06 AM11/28/17
to Harbour Users
Available encoders here:


José M. C. Quintas

Klas Engwall

unread,
Nov 28, 2017, 8:28:54 AM11/28/17
to harbou...@googlegroups.com
Hi José,

> I use on this way, same codepage as Windows to all:
>
> PROCEDURE Main
>
>    Set( _SET_CODEPAGE, "PTISO" )

Yes, but Guillermo is already using an 850 codepage in the application,
not an ISO one, so please don't add new confusion.

Regards,
Klas

Pritpal Bedi

unread,
Oct 23, 2020, 7:26:52 PM10/23/20
to Harbour Users
Hi Maurizio

How can box chacaters be printed in hbhpdf ? I am unable to find a codepage supporting these characters. Any clue will be appreciable.


Pritpal Bedi
a student of software analysis & concepts

Srđan

unread,
Apr 13, 2022, 12:53:05 AM4/13/22
to Harbour Users
when start program I get this. Why?
Screenshot 2022-04-13 06.51.08.png

Srđan

unread,
Apr 14, 2022, 11:05:44 AM4/14/22
to Harbour Users
Does anyone have an example of printing text with code page 1251 with HaruPDF ?
Reply all
Reply to author
Forward
0 new messages