Create PDF in Mod_Harbour.

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!
Post Reply
byron.hopp
Posts: 254
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA
Contact:

Create PDF in Mod_Harbour.

Post by byron.hopp »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Create PDF in Mod_Harbour.

Post by Antonio Linares »

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
byron.hopp
Posts: 254
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA
Contact:

Re: Create PDF in Mod_Harbour.

Post by byron.hopp »

The function returns 4133.
Thanks,
Byron Hopp
Matrix Computer Services
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Create PDF in Mod_Harbour.

Post by Antonio Linares »

Byron,

This way it works fine:

Code: Select all

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/ma ... hpdferro.h
regards, saludos

Antonio Linares
www.fivetechsoft.com
byron.hopp
Posts: 254
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA
Contact:

Re: Create PDF in Mod_Harbour.

Post by byron.hopp »

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
luiscambuston
Posts: 21
Joined: Mon Mar 02, 2020 12:00 am

Re: Create PDF in Mod_Harbour.

Post by luiscambuston »

Byron,

Try replacing c:\temp with c:\inetpub\wwwroot or the folder that your application is running or a sub folder under that....
Post Reply