Difference between revisions of "fcl-pdf"

From Lazarus wiki
Jump to navigationJump to search
Line 1: Line 1:
== Info ==
+
== About ==
 
fcl-pdf is [[PDF]] implementation.
 
fcl-pdf is [[PDF]] implementation.
  
 
The PDF generator has the following features:
 
The PDF generator has the following features:
 +
 
* Support for basic shapes.
 
* Support for basic shapes.
 
* Support for basic line styles.
 
* Support for basic line styles.
Line 20: Line 21:
 
* Output validates by several PDF validators.
 
* Output validates by several PDF validators.
  
 
 
Contains units:  
 
Contains units:  
 +
 
* fppdf
 
* fppdf
 
* fpparsettf
 
* fpparsettf
Line 27: Line 28:
 
* fpttfencodings
 
* fpttfencodings
  
 +
== Examples ==
 +
=== Writing few lines, without embedded fonts ===
 +
Example by forum member '''Moritz''', fixed by member '''paweld'''. Code disables embedding of fonts into PDF.
 +
 +
<syntaxhighlight lang="pascal">
 +
procedure TMainForm.TestButtonClick(Sender: TObject);
 +
var
 +
  FontID, FontBoldID: Integer;
 +
  Document: TPDFDocument;
 +
  Section: TPDFSection;
 +
  Page: TPDFPage;
 +
begin
 +
  Document := TPDFDocument.Create(nil);
 +
  Document.FontDirectory := 'C:\Windows\Fonts';
 +
  Document.StartDocument;
 +
  FontID := Document.AddFont('arial.ttf', 'Arial');
 +
  FontBoldID := Document.AddFont('arialbd.ttf', 'Arial Bold');
 +
 +
  Document.Options := Document.Options + [poPageOriginAtTop, poNoEmbeddedFonts];
 +
  Section := Document.Sections.AddSection;
 +
 +
  Page := Document.Pages.AddPage;
 +
  Section.AddPage(Page);
 +
 +
  Page.SetFont(FontID, 11);
 +
  Page.WriteText(20, 20, 'This is normal text');
 +
 +
  Page.SetFont(FontBoldID, 11);
 +
  Page.WriteText(20, 30, 'This is bold text');
 +
 +
  Document.SaveToFile('output.pdf');
 +
end;
 +
</syntaxhighlight>
 
== See also ==
 
== See also ==
 
* [[Package List]]
 
* [[Package List]]

Revision as of 12:31, 16 August 2023

About

fcl-pdf is PDF implementation.

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 units.
  • Rotation matrix system.
  • PDF creator information.
  • Output validates by several PDF validators.

Contains units:

  • fppdf
  • fpparsettf
  • fpttf
  • fpttfencodings

Examples

Writing few lines, without embedded fonts

Example by forum member Moritz, fixed by member paweld. Code disables embedding of fonts into PDF.

procedure TMainForm.TestButtonClick(Sender: TObject);
var
  FontID, FontBoldID: Integer;
  Document: TPDFDocument;
  Section: TPDFSection;
  Page: TPDFPage;
begin
  Document := TPDFDocument.Create(nil);
  Document.FontDirectory := 'C:\Windows\Fonts';
  Document.StartDocument;
  FontID := Document.AddFont('arial.ttf', 'Arial');
  FontBoldID := Document.AddFont('arialbd.ttf', 'Arial Bold');
 
  Document.Options := Document.Options + [poPageOriginAtTop, poNoEmbeddedFonts];
  Section := Document.Sections.AddSection;
 
  Page := Document.Pages.AddPage;
  Section.AddPage(Page);
 
  Page.SetFont(FontID, 11);
  Page.WriteText(20, 20, 'This is normal text');
 
  Page.SetFont(FontBoldID, 11);
  Page.WriteText(20, 30, 'This is bold text');
 
  Document.SaveToFile('output.pdf');
end;

See also