PdfLib on linux
PdfLib on linux
I need to generate some pdf docs and I thought I'd use the pdflib, but I've discovered that it doesn't work on Linux (the lib is missing from distribution files, and the site does'nt say anything about a linux version).
Somebody knows how to make pdflib work in linux, or what other libraries could I use instead?
Somebody knows how to make pdflib work in linux, or what other libraries could I use instead?
-
- Posts: 139
- Joined: Feb 04, 2011 20:34
- Location: Ontario, Canada
Re: PdfLib on linux
I use the CUPS-PDF virtual printer for creating PDF files on Linux. It's simple to use - just direct printed output to the virtual printer instead of a real printer.
Many of our customers prefer to receive invoices via email, so for those customers we just direct the printed output to the virtual printer, then email the PDF files to them. Our billing software didn't require any special code to handle PDF output, since it already had the ability to print to multiple printers.
Rod
Many of our customers prefer to receive invoices via email, so for those customers we just direct the printed output to the virtual printer, then email the PDF files to them. Our billing software didn't require any special code to handle PDF output, since it already had the ability to print to multiple printers.
Rod
Re: PdfLib on linux
http://free-basic.ru/
18.04.2015
It is in russian, I guess you can not read cyrilic, but you dont need it: just click 3rd link from the top.
Library is called LIBHARU follow link and save libharu.zip - and then when you download it will be in english
I don use that lib, but I tested examples and it works ...
OR
Save file as SVG () and use rsvg-convert (google it) to covert it to pdf, png etc
P.S.
HERE IS DIRECT LINK:
http://free-basic.ru/user-files/LibHaru.zip
EXAMPLE
SEE THIS
http://www.freebasic.net/forum/viewtopic.php?t=9014
18.04.2015
It is in russian, I guess you can not read cyrilic, but you dont need it: just click 3rd link from the top.
Library is called LIBHARU follow link and save libharu.zip - and then when you download it will be in english
I don use that lib, but I tested examples and it works ...
OR
Save file as SVG () and use rsvg-convert (google it) to covert it to pdf, png etc
P.S.
HERE IS DIRECT LINK:
http://free-basic.ru/user-files/LibHaru.zip
EXAMPLE
Code: Select all
'******************************************************************************
'* Program name: hpdftest
'* Version: 0.1
'*
'* Author: Copyright (c) 2008 Klaus Siebke
'* Siebke Unternehmensberatung
'* URL http://www.siebke.com
'*
'* Description:
'* -----------
'*
'* Program to test the creation of a PDF file using the Haru Free PDF Library
'*
'* License:
'* -------
'*
'* Permission to use, copy, modify, distribute and sell this software
'* and its documentation for any purpose is hereby granted without fee,
'* provided that the above copyright notice appear in all copies and
'* that both that copyright notice and this permission notice appear
'* in supporting documentation.
'* It is provided "as is" without express or implied warranty.
'*
'*
'* External libraries used by the program:
'* --------------------------------------
'*
'* << Haru Free PDF Library 2.0.8 >>
'* URL http://libharu.sourceforge.net/
'* Copyright (c) 1999-2006 Takeshi Kanno
'*
'******************************************************************************
'******************************************************************************
'* Includes for Haru Free PDF Library
'******************************************************************************
#include "crt/errno.bi"
#include "zlib.bi"
#ifndef __mod_hpdf_bi__
#define __mod_hpdf_bi__
#include once "hpdf_consts.bi"
#include once "hpdf_types.bi"
#include once "hpdf.bi"
#endif
'******************************************************************************
'* Declarations of subroutines and functions
'******************************************************************************
declare sub error_handler cdecl (byval error_no as HPDF_STATUS, byval detail_no as HPDF_STATUS, byval user_data as any ptr )
'******************************************************************************
'* Constants
'******************************************************************************
#define NULL 0
const page_title = "PDF test document"
'******************************************************************************
'* Variables
'******************************************************************************
dim shared pdf as HPDF_Doc 'ptr
dim shared fname as string * 256
dim shared page as HPDF_Page
dim shared def_font as HPDF_Font
dim shared txt_font as HPDF_Font
dim shared tw as HPDF_REAL
dim shared doc_height as HPDF_REAL
dim shared doc_width as HPDF_REAL
dim shared i as HPDF_UINT
'dim shared errno as HPDF_STATUS ptr
dim shared detno as HPDF_STATUS ptr
dim shared userdat as any ptr
'******************************************************************************
'* Begin of main program
'******************************************************************************
'print "let's go"
'let's go ... (initialize hpdf)
pdf = HPDF_New(@error_handler, NULL)
'print "after hpdf_new"
'add a new page object
page = HPDF_AddPage (pdf)
'print "after hpdf_AddPage"
doc_height = HPDF_Page_GetHeight (page)
'print "after hpdf_GetHeight"
doc_width = HPDF_Page_GetWidth (page)
'print a frame
HPDF_Page_SetLineWidth (page, .5)
HPDF_Page_Rectangle (page, 50, 50, doc_width - 100, doc_height - 110)
HPDF_Page_Stroke (page)
'print the title of the page (with positioning center) with font Helvetica
def_font = HPDF_GetFont (pdf, "Helvetica", NULL)
HPDF_Page_SetFontAndSize (page, def_font, 24)
tw = HPDF_Page_TextWidth (page, page_title)
HPDF_Page_BeginText (page)
HPDF_Page_TextOut (page, (doc_width - tw) / 2, doc_height - 50, page_title)
HPDF_Page_EndText (page)
'print some text inside the frame
HPDF_Page_BeginText (page)
'first line with font Times Roman 14
txt_font = HPDF_GetFont (pdf, "Times-Roman", NULL)
HPDF_Page_MoveTextPos (page, 60, doc_height - 105)
HPDF_Page_SetFontAndSize (page, txt_font, 14)
HPDF_Page_ShowText (page, "This is a first line")
'second line with font Courier 12
txt_font = HPDF_GetFont (pdf, "Courier", NULL)
HPDF_Page_MoveTextPos (page, 0, -20)
HPDF_Page_SetFontAndSize (page, txt_font, 12)
HPDF_Page_ShowText (page, "This is a second line")
'third line with font Symbol 16
txt_font = HPDF_GetFont (pdf, "Symbol", NULL)
HPDF_Page_MoveTextPos (page, 0, -20)
HPDF_Page_SetFontAndSize (page, txt_font, 16)
HPDF_Page_ShowText (page, "Here are some symbols")
HPDF_Page_EndText (page)
'save the document
HPDF_SaveToFile (pdf, "mydoc.pdf")
'clean up
HPDF_Free (pdf)
'******************************************************************************
'* End of main program
'******************************************************************************
sub error_handler cdecl (byval error_no as HPDF_STATUS, byval detail_no as HPDF_STATUS, byval user_data as any ptr)
'******************************************************************************
'* Error handler
'******************************************************************************
' do something here ...
print "error_no: ", error_no
print "detail_no:", detail_no
print "data: ", user_data
end Sub
SEE THIS
http://www.freebasic.net/forum/viewtopic.php?t=9014
Re: PdfLib on linux
Thank you very much. Now I'm on Windows and cannot test the library on Linux. I'll do that when I'll be home. Anyway, I have no problem in reading russian (I studied russian language at University, many many years ago).ike wrote:http://free-basic.ru/
18.04.2015
It is in russian, I guess you can not read cyrilic, but you dont need it: just click 3rd link from the top.
Library is called LIBHARU follow link and save libharu.zip - and then when you download it will be in english
I don use that lib, but I tested examples and it works ...
OR
Save file as SVG () and use rsvg-convert (google it) to covert it to pdf, png etc
P.S.
HERE IS DIRECT LINK:
http://free-basic.ru/user-files/LibHaru.zip
EXAMPLE
Code: Select all
'****************************************************************************** '* Program name: hpdftest '* Version: 0.1 '* '* Author: Copyright (c) 2008 Klaus Siebke '* Siebke Unternehmensberatung '* URL http://www.siebke.com '* '* Description: '* ----------- '* '* Program to test the creation of a PDF file using the Haru Free PDF Library '* '* License: '* ------- '* '* Permission to use, copy, modify, distribute and sell this software '* and its documentation for any purpose is hereby granted without fee, '* provided that the above copyright notice appear in all copies and '* that both that copyright notice and this permission notice appear '* in supporting documentation. '* It is provided "as is" without express or implied warranty. '* '* '* External libraries used by the program: '* -------------------------------------- '* '* << Haru Free PDF Library 2.0.8 >> '* URL http://libharu.sourceforge.net/ '* Copyright (c) 1999-2006 Takeshi Kanno '* '****************************************************************************** '****************************************************************************** '* Includes for Haru Free PDF Library '****************************************************************************** #include "crt/errno.bi" #include "zlib.bi" #ifndef __mod_hpdf_bi__ #define __mod_hpdf_bi__ #include once "hpdf_consts.bi" #include once "hpdf_types.bi" #include once "hpdf.bi" #endif '****************************************************************************** '* Declarations of subroutines and functions '****************************************************************************** declare sub error_handler cdecl (byval error_no as HPDF_STATUS, byval detail_no as HPDF_STATUS, byval user_data as any ptr ) '****************************************************************************** '* Constants '****************************************************************************** #define NULL 0 const page_title = "PDF test document" '****************************************************************************** '* Variables '****************************************************************************** dim shared pdf as HPDF_Doc 'ptr dim shared fname as string * 256 dim shared page as HPDF_Page dim shared def_font as HPDF_Font dim shared txt_font as HPDF_Font dim shared tw as HPDF_REAL dim shared doc_height as HPDF_REAL dim shared doc_width as HPDF_REAL dim shared i as HPDF_UINT 'dim shared errno as HPDF_STATUS ptr dim shared detno as HPDF_STATUS ptr dim shared userdat as any ptr '****************************************************************************** '* Begin of main program '****************************************************************************** 'print "let's go" 'let's go ... (initialize hpdf) pdf = HPDF_New(@error_handler, NULL) 'print "after hpdf_new" 'add a new page object page = HPDF_AddPage (pdf) 'print "after hpdf_AddPage" doc_height = HPDF_Page_GetHeight (page) 'print "after hpdf_GetHeight" doc_width = HPDF_Page_GetWidth (page) 'print a frame HPDF_Page_SetLineWidth (page, .5) HPDF_Page_Rectangle (page, 50, 50, doc_width - 100, doc_height - 110) HPDF_Page_Stroke (page) 'print the title of the page (with positioning center) with font Helvetica def_font = HPDF_GetFont (pdf, "Helvetica", NULL) HPDF_Page_SetFontAndSize (page, def_font, 24) tw = HPDF_Page_TextWidth (page, page_title) HPDF_Page_BeginText (page) HPDF_Page_TextOut (page, (doc_width - tw) / 2, doc_height - 50, page_title) HPDF_Page_EndText (page) 'print some text inside the frame HPDF_Page_BeginText (page) 'first line with font Times Roman 14 txt_font = HPDF_GetFont (pdf, "Times-Roman", NULL) HPDF_Page_MoveTextPos (page, 60, doc_height - 105) HPDF_Page_SetFontAndSize (page, txt_font, 14) HPDF_Page_ShowText (page, "This is a first line") 'second line with font Courier 12 txt_font = HPDF_GetFont (pdf, "Courier", NULL) HPDF_Page_MoveTextPos (page, 0, -20) HPDF_Page_SetFontAndSize (page, txt_font, 12) HPDF_Page_ShowText (page, "This is a second line") 'third line with font Symbol 16 txt_font = HPDF_GetFont (pdf, "Symbol", NULL) HPDF_Page_MoveTextPos (page, 0, -20) HPDF_Page_SetFontAndSize (page, txt_font, 16) HPDF_Page_ShowText (page, "Here are some symbols") HPDF_Page_EndText (page) 'save the document HPDF_SaveToFile (pdf, "mydoc.pdf") 'clean up HPDF_Free (pdf) '****************************************************************************** '* End of main program '****************************************************************************** sub error_handler cdecl (byval error_no as HPDF_STATUS, byval detail_no as HPDF_STATUS, byval user_data as any ptr) '****************************************************************************** '* Error handler '****************************************************************************** ' do something here ... print "error_no: ", error_no print "detail_no:", detail_no print "data: ", user_data end Sub
SEE THIS
http://www.freebasic.net/forum/viewtopic.php?t=9014
Re: PdfLib on linux
AFAIR libharu is text only.
Here's an alternative if you need graphics (no encryption in this case):
Here's an alternative if you need graphics (no encryption in this case):
Re: PdfLib on linux
I don't need graphics, except maybe for a little logo, so I think libharu is OK. The advantage is that libharu doesn't require any external dependency (dll or so).TJF wrote:AFAIR libharu is text only.
Here's an alternative if you need graphics (no encryption in this case):
I've done some short test and the only thing that doesn't work well so far is the encoding: if I write accented letters such a "é" the PDF contains a graphical character and I'm not yet been able to make libharu print correctly that letters.
Re: PdfLib on linux
That's wrong. libharu is an external dependency itself, while cairo is part of each LINUX distribution with GTK desktop (like GNOME, XFCE, LXDE, ...).tinycla wrote: The advantage is that libharu doesn't require any external dependency (dll or so).
I checked it, meanwhile libharu can handle graphics. The advantage is, it can encrypt pages (for security).
The disadvantage is that you have to start a PDF viewer to show the result. Instead, cairo can output on screen, in a vector graphic file, or in a pixel image -- it's just one line of code to direct the output.
In case of cairo you have to compile against pango-cairo for special characters. libharu may need pango for those characters (just a guess).tinycla wrote: ... if I write accented letters such a "é" the PDF contains a graphical character
Re: PdfLib on linux
It's true that on Linux Cairo is already installed, but I'm developing a program that has to be run both on Linux and on Windows, and in Windows for using Cairo you have to install GTK (if I'm not wrong). On the other hand, I've been asked to make a program that can be run from an USB stick and doesn't require installation of other software on that computer.TJF wrote:That's wrong. libharu is an external dependency itself, while cairo is part of each LINUX distribution with GTK desktop (like GNOME, XFCE, LXDE, ...).tinycla wrote: The advantage is that libharu doesn't require any external dependency (dll or so).
I checked it, meanwhile libharu can handle graphics. The advantage is, it can encrypt pages (for security).
The disadvantage is that you have to start a PDF viewer to show the result. Instead, cairo can output on screen, in a vector graphic file, or in a pixel image -- it's just one line of code to direct the output.
In case of cairo you have to compile against pango-cairo for special characters. libharu may need pango for those characters (just a guess).tinycla wrote: ... if I write accented letters such a "é" the PDF contains a graphical character
But I'm interested in trying Cairo. I've take a look at the example, but my first impression is that it is more complicated and its use is mora for graphics than for textual report. But this impression could be erroneaus, so I'm ready to take a deeper look if someone could tell me where to find in-depth tutorial on creating pdf docs with Cairo. I didn't find many examples of that.
-
- Posts: 252
- Joined: Mar 12, 2006 16:25
Re: PdfLib on linux
Well, if you dont want external dependencies just use the static version of the library. Even for GTK you can build a static version and use it for windows.
Re: PdfLib on linux
For Cairo Windows you need 5 dll's in a folder, and run any test code you have from the same folder;
http://www.mediafire.com/download/ui41t ... /Cairo.zip
The .bi file is included in the folder.
http://www.mediafire.com/download/ui41t ... /Cairo.zip
The .bi file is included in the folder.
Re: PdfLib on linux
Well, very interesting, but it's not what I looked for. I need a way to produce PDF docs, almost exclusively containing text infos. The only graphic element will be a logo image, but this is optional. I know that Cairo can produce PDF, but is it well suited for producing the reports I need?dodicat wrote:For Cairo Windows you need 5 dll's in a folder, and run any test code you have from the same folder;
http://www.mediafire.com/download/ui41t ... /Cairo.zip
The .bi file is included in the folder.
The big problem is that I can find only examples on how to draw images, but if I want to produce text, maybe with column and intests, how could I do? Maybe it's not the right tool for my program.