Discussion:
LibHaru PDF creation in xHarbour
(too old to reply)
hot.eye
2012-01-06 13:40:19 UTC
Permalink
Hi all,

I've been playing around and I can get a pdf created, but no text on
it.

My code is based on the HaruPDF.prg source from the Harbour sample.

I have put the dll file and Arial.ttf in the working directory. The
fact it
is making a pdf means that it is loading the dll and calling it.

I have tried changing the paper size to A5 and orientation those
changes are
reflected in the pdf as Acrobat shows the page size.

Any ideas why no text is appearing? Do I need to pass some parameters
by
reference, if so how is that done in the dll calls?

Am I on the right track? Has anybody got it to work? What did I miss?

Kind regards
Philip

dllPDF:=LoadLibrary('libhpdf.dll')

if dllPDF>0

pdf := PDF_New()

IF pdf == NIL
alert( " Pdf could not been created!" )
RETURN NIL
ENDIF

PDF_SetCompressionMode( pdf, HPDF_COMP_ALL )
PDF_SetPageMode(pdf, HPDF_PAGE_MODE_USE_OUTLINE)

page := HPDF_AddPage(pdf)
PDF_Page_SetSize (page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT)
height := PDF_Page_GetHeight(page)
width := PDF_Page_GetWidth(page)

font_Arial:=PDF_LoadTTFontFromFile( pdf, 'Arial.ttf', HPDF_TRUE)
def_font := PDF_GetFont( pdf, font_Arial, 'StandardEncoding' )

PDF_Page_SetFontAndSize( page, def_font, 12 )
PDF_Page_SetRGBFill(page, 0, 0, 0)

PDF_Page_BeginText( page )
for i:=1 to 1000 step 100
HPDF_Page_TextOut( page, i, i, alltrim(str(i)) )
next
PDF_Page_EndText( page )

PDF_SaveToFile( pdf, cFileToSave )

PDF_Free( pdf )
endif


//----------------------------------------------------------------------//

// wrapper functions to call a DLL loaded above

function PDF_New
return DllCall(dllPDF, DC_CALL_CDECL, "HPDF_New")


function PDF_SetCompressionMode( pdf, xMode )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_SetCompressionMode', pdf,
xMode )


function PDF_AddPage(pdf)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_AddPage', pdf)


function PDF_Page_GetHeight(page)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_GetHeight', page)


function PDF_Page_GetWidth(page)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_GetWidth', page)


function PDF_GetFont( pdf, cFont, cCodePage )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_GetFont', pdf, cFont,
cCodePage )


function PDF_Page_SetFontAndSize( page, def_font, nSize )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_SetFontAndSize',
page,
def_font, nSize )


function PDF_Page_TextWidth( page, page_title )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_TextWidth', page,
page_title )


function PDF_Page_SetSize (page, nPageSize, nOrientation)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_SetSize', page,
nPageSize,
nOrientation)


function PDF_Page_BeginText( page )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_BeginText', page )


function PDF_Page_TextOut( page, nWidth, nHeight, page_title )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_TextOut', page,
nWidth,
nHeight, page_title )


function PDF_Page_EndText( page )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_EndText', page )


function PDF_LoadTTFontFromFile( pdf, cFilename, lEmbed)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_LoadTTFontFromFile', pdf,
cFilename, lEmbed)


function PDF_Page_MoveTextPos( page, nX, nY )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_MoveTextPos', page,
nX,
nY )


function PDF_SaveToFile( pdf, cFileToSave )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_SaveToFile', pdf,
cFileToSave )


function PDF_Free( pdf )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Free', pdf )


function PDF_Page_ShowText( page, cFont )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_ShowText', page,
cFont )


function PDF_SetPageMode(pdf, nPageMode)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_SetPageMode', pdf,
nPageMode)


function PDF_Page_SetRGBFill(page, nR, nG, nB)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_SetRGBFill', page,
nR, nG,
nB)


//----------------------------------------------------------------------//
c***@gmail.com
2012-01-06 14:05:05 UTC
Permalink
Hi

use xharbour libharu insted of direct dll call

Regards
Luiz
Post by hot.eye
Hi all,
I've been playing around and I can get a pdf created, but no text on
it.
My code is based on the HaruPDF.prg source from the Harbour sample.
I have put the dll file and Arial.ttf in the working directory. The
fact it
is making a pdf means that it is loading the dll and calling it.
I have tried changing the paper size to A5 and orientation those
changes are
reflected in the pdf as Acrobat shows the page size.
Any ideas why no text is appearing? Do I need to pass some parameters
by
reference, if so how is that done in the dll calls?
Am I on the right track? Has anybody got it to work? What did I miss?
Kind regards
Philip
dllPDF:=LoadLibrary('libhpdf.dll')
if dllPDF>0
   pdf :=  PDF_New()
   IF pdf == NIL
      alert( " Pdf could not been created!" )
      RETURN NIL
   ENDIF
   PDF_SetCompressionMode( pdf, HPDF_COMP_ALL )
   PDF_SetPageMode(pdf, HPDF_PAGE_MODE_USE_OUTLINE)
   page := HPDF_AddPage(pdf)
   PDF_Page_SetSize (page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT)
   height := PDF_Page_GetHeight(page)
   width  := PDF_Page_GetWidth(page)
   font_Arial:=PDF_LoadTTFontFromFile( pdf, 'Arial.ttf', HPDF_TRUE)
   def_font := PDF_GetFont( pdf, font_Arial, 'StandardEncoding' )
   PDF_Page_SetFontAndSize( page, def_font, 12 )
   PDF_Page_SetRGBFill(page, 0, 0, 0)
   PDF_Page_BeginText( page )
   for i:=1 to 1000 step 100
      HPDF_Page_TextOut( page, i, i, alltrim(str(i)) )
   next
   PDF_Page_EndText( page )
   PDF_SaveToFile( pdf, cFileToSave )
   PDF_Free( pdf )
endif
//----------------------------------------------------------------------//
// wrapper functions to call a DLL loaded above
function PDF_New
return DllCall(dllPDF, DC_CALL_CDECL, "HPDF_New")
function PDF_SetCompressionMode( pdf, xMode )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_SetCompressionMode', pdf,
xMode )
function PDF_AddPage(pdf)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_AddPage', pdf)
function PDF_Page_GetHeight(page)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_GetHeight', page)
function PDF_Page_GetWidth(page)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_GetWidth', page)
function PDF_GetFont( pdf, cFont, cCodePage )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_GetFont', pdf, cFont,
cCodePage )
function PDF_Page_SetFontAndSize( page, def_font, nSize )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_SetFontAndSize',
page,
def_font, nSize )
function PDF_Page_TextWidth( page, page_title )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_TextWidth', page,
page_title )
function PDF_Page_SetSize (page, nPageSize, nOrientation)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_SetSize', page,
nPageSize,
nOrientation)
function PDF_Page_BeginText( page )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_BeginText', page )
function PDF_Page_TextOut( page, nWidth, nHeight, page_title )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_TextOut', page,
nWidth,
nHeight, page_title )
function PDF_Page_EndText( page )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_EndText', page )
function PDF_LoadTTFontFromFile( pdf, cFilename, lEmbed)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_LoadTTFontFromFile', pdf,
cFilename, lEmbed)
function PDF_Page_MoveTextPos( page, nX, nY )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_MoveTextPos', page,
nX,
nY )
function PDF_SaveToFile( pdf, cFileToSave )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_SaveToFile', pdf,
cFileToSave )
function PDF_Free( pdf )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Free', pdf )
function PDF_Page_ShowText( page, cFont )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_ShowText', page,
cFont )
function PDF_SetPageMode(pdf, nPageMode)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_SetPageMode', pdf,
nPageMode)
function PDF_Page_SetRGBFill(page, nR, nG, nB)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_SetRGBFill', page,
nR, nG,
nB)
//----------------------------------------------------------------------//
hot.eye
2012-01-06 21:32:19 UTC
Permalink
Hi Luiz,

I didn't know there was one, where can I get it from please?

Regards
Philip
Post by c***@gmail.com
Hi
use xharbour libharu insted of direct dll call
Regards
Luiz
dlzc
2012-01-06 14:24:02 UTC
Permalink
Post by hot.eye
Hi all,
I've been playing around and I can get a pdf created, but
no text on it.
My code is based on the HaruPDF.prg source from the Harbour sample.
There may be the problem. Harbour has tended to set itself apart from
xHarbour (and its own roots, for that matter).

Did you try the PDF creation sample programs provided with xHarbour?

David A. Smith
hot.eye
2012-01-06 21:57:46 UTC
Permalink
Post by hot.eye
Hi all,
I've been playing around and I can get a pdf created, but
no text on it.
My code is based on the HaruPDF.prg source from the Harbour sample.
There may be the problem.  Harbour has tended to set itself apart from
xHarbour (and its own roots, for that matter).
Did you try the PDF creation sample programs provided with xHarbour?
David A. Smith
Hi David,

Thanks for replying. I didn't know there was a PDF creation sample
programs provided with xHarbour?

Where should I look and what's it called?

Regards
Philip
Mel Smith
2012-01-07 00:31:34 UTC
Permalink
Post by hot.eye
Hi David,
Thanks for replying. I didn't know there was a PDF creation sample
programs provided with xHarbour?
Where should I look and what's it called?
Philip:

The library libharu.lib is included with Build 9420 which I made
available in a posting a few days ago. (Download it at www.whosaway.com with
a password: 'XHB'

The source code is contained in \xharbour\contrib\hbhpdf and its
...\tests\ sub-directory

--
Mel Smith
hot.eye
2012-01-07 23:05:48 UTC
Permalink
Post by hot.eye
Hi David,
Thanks for replying. I didn't know there was a PDF creation sample
programs provided with xHarbour?
Where should I look and what's it called?
    The library libharu.lib  is included with Build 9420 which I made
available in a posting a few days ago. (Download it atwww.whosaway.comwith
a password: 'XHB'
    The source code is contained in \xharbour\contrib\hbhpdf  and its
...\tests\ sub-directory
--
Mel Smith
Thanks Mel for a Saturday response.

But I still cannot link LIBHARU.LIB as I use XCC compiler supplied
with XHarbour and it says:
xLINK: fatal error: Corrupt library: '.\libharu.lib'.

Also, there is no CONTRIB directory in either of the 9420 zip files.
Could you make an XCC version, or send source and instructions so I
can make the lib?

Regards, Philip
Mel Smith
2012-01-08 16:42:31 UTC
Permalink
Philip said:

But I still cannot link LIBHARU.LIB as I use XCC compiler supplied
with XHarbour and it says:
xLINK: fatal error: Corrupt library: '.\libharu.lib'.

Also, there is no CONTRIB directory in either of the 9420 zip files.
Could you make an XCC version, or send source and instructions so I
can make the lib?

Philip:

Sorry to mislead you :)

What I have done now is to add an extra download to the alternate site.
This download includes the complete Contrib sub-directory.

So, please got to www.whosaway.com, and enter the Password 'XHB' and
look for the Contrib download (separate from the binary, and source
downloads).

Hope you (and others) find this useful.

-Mel Smith
hot.eye
2012-01-09 00:08:28 UTC
Permalink
Post by hot.eye
But I still cannot link LIBHARU.LIB as I use XCC compiler supplied
xLINK: fatal error: Corrupt library: '.\libharu.lib'.
Also, there is no CONTRIB directory in either of the 9420 zip files.
Could you make an XCC version, or send source and instructions so I
can make the lib?
    Sorry to mislead you :)
    What I have done now is to add an extra download to the alternate site.
This download includes the complete Contrib sub-directory.
    So, please got towww.whosaway.com, and enter the Password 'XHB'  and
look for the Contrib download (separate from the binary, and source
downloads).
    Hope you (and others) find this useful.
-Mel Smith
Hi Mel,

I did download that file, but what do I do with it?

My knowledge of C is not sufficient to get it to compile to a lib. I
use the xHarbour supplied XCC as the C compiler and there appears not
to be a batch file to make it.

Sorry to be a pain but how do I make a LIB file I can link into my
program?

Then I tried adding all the C files to my Builder project. It then
complained about PNG, so I added those from the contrib. Then it
wanted zlib so I found zlib125 and added those C files.

This is wherre I get stuck as the errors, to me, are serious:


Type: C >>>xcc.exe -Fo"compiler\PNGRTRAN.obj" -Ot -I"\novlib
\include" -I"s:\medcl\xharbour\include" -I"S:\XSOURCE\HBHPDF" -I"S:
\XSOURCE\zlib-1.2.5" -I"C:\xHB\include" -I"c:\xhb\c_include" -I"c:\xhb
\c_include\win" -I"c:\xhb\c_include\msvc" "S:\XSOURCE\hbhpdf
\PNGRTRAN.C"<<<

S:\XSOURCE\hbhpdf\PNGRTRAN.C(1278): warning: Missing prototype for
'_snprintf'.

can't spill register variable: esi (1) sp
S:\XSOURCE\hbhpdf\PNGRTRAN.C(3524): fatal error: Internal error:
best_spillee.


Type: C >>>Couldn't build: PNGRTRAN.obj<<<
Type: C >>>TMAKEOBJECT<<<
Type: C >>>TMAKEOBJECT:REFRESH<<<
Type: N >>> 1423<<<

Thanks in advance for your continued help.

Philip
Mel Smith
2012-01-09 04:02:10 UTC
Permalink
Phillip said:

Hi Mel,

I did download that file, but what do I do with it?

My knowledge of C is not sufficient to get it to compile to a lib. I
use the xHarbour supplied XCC as the C compiler and there appears not
to be a batch file to make it.

Sorry to be a pain but how do I make a LIB file I can link into my
program?

**************************
Hi Phillip:

I'm sorry , but I'm a 'simple tranport truck driver' :). I can deliver
the goods -- but I don't know how to assemble them :(((

Perhaps someone else here can help you with your problem. David Smith
(my brilliant compatriot here in Arizona) is probably your best bet !)

-Mel
**************************


Then I tried adding all the C files to my Builder project. It then
complained about PNG, so I added those from the contrib. Then it
wanted zlib so I found zlib125 and added those C files.

This is wherre I get stuck as the errors, to me, are serious:


Type: C >>>xcc.exe -Fo"compiler\PNGRTRAN.obj" -Ot -I"\novlib
\include" -I"s:\medcl\xharbour\include" -I"S:\XSOURCE\HBHPDF" -I"S:
\XSOURCE\zlib-1.2.5" -I"C:\xHB\include" -I"c:\xhb\c_include" -I"c:\xhb
\c_include\win" -I"c:\xhb\c_include\msvc" "S:\XSOURCE\hbhpdf
\PNGRTRAN.C"<<<

S:\XSOURCE\hbhpdf\PNGRTRAN.C(1278): warning: Missing prototype for
'_snprintf'.

can't spill register variable: esi (1) sp
S:\XSOURCE\hbhpdf\PNGRTRAN.C(3524): fatal error: Internal error:
best_spillee.


Type: C >>>Couldn't build: PNGRTRAN.obj<<<
Type: C >>>TMAKEOBJECT<<<
Type: C >>>TMAKEOBJECT:REFRESH<<<
Type: N >>> 1423<<<

Thanks in advance for your continued help.

Philip
dlzc
2012-01-09 14:01:06 UTC
Permalink
Post by hot.eye
Hi Mel,
I did download that file, but what do I do with it?
My knowledge of C is not sufficient to get it to compile
to a lib. I use the xHarbour supplied XCC as the C
compiler and there appears not to be a batch file to
make it.
Sorry to be a pain but how do I make a LIB file I can
link into my program?
**************************
    I'm sorry , but I'm a 'simple tranport truck driver' :).
I can deliver the goods -- but I don't know how to
assemble them :(((
    Perhaps someone else here can help you with your
problem. David Smith (my brilliant compatriot here in
Arizona) is probably your best bet !)
Blush<
I am little better than a search engine here. It seems to me, the
entire CVS package would have to be built, as in make_all.bat or
something like it. Pretty sure things won't work right if you don't.
Hopefully Luiz can chime in if this is incorrect, or incomplete.

If it isn't in the commercial package, I cannot yet do it (and I am a
year out-of-date on that).

Sorry.

David A. Smith
c***@gmail.com
2012-01-09 14:35:40 UTC
Permalink
Hi simples As

first download http://libharu.org/files/libharu-2.1.0-vc8-x86.zip

install in c:\haru

copy c:\haru\lib_dll\*.dll to you app folder
copy c:\haru\lib_dll\*.lib to your xharbour lib folder
then do
cd\xharbour\contrib\hbhpdf
xbuild haru.lib harupdf.c -I\haru\include

link in your app
haru.lib libhpdf.lib

Regards
Luiz
Post by hot.eye
Hi Mel,
I did download that file, but what do I do with it?
My knowledge of C is not sufficient to get it to compile
to a lib. I use the xHarbour supplied XCC as the C
compiler and there appears not to be a batch file to
make it.
Sorry to be a pain but how do I make a LIB file I can
link into my program?
**************************
    I'm sorry , but I'm a 'simple tranport truck driver' :).
I can deliver the goods -- but I don't know how to
assemble them :(((
    Perhaps someone else here can help you with your
problem. David Smith (my brilliant compatriot here in
Arizona) is probably your best bet !)
Blush<
I am little better than a search engine here.  It seems to me, the
entire CVS package would have to be built, as in make_all.bat or
something like it.  Pretty sure things won't work right if you don't.
Hopefully Luiz can chime in if this is incorrect, or incomplete.
If it isn't in the commercial package, I cannot yet do it (and I am a
year out-of-date on that).
Sorry.
David A. Smith
hot.eye
2012-01-10 10:49:41 UTC
Permalink
Hi Luiz,

Thank you for the reply, however, it's not working on my system.

I have followed your instructions and when I run the xbuild command I
get the following errors:

Type: C >>>xcc.exe -Fo"harupdf.obj" -Ot -I"C:\xhb\include" -I"C:\xhb
\c_include" -I"C:\xhb\c_include\win" -I"C:\xhb\c_include\msvc"
"harupdf.c"<<<

harupdf.c(154): error: Type error in argument 2 to 'hb_fsNameConv';
found 'int *' expected 'char * *'.
harupdf.c(154): error: Operands of = have illegal types 'unsigned char
*' and 'const char *'.

harupdf.c(319): error: Type error in argument 2 to 'hb_fsNameConv';
found 'int *' expected 'char * *'.
harupdf.c(319): error: Operands of = have illegal types 'unsigned char
*' and 'const char *'.

harupdf.c(321): error: Type error in argument 2 to 'hb_fsNameConv';
found 'int *' expected 'char * *'.
harupdf.c(321): error: Operands of = have illegal types 'unsigned char
*' and 'const char *'.

harupdf.c(337): error: Type error in argument 2 to 'hb_fsNameConv';
found 'int *' expected 'char * *'.
harupdf.c(337): error: Operands of = have illegal types 'unsigned char
*' and 'const char *'.

harupdf.c(350): error: Type error in argument 2 to 'hb_fsNameConv';
found 'int *' expected 'char * *'.
harupdf.c(350): error: Operands of = have illegal types 'unsigned char
*' and 'const char *'.

Type: C >>>Couldn't build: harupdf.obj<<<


This is the file:
Directory of C:\xHB\contrib\hbhpdf
06/09/2008 10:20 73,174 harupdf.c

I'll copy a few of the lines for your reference.
154 BYTE * pszFileName = hb_fsNameConv( ( BYTE * ) hb_parc( 2 ),
&fFree );
319 BYTE * pszFileName1 = hb_fsNameConv( ( BYTE * ) hb_parc( 2 ),
&fFree1 );
321 BYTE * pszFileName2 = hb_fsNameConv( ( BYTE * ) hb_parc( 3 ),
&fFree2 );
337 BYTE * pszFileName = hb_fsNameConv( ( BYTE * ) hb_parc( 2 ),
&fFree );
350 BYTE * pszFileName = hb_fsNameConv( ( BYTE * ) hb_parc( 2 ),
&fFree );

I changed the BYTE to char, and in the lines just befor this, but I
don't know much about C :-(

Any help on this one?

I found this in HBAPIFS.H
extern HB_EXPORT const char * hb_fsNameConv( const char * szFileName,
char ** pszFree );

but t didn't help me :-(

Thanks, Philip.
c***@gmail.com
2012-01-10 14:39:06 UTC
Permalink
Philip,

What is your xbuilder version?

Regards
Luiz
Post by hot.eye
Hi Luiz,
Thank you for the reply, however, it's not working on my system.
I have followed your instructions and when I run the xbuild command I
Type: C >>>xcc.exe -Fo"harupdf.obj" -Ot   -I"C:\xhb\include" -I"C:\xhb
\c_include" -I"C:\xhb\c_include\win" -I"C:\xhb\c_include\msvc"
"harupdf.c"<<<
harupdf.c(154): error: Type error in argument 2 to 'hb_fsNameConv';
found 'int *' expected 'char * *'.
harupdf.c(154): error: Operands of = have illegal types 'unsigned char
*' and 'const char *'.
harupdf.c(319): error: Type error in argument 2 to 'hb_fsNameConv';
found 'int *' expected 'char * *'.
harupdf.c(319): error: Operands of = have illegal types 'unsigned char
*' and 'const char *'.
harupdf.c(321): error: Type error in argument 2 to 'hb_fsNameConv';
found 'int *' expected 'char * *'.
harupdf.c(321): error: Operands of = have illegal types 'unsigned char
*' and 'const char *'.
harupdf.c(337): error: Type error in argument 2 to 'hb_fsNameConv';
found 'int *' expected 'char * *'.
harupdf.c(337): error: Operands of = have illegal types 'unsigned char
*' and 'const char *'.
harupdf.c(350): error: Type error in argument 2 to 'hb_fsNameConv';
found 'int *' expected 'char * *'.
harupdf.c(350): error: Operands of = have illegal types 'unsigned char
*' and 'const char *'.
Type: C >>>Couldn't build: harupdf.obj<<<
Directory of C:\xHB\contrib\hbhpdf
06/09/2008  10:20            73,174 harupdf.c
I'll copy a few of the lines for your reference.
154   BYTE * pszFileName = hb_fsNameConv( ( BYTE * ) hb_parc( 2 ),
&fFree );
319   BYTE * pszFileName1 = hb_fsNameConv( ( BYTE * ) hb_parc( 2 ),
&fFree1 );
321   BYTE * pszFileName2 = hb_fsNameConv( ( BYTE * ) hb_parc( 3 ),
&fFree2 );
337   BYTE * pszFileName = hb_fsNameConv( ( BYTE * ) hb_parc( 2 ),
&fFree );
350   BYTE * pszFileName = hb_fsNameConv( ( BYTE * ) hb_parc( 2 ),
&fFree );
I changed the BYTE to char, and in the lines just befor this, but I
don't know much about C :-(
Any help on this one?
I found this in HBAPIFS.H
extern HB_EXPORT const char * hb_fsNameConv( const char * szFileName,
char ** pszFree );
but t didn't help me :-(
Thanks, Philip.
hot.eye
2012-01-10 17:01:55 UTC
Permalink
Hi Luiz,

XHarbour version: xHarbour build 1.2.1 Intl. (SimpLex) (Rev. 6726)
xBuild Wizard Version: 4.5 Dated Aug 3 2010 05:26:24

If I upgrade to latest do you know if Mediator will still be OK?
Meditor: 4.3.3.1
Meditor (client patch): 32.3
Meditor server version: 4 : 3 :

That is the only external (to XHarbour) lib I use.

Which XHarbour version should I use, latest released version I
presume?
These are the versions showing on the XHarbour downloads page:
xHarbour Builder Professional for Windows ( November-2011-
Build1119 )
Visual xHarbour Professional for Windows ( Build December-24-2011
v3.0.025 ) (New beta today!)

Regards, Philip
TmBlues
2012-10-09 05:48:42 UTC
Permalink
I've exactly the same problem here trying to compile harupdf.c

harupdf.c(154): error: Type error in argument 2 to 'hb_fsNameConv';
found 'int *' expected 'char * *'.
harupdf.c(154): error: Operands of = have illegal types 'unsigned char
*' and 'const char *'.

and so on...

Did anyone manage to compile this file? I'm using the latest commercial (non-beta) xHarbour-version? Or could someone send me haru.lib by email. I just wanna try if this tool is useful for me and already spend so much time trying to get it work. :(

Thierry
Mel Smith
2012-10-09 15:10:29 UTC
Permalink
Post by TmBlues
I've exactly the same problem here trying to compile harupdf.c
harupdf.c(154): error: Type error in argument 2 to 'hb_fsNameConv';
found 'int *' expected 'char * *'.
harupdf.c(154): error: Operands of = have illegal types 'unsigned char
*' and 'const char *'.
and so on...
Did anyone manage to compile this file? I'm using the latest commercial
(non-beta) xHarbour-version? Or could someone send me haru.lib by email. I
just wanna try if this tool is useful for me and already spend so much
time trying to get it work. :(
Thierry:

I've sent libharu.dbf (wrapped in a .zip file) to you a few minutes ago.
And I've noted it is the latest version made during build 9733.

-Mel
j***@gmail.com
2012-10-09 17:41:44 UTC
Permalink
Hi Mel.

Would you send me same file ?

Thank you in advance.
Alex
Mel Smith
2012-10-09 23:23:42 UTC
Permalink
Hi Alex:

I'm sending you a new libharu.lib file -- but for Build 9734 which I
just completed

-Meel
Post by j***@gmail.com
Hi Mel.
Would you send me same file ?
Thank you in advance.
Alex
Alex
2012-10-10 00:23:20 UTC
Permalink
Post by Mel Smith
I'm sending you a new libharu.lib file -- but for Build 9734 which I
just completed
-Meel
Hi Mel.
Sorry , didn't get any file yet ,I was in a process of adding google groups to account, that's why I think email wasn't delivered.
Would you mind to recend it now.
Alex
Thierry
2012-10-10 06:43:40 UTC
Permalink
Post by Mel Smith
I've sent libharu.dbf (wrapped in a .zip file) to you a few minutes ago.
And I've noted it is the latest version made during build 9733.
-Mel
Fantastic! Thank you Mel (and Andi, who also sent me a working lib!) :)

Thierry
Alex
2012-10-10 22:27:50 UTC
Permalink
Post by Thierry
Post by Mel Smith
I've sent libharu.dbf (wrapped in a .zip file) to you a few minutes ago.
And I've noted it is the latest version made during build 9733.
-Mel
Fantastic! Thank you Mel (and Andi, who also sent me a working lib!) :)
Thierry
Hi Thierry.
Would you mind to send me a copy? Have same problem.
Alex
Andi Jahja
2012-10-11 03:44:03 UTC
Permalink
Hello Alex,

If you are working with XCC, here is a link to the library:

http://www.mediafire.com/?g3hse3s0b0h4d33

libharu.lib for XCC will not available in Mel's site.

Andi

On Wed, 10 Oct 2012 15:27:50 -0700 (PDT), Alex
Post by Alex
Post by Thierry
Post by Mel Smith
I've sent libharu.dbf (wrapped in a .zip file) to you a few minutes ago.
And I've noted it is the latest version made during build 9733.
-Mel
Fantastic! Thank you Mel (and Andi, who also sent me a working lib!) :)
Thierry
Hi Thierry.
Would you mind to send me a copy? Have same problem.
Alex
j***@gmail.com
2012-10-09 21:38:47 UTC
Permalink
Post by c***@gmail.com
Hi simples As
first download http://libharu.org/files/libharu-2.1.0-vc8-x86.zip
install in c:\haru
copy c:\haru\lib_dll\*.dll to you app folder
copy c:\haru\lib_dll\*.lib to your xharbour lib folder
then do
cd\xharbour\contrib\hbhpdf
xbuild haru.lib harupdf.c -I\haru\include
link in your app
haru.lib libhpdf.lib
Regards
Luiz
Hi.
step1:
Have everything done as you stated.
Trying to compile with xBuilder have an error "couldn't build file"
and one warning : harupdf.c 248 expected pragma argument to be void function(viod).

step 2:
Found that .h files in libharu-2.1.0-vc8-x86.zip are different on date and size comparing to xharbour\contrib\hbhpdf folder , those are 2012 and those one in a zip file are 2008.
thus have all 2012 files deleted , library rebuild , and then got a bunch of errors , from where I have decided that missing some .c files.
Because there is no .c files in a libharu-2.1.0-vc8-x86.zip file , I took newer *.c files (2012 ) put it in a xharbour\contrib\hbhpdf folder and have them attached to xBuilder , after those manipulations got 5 warning s like :
hpdf_fontdef_jp.c 1048 static MSPMincyo_W_Array not Refferenced,
same for kr.c
Looks like some Japan / Korean fonts do not exists.

OK have those pdf_encoder_jp.c and pdf_encoder_kr.c and hpdf_fontdef_jp.c , hpdf_fontdef_kr.c. removed

Now I have :
warning : harupdf.c 248 expected pragma argument to be void function(viod).
error : couldn't build.

Back to step1

Any idea ?
Thank you.
Alex
c***@gmail.com
2012-01-09 14:24:31 UTC
Permalink
I´ll answer tonight where i have the source


but normaly i compile as
install http://libharu.org/files/libharu-2.1.0-vc8-x86.zip in c:\haru
cd\xharbour\contrib\hbpdf
xbuild haru.lib harupdf.c -I\haru\include
copy haru.lib to your xharbour lib folder

copy libhpdf.dll libpng13.dll zlib.dll to the same place of your .dll
copy libhpdf.lib to your xharbour\lib folder

link with
xbuild source haru.lib libhpdf.lib

Regards
Luiz
Post by hot.eye
Hi Mel,
I did download that file, but what do I do with it?
My knowledge of C is not sufficient to get it to compile to a lib. I
use the xHarbour supplied XCC as the C compiler and there appears not
to be a batch file to make it.
Sorry to be a pain but how do I make a LIB file I can link into my
program?
**************************
    I'm sorry , but I'm a 'simple tranport truck driver' :).  I can deliver
the goods -- but I don't know how to assemble them :(((
    Perhaps someone else here can help you with your problem. David Smith
(my brilliant compatriot here in Arizona) is probably your best bet !)
-Mel
**************************
Then I tried adding all the C files to my Builder project. It then
complained about PNG, so I added those from the contrib. Then it
wanted zlib so I found zlib125 and added those C files.
Type: C >>>xcc.exe -Fo"compiler\PNGRTRAN.obj" -Ot   -I"\novlib
\XSOURCE\zlib-1.2.5" -I"C:\xHB\include" -I"c:\xhb\c_include" -I"c:\xhb
\c_include\win" -I"c:\xhb\c_include\msvc" "S:\XSOURCE\hbhpdf
\PNGRTRAN.C"<<<
S:\XSOURCE\hbhpdf\PNGRTRAN.C(1278): warning: Missing prototype for
'_snprintf'.
can't spill register variable: esi (1) sp
best_spillee.
Type: C >>>Couldn't build: PNGRTRAN.obj<<<
Type: C >>>TMAKEOBJECT<<<
Type: C >>>TMAKEOBJECT:REFRESH<<<
Type: N >>>      1423<<<
Thanks in advance for your continued help.
Philip
fatfat
2012-10-10 01:31:27 UTC
Permalink
we are using pdfactivex.dll (free) /abcpdf (commerical) to produce pdf from
xharbour for over 3 years :p:

"hot.eye" 在郵件張貼內容主旨
b16c50e3-5ef9-4430-90b3-***@t16g2000vba.googlegroups.com 中撰寫...

Hi all,

I've been playing around and I can get a pdf created, but no text on
it.

My code is based on the HaruPDF.prg source from the Harbour sample.

I have put the dll file and Arial.ttf in the working directory. The
fact it
is making a pdf means that it is loading the dll and calling it.

I have tried changing the paper size to A5 and orientation those
changes are
reflected in the pdf as Acrobat shows the page size.

Any ideas why no text is appearing? Do I need to pass some parameters
by
reference, if so how is that done in the dll calls?

Am I on the right track? Has anybody got it to work? What did I miss?

Kind regards
Philip

dllPDF:=LoadLibrary('libhpdf.dll')

if dllPDF>0

pdf := PDF_New()

IF pdf == NIL
alert( " Pdf could not been created!" )
RETURN NIL
ENDIF

PDF_SetCompressionMode( pdf, HPDF_COMP_ALL )
PDF_SetPageMode(pdf, HPDF_PAGE_MODE_USE_OUTLINE)

page := HPDF_AddPage(pdf)
PDF_Page_SetSize (page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT)
height := PDF_Page_GetHeight(page)
width := PDF_Page_GetWidth(page)

font_Arial:=PDF_LoadTTFontFromFile( pdf, 'Arial.ttf', HPDF_TRUE)
def_font := PDF_GetFont( pdf, font_Arial, 'StandardEncoding' )

PDF_Page_SetFontAndSize( page, def_font, 12 )
PDF_Page_SetRGBFill(page, 0, 0, 0)

PDF_Page_BeginText( page )
for i:=1 to 1000 step 100
HPDF_Page_TextOut( page, i, i, alltrim(str(i)) )
next
PDF_Page_EndText( page )

PDF_SaveToFile( pdf, cFileToSave )

PDF_Free( pdf )
endif


//----------------------------------------------------------------------//

// wrapper functions to call a DLL loaded above

function PDF_New
return DllCall(dllPDF, DC_CALL_CDECL, "HPDF_New")


function PDF_SetCompressionMode( pdf, xMode )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_SetCompressionMode', pdf,
xMode )


function PDF_AddPage(pdf)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_AddPage', pdf)


function PDF_Page_GetHeight(page)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_GetHeight', page)


function PDF_Page_GetWidth(page)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_GetWidth', page)


function PDF_GetFont( pdf, cFont, cCodePage )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_GetFont', pdf, cFont,
cCodePage )


function PDF_Page_SetFontAndSize( page, def_font, nSize )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_SetFontAndSize',
page,
def_font, nSize )


function PDF_Page_TextWidth( page, page_title )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_TextWidth', page,
page_title )


function PDF_Page_SetSize (page, nPageSize, nOrientation)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_SetSize', page,
nPageSize,
nOrientation)


function PDF_Page_BeginText( page )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_BeginText', page )


function PDF_Page_TextOut( page, nWidth, nHeight, page_title )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_TextOut', page,
nWidth,
nHeight, page_title )


function PDF_Page_EndText( page )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_EndText', page )


function PDF_LoadTTFontFromFile( pdf, cFilename, lEmbed)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_LoadTTFontFromFile', pdf,
cFilename, lEmbed)


function PDF_Page_MoveTextPos( page, nX, nY )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_MoveTextPos', page,
nX,
nY )


function PDF_SaveToFile( pdf, cFileToSave )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_SaveToFile', pdf,
cFileToSave )


function PDF_Free( pdf )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Free', pdf )


function PDF_Page_ShowText( page, cFont )
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_ShowText', page,
cFont )


function PDF_SetPageMode(pdf, nPageMode)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_SetPageMode', pdf,
nPageMode)


function PDF_Page_SetRGBFill(page, nR, nG, nB)
return DllCall(dllPDF, DC_CALL_CDECL, 'HPDF_Page_SetRGBFill', page,
nR, nG,
nB)


//----------------------------------------------------------------------//
Loading...