The Synopse PDF engine features:

  • Create PDF documents containing text, graphics, and bitmaps;
  • Use a TCanvas instance to draw the page content with your VCL code, just as usual (you can even use the Handle property of the TCanvas to use low level GDI commands);
  • Automatic document Compression;
  • Embed JPG or BMP/GIF/PNG pictures (bitmaps are compressed into the PDF content);
  • You can draw any EMF file or TMetaFile instance, which will be converted to vectorial;
  • Fully handle Unicode text content;
  • Embed TrueType fonts, as a whole, or as a subset (i.e. only used glyphs are stored into the PDF);
  • Easily add outlines or change page format;
  • PDF file content generation is very fast: after profiling, it appears that the creation time is mostly spent in compression, not in content generation;
  • Works in Delphi 7 up to 2010;
  • Whole engine is only one unit (i.e. no external dll is required), and doesn't require our SQLite3 database framework;
  • Freeware Opensource unit, licensed under a MPL/GPL/LGPL tri-license.
It's fully tested with Delphi 7. I need your feedback with Delphi 2009/2010.

There are two ways of using this framework.

1. Either directly (using the Canvas property, and its associated methods):
  with TPdfDocument.Create do
try
AddPage;
Canvas.SetFont('georgia',12,[fsItalic,fsBold]);
Canvas.TextOut(100,700,'Synopse PDF Engine Test');
Canvas.TextOut(100,680,'Testé en Français');
SaveToFile('testdirect.pdf');
finally
Free;
end;
Here is the resulting file: testdirect.pdf

2. Either by using a TCanvas, and VCL standard code:
  with TPdfDocumentGDI.Create do
try
for i := 1 to 9 do begin
AddPage;
with VCLCanvas do begin
Font.Name := 'Times new roman';
Font.Size := 150;
Font.Style := [fsBold,fsItalic];
Font.Color := clNavy;
TextOut(100,100,'Page '+IntToStr(i));
end;
end;
SaveToFile('testvcl.pdf');
finally
Free;
end;
Here is the resulting file: testvcl.pdf

Of course, both way of creating the PDF content can be used at the same time in your code, without any problem.

You can download the full source code of this unit, with other needed Synopse units, from synpdf.zip licensed under a MPL/GPL/LGPL tri-license.

Luiz Américo has made some sample code about Unicode, which can be downloaded from here.

I'm some kind of proud about this code, especially the fast low level CMAP4/TrueType part (for getting Unicode chars and their widths), the great TrueType subsetting trick (which works under XP and later, for once Micro$oft provided some useful API), and the way the TCanvas/EMF/TMetaFile features are implemented. Feedback welcome!