Unit MainForm;

{$I ..\..\..\Lib\PDFlibDefines.inc}

Interface

Uses
{$IFDEF XE2+}
  Winapi.Windows,
  Winapi.ShellAPI,
  System.Classes,
  Vcl.Controls,
  Vcl.StdCtrls,
  Vcl.Forms,
{$ELSE}
  Windows,
  ShellAPI,
  Classes,
  Controls,
  StdCtrls,
  Forms,
{$ENDIF}
  PDFlibrary;

Type
  TForm1 = Class(TForm)
    Button1: TButton;
    Procedure Button1Click(Sender: TObject);
  Private
    { Private declarations }
  Public
    { Public declarations }
  End;

Var
  Form1: TForm1;

Implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  i, j, YPos: Integer;
begin

  with TPDFlib.Create do
  try
    SetOrigin(1);
    AddTrueTypeFont('Calibri {1250}', 0);

    for j := 1 to 200 do
    begin
      SelectPage(j);
      YPos := 30;
      for i := 1 to 48 do
      begin
        YPos := YPos + 15;
        DrawText(50, YPos, 'Polish Text: przyjęcie materiału - AddTrueTypeFont, Windows-1250 Central/Eastern European');
      end;
      NewPage;
    end;
    CompressContent;
    SaveToFile('AddTrueTypeFont.pdf');
  finally
    Free;
  end;

  with TPDFlib.Create do
  try
    SetOrigin(1);
    AddSubsettedFont('Calibri', 16, 'AĄBCĆDEĘFGHIJKLŁMNŃOÓPRSŚTUVWXYZŹŻaąbcćdeęfghijklłmnńoóprsśtuvwxyzźż0123456789`~!@#$%^&*()-_=+[{]}\|;:",<.>/?' +#9#32#39 );
    //AddTrueTypeSubsettedFont('Calibri', 'ACEFPTWacdeęhijlłmnoprstuwxyz0125`-:,/' + #32, 1);
    for j := 1 to 200 do
    begin
      SelectPage(j);
      YPos := 30;
      for i := 1 to 48 do
      begin
        YPos := YPos + 15;
        DrawText(50, YPos, 'Polish Text: przyjęcie materiału - AddTrueTypeFont, Windows-1250 Central/Eastern European');
      end;
      NewPage;
    end;
    CompressContent;
    SaveToFile('TrueTypeSubsettedFont.pdf');
  finally
    Free;
  end;
end;

// AddTrueTypeSubsettedFont adds each character as an object to the PDF, so the size even a bit larger, but this method is faster. 
// In real-world PDF documents, the size difference is not that significant.
// Refer to this sample project: a 200-page pure text document size increase will less than double.
// Compressing content before saving file can significantly reduce the document size.

End.
