Create PDF in Mod_Harbour.

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!

Create PDF in Mod_Harbour.

Postby byron.hopp » Sun Mar 01, 2020 7:22 pm

Is there any samples of printing to pdf using harupdf lib. I tried the TPdf print class from my newest version of Harbour but this does not work. I then created the code below by using the functions used in the class:

function main()
local hPdf := HPDF_New()
local hPage := HPDF_AddPage( hPdf )
HPDF_Page_BeginText( hPage )
HPDF_Page_TextOut( hPage,10,10,"Hello PDF" )
HPDF_Page_EndText( hPage )
HPDF_SaveToFile ( hPdf, "Hello.pdf" )
return NIL

This runs without errors, but cannot find the hello.pdf anywhere on the server.
Thanks,
Byron
Thanks,
Byron Hopp
Matrix Computer Services
byron.hopp
 
Posts: 382
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA

Re: Create PDF in Mod_Harbour.

Postby Antonio Linares » Mon Mar 02, 2020 7:43 am

Byron,

Please change this line this way:

? HPDF_SaveToFile ( hPdf, "Hello.pdf" )

and lets see what return code you get
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Create PDF in Mod_Harbour.

Postby byron.hopp » Mon Mar 02, 2020 8:31 am

The function returns 4133.
Thanks,
Byron Hopp
Matrix Computer Services
byron.hopp
 
Posts: 382
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA

Re: Create PDF in Mod_Harbour.

Postby Antonio Linares » Mon Mar 02, 2020 10:50 am

Byron,

This way it works fine:
Code: Select all  Expand view
function main()

   local hPdf := HPDF_New()
   local hPage := HPDF_AddPage( hPdf )

   HPDF_Page_SetFontAndSize( hPage, HPDF_GetFont( hPdf, "Helvetica" ), 24 )

   HPDF_Page_BeginText( hPage )
   HPDF_Page_TextOut( hPage, 10, 10, "Hello PDF" )
   HPDF_Page_EndText( hPage )
   ? hb_NumToHex( HPDF_SaveToFile( hPdf, "c:\temp\Hello.pdf" ) )

return nil


You can check the error codes here:
https://github.com/harbour/core/blob/master/contrib/hbhpdf/3rd/libhpdf/hpdferro.h
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Create PDF in Mod_Harbour.

Postby byron.hopp » Mon Mar 02, 2020 5:24 pm

I pasted this code into my program and run. The ? hb_NumToHex( HPDF_SaveToFile( hPdf, "c:\temp\Hello.pdf" ) ) returns 0, there is a Temp directory on my c: drive but no file is created. I am using IIS version of Mod_Harbour.

Thanks,
Thanks,
Byron Hopp
Matrix Computer Services
byron.hopp
 
Posts: 382
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA

Re: Create PDF in Mod_Harbour.

Postby luiscambuston » Mon Mar 02, 2020 6:11 pm

Byron,

Try replacing c:\temp with c:\inetpub\wwwroot or the folder that your application is running or a sub folder under that....
luiscambuston
 
Posts: 22
Joined: Mon Mar 02, 2020 12:00 am


Return to mod_harbour

Who is online

Users browsing this forum: No registered users and 6 guests