FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index mod_harbour Create PDF in Mod_Harbour.
Posts: 408
Joined: Sun Nov 06, 2005 03:55 PM
Create PDF in Mod_Harbour.
Posted: Sun Mar 01, 2020 07: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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Create PDF in Mod_Harbour.
Posted: Mon Mar 02, 2020 07: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
Posts: 408
Joined: Sun Nov 06, 2005 03:55 PM
Re: Create PDF in Mod_Harbour.
Posted: Mon Mar 02, 2020 08:31 AM

The function returns 4133.

Thanks,

Byron Hopp

Matrix Computer Services
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Create PDF in Mod_Harbour.
Posted: Mon Mar 02, 2020 10:50 AM
Byron,

This way it works fine:
Code (fw): Select all Collapse
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
Posts: 408
Joined: Sun Nov 06, 2005 03:55 PM
Re: Create PDF in Mod_Harbour.
Posted: Mon Mar 02, 2020 05: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
Posts: 22
Joined: Mon Mar 02, 2020 12:00 AM
Re: Create PDF in Mod_Harbour.
Posted: Mon Mar 02, 2020 06: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....

Continue the discussion