[Lazarus] PDF generator

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] PDF generator

Michael Van Canneyt
Hi,

I have committed a PDF generator to FPC Subversion: fcl-pdf.

Why a new pascal PDF generator ?
Mainly because the existing ones written in Object Pascal suffer from
several disadvantages:
- Font support usually incomplete or downright buggy.
- Dependency on a GUI (LCL, VCL, Windows).
The latter is important because the PDFs must be generated on a headless (no
display) webserver.

So, the fcl-pdf package contains a PDF generating unit fppdf that does not depend
on any external libraries or GUI system.

The PDF generator has the following features:
- Support for basic shapes.
- Support for basic line styles.
- Dictionary support.
- Multi-page PDF.
- Image support.
- TTF Font support.
- Font embedding.
- Unicode font support.
- Stream Compression.
- Image embedding.
- Several paper types.
- Portrait/Landscape.
- Support for multiple measurement units.
- Rotation matrix system.
- PDF creator information.
- The generated PDF passes several PDF validators.

The library is based on a library that came with FPGUI, with a feature set
which came closest to what I desired. It was completed for the company I
work for by Graeme Geldenhuys, and is heavily unit tested.

It is not yet feature-complete, but the above should be ample for most
applications.

In the near future, I expect to commit a reporting engine which, likewise,
does not need a GUI (but can use one) and uses the PDF generator as one
possible backend.

Todo:
- Implement TFPCustomCanvas descendent (TPDFCanvas) that draws on a PDF.
   (should allow easy integration in LCL)
- Partial embedding of (unicode) fonts (only used glyphs) for smaller PDFs.
- On windows (possibly mac), allow to use native font mechanisms for extracting info from TTF files.
- Reduce memory usage by streaming finished pages to file.

Optionally:
- PDF Forms ?
- Archive format ?
- Signatures ?

Enjoy,

I would welcome additional tests/demos, suggestions, bugreports, improvements or patches.

Michael.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] PDF generator

silvioprog
On Sat, Mar 5, 2016 at 2:27 PM, Michael Van Canneyt <[hidden email]> wrote:
Hi,

I have committed a PDF generator to FPC Subversion: fcl-pdf.

Great news of this weekend.

I'm going to test that ...

Congrats for your job!

--
Silvio Clécio

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] PDF generator

silvioprog
In reply to this post by Michael Van Canneyt
On Sat, Mar 5, 2016 at 2:27 PM, Michael Van Canneyt <[hidden email]> wrote:
[...] 
Optionally:
- PDF Forms ?
- Archive format ?
- Signatures ?

- File attachments? [1]

 
--
Silvio Clécio

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] PDF generator

Michael Van Canneyt


On Sat, 5 Mar 2016, silvioprog wrote:

> On Sat, Mar 5, 2016 at 2:27 PM, Michael Van Canneyt <[hidden email]>
> wrote:
> [...]
>>
>> Optionally:
>> - PDF Forms ?
>> - Archive format ?
>> - Signatures ?
>
>
> - File attachments? [1]
>
> [1] https://github.com/libharu/libharu/blob/master/demo/attach.c

I have added it to the list in the readme file :-)

Michael.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] PDF generator

Jesus Reyes A.-2
In reply to this post by Michael Van Canneyt
En Sat, 05 Mar 2016 11:27:24 -0600, Michael Van Canneyt  
<[hidden email]> escribió:

> Hi,
>
> I have committed a PDF generator to FPC Subversion: fcl-pdf.
>
> Why a new pascal PDF generator ? Mainly because the existing ones  
> written in Object Pascal suffer from
> several disadvantages: - Font support usually incomplete or downright  
> buggy.
> - Dependency on a GUI (LCL, VCL, Windows).
> The latter is important because the PDFs must be generated on a headless  
> (no
> display) webserver.
>
> So, the fcl-pdf package contains a PDF generating unit fppdf that does  
> not depend
> on any external libraries or GUI system.
>
> The PDF generator has the following features:
> - Support for basic shapes.
> - Support for basic line styles.
> - Dictionary support.
> - Multi-page PDF.
> - Image support.
> - TTF Font support.
> - Font embedding.
> - Unicode font support.
> - Stream Compression.
> - Image embedding.
> - Several paper types.
> - Portrait/Landscape.
> - Support for multiple measurement units.
> - Rotation matrix system.
> - PDF creator information.
> - The generated PDF passes several PDF validators.
>
> The library is based on a library that came with FPGUI, with a feature  
> set
> which came closest to what I desired. It was completed for the company I
> work for by Graeme Geldenhuys, and is heavily unit tested.
>
> It is not yet feature-complete, but the above should be ample for most
> applications.
>
> In the near future, I expect to commit a reporting engine which,  
> likewise, does not need a GUI (but can use one) and uses the PDF  
> generator as one possible backend.
>
> Todo:
> - Implement TFPCustomCanvas descendent (TPDFCanvas) that draws on a PDF.
>    (should allow easy integration in LCL) - Partial embedding of  
> (unicode) fonts (only used glyphs) for smaller PDFs.
> - On windows (possibly mac), allow to use native font mechanisms for  
> extracting info from TTF files.
> - Reduce memory usage by streaming finished pages to file.
>
> Optionally:
> - PDF Forms ?
> - Archive format ?
> - Signatures ?
>
> Enjoy,
>
> I would welcome additional tests/demos, suggestions, bugreports,  
> improvements or patches.
>
> Michael.


Great, thank you!

Jesus Reyes A.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] PDF generator

Martok
In reply to this post by Michael Van Canneyt
Nice work! Certainly comes just in time as I'm looking at PDF libraries for the
next work-related project.

> - On windows (possibly mac), allow to use native font mechanisms for extracting info from TTF files.
Would using freetype/freetype2 make more sense? There are native implementations
in the CCR and the freetype2 library interface is surprisingly simple as well.

-- Sebastian

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] PDF generator

Michael Van Canneyt


On Sat, 5 Mar 2016, Martok wrote:

> Nice work! Certainly comes just in time as I'm looking at PDF libraries for the
> next work-related project.
>
>> - On windows (possibly mac), allow to use native font mechanisms for extracting info from TTF files.
> Would using freetype/freetype2 make more sense? There are native implementations
> in the CCR and the freetype2 library interface is surprisingly simple as well.

Well, I didn't want to use external libraries.

I have no idea of the state of Freetype in CCR.
Last time I checked it, it was totally incomprehensible and hopelessly outdated code.
But I certainly may be wrong there, although a quick look at e.g. ttfile.pas
is not exactly encouraging.

But nothing prevents the use of these libraries: since we need to 'abstract'
out the relevant functionality anyway for the Windows OS, a kind of
manager/driver approach such as used in other parts of the RTL is a definite possibility.

(On windows, the OS itself provides these functions, the situation is different there)

Contributions in this area are definitely welcome.

Michael.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] PDF generator

silvioprog
In reply to this post by Michael Van Canneyt
On Sat, Mar 5, 2016 at 3:19 PM, Michael Van Canneyt <[hidden email]> wrote:
On Sat, 5 Mar 2016, silvioprog wrote:
On Sat, Mar 5, 2016 at 2:27 PM, Michael Van Canneyt <[hidden email]>
wrote:
[...]

Optionally:
- PDF Forms ?
- Archive format ?
- Signatures ?


- File attachments? [1]

[1] https://github.com/libharu/libharu/blob/master/demo/attach.c

I have added it to the list in the readme file :-)

Awesome! :-)

The PDF encryption seems optionally a nice feature too, but I don't know if everyone agrees.

Here is a demo (password: owner ):


--
Silvio Clécio

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] PDF generator

aradeonas
Thank you Michael Van Canneyt.
 
Regards,
Ara
 
 
-- 
http://www.fastmail.com - A no graphics, no pop-ups email service

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] PDF generator

Roberto P.
In reply to this post by Michael Van Canneyt
Great!
Are metadata included ?

Thanks,

 R.

2016-03-05 18:27 GMT+01:00 Michael Van Canneyt <[hidden email]>:
Hi,

I have committed a PDF generator to FPC Subversion: fcl-pdf.

Why a new pascal PDF generator ? Mainly because the existing ones written in Object Pascal suffer from
several disadvantages: - Font support usually incomplete or downright buggy.
- Dependency on a GUI (LCL, VCL, Windows).
The latter is important because the PDFs must be generated on a headless (no
display) webserver.

So, the fcl-pdf package contains a PDF generating unit fppdf that does not depend
on any external libraries or GUI system.

The PDF generator has the following features:
- Support for basic shapes.
- Support for basic line styles.
- Dictionary support.
- Multi-page PDF.
- Image support.
- TTF Font support.
- Font embedding.
- Unicode font support.
- Stream Compression.
- Image embedding.
- Several paper types.
- Portrait/Landscape.
- Support for multiple measurement units.
- Rotation matrix system.
- PDF creator information.
- The generated PDF passes several PDF validators.

The library is based on a library that came with FPGUI, with a feature set
which came closest to what I desired. It was completed for the company I
work for by Graeme Geldenhuys, and is heavily unit tested.

It is not yet feature-complete, but the above should be ample for most
applications.

In the near future, I expect to commit a reporting engine which, likewise, does not need a GUI (but can use one) and uses the PDF generator as one possible backend.

Todo:
- Implement TFPCustomCanvas descendent (TPDFCanvas) that draws on a PDF.
  (should allow easy integration in LCL) - Partial embedding of (unicode) fonts (only used glyphs) for smaller PDFs.
- On windows (possibly mac), allow to use native font mechanisms for extracting info from TTF files.
- Reduce memory usage by streaming finished pages to file.

Optionally:
- PDF Forms ?
- Archive format ?
- Signatures ?

Enjoy,

I would welcome additional tests/demos, suggestions, bugreports, improvements or patches.

Michael.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] PDF generator

Graeme Geldenhuys-3
On 06/03/2016 07:35, Roberto P. wrote:
> Are metadata included ?

Do you mean Author, PDF Creator, Date Modified, Keywords etc
information. If so, yes that is included.

Regards,
   Graeme


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] PDF generator

leledumbo
Administrator
In reply to this post by Michael Van Canneyt
> I have committed a PDF generator to FPC Subversion: fcl-pdf

The package must be excluded from build for msdos target because its dependencies are not available for msdos, otherwise full build will fail. There are already embedded and win16 in the exclude list.
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] PDF generator

Michael Van Canneyt


On Wed, 9 Mar 2016, leledumbo wrote:

>> I have committed a PDF generator to FPC Subversion: fcl-pdf
>
> The package must be excluded from build for msdos target because its
> dependencies are not available for msdos, otherwise full build will fail.
> There are already embedded and win16 in the exclude list.

Done, rev. 33212. Thanks for testing.

Michael.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus