Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-03

PDF generator

13 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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.

Reply by email

silvioprog
to Michael Van Canneyt: I have committed a PDF generator to FPC Subversion: fcl-pdf. Why a new pascal PDF…

On Sat, Mar 5, 2016 at 2:27 PM, Michael Van Canneyt wrote:
[...]

Show quoted text 5 lines
Optionally: - PDF Forms ? - Archive format ? - Signatures ?

- File attachments? [1]

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

Silvio Cl?cio -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160305/763b47dd/attachment.html>

Reply by email

Jesus Reyes A.
to Michael Van Canneyt: I have committed a PDF generator to FPC Subversion: fcl-pdf. Why a new pascal PDF…

En Sat, 05 Mar 2016 11:27:24 -0600, Michael Van Canneyt escribi?:

Show quoted text 66 lines
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.

Reply by email

Martok
to Michael Van Canneyt: I have committed a PDF generator to FPC Subversion: fcl-pdf. Why a new pascal PDF…

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

Reply by email

Michael Van Canneyt
to Martok
Martok wrote 6 lines
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 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.

Reply by email

silvioprog
to Michael Van Canneyt: I have added it to the list in the readme file :-) Michael.
Michael Van Canneyt wrote 21 lines
On Sat, 5 Mar 2016, silvioprog wrote: > On Sat, Mar 5, 2016 at 2:27 PM, Michael Van Canneyt < > > > 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 ):

https://github.com/libharu/libharu/raw/master/demo/encryption.pdf

Silvio Cl?cio -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160305/c7b17bf9/attachment.html>

Reply by email

Roberto P.
to Michael Van Canneyt: I have committed a PDF generator to FPC Subversion: fcl-pdf. Why a new pascal PDF…

Great!
Are metadata included ?

Thanks,

R.

2016-03-05 18:27 GMT+01:00 Michael Van Canneyt :

Show quoted text 72 lines
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 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160306/0ee95fea/attachment-0002.html>

Reply by email

leledumbo
to Michael Van Canneyt: I have committed a PDF generator to FPC Subversion: fcl-pdf. Why a new pascal PDF…
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.

View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-PDF-generator-tp4047578p4047658.html Sent from the Free Pascal - Lazarus mailing list .

Reply by email

Michael Van Canneyt
to leledumbo
leledumbo wrote 5 lines
> 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.

Reply by email