Getting Started

Installation, Delphi and FPC setup, First program

PDF Library for Delphi is a Delphi PDF library. It is used from code by adding the library unit to your project and creating a TPDFlib instance when you need to build or modify a PDF document

Path Setting

Tell Delphi where to find the PDF Library for Delphi source files or compiled DCU files. You can set the global Library Path once, or set the Search Path for each project that uses the library

To set the global Library Path, use this Delphi menu path:

Tools -> Options -> Language -> Delphi -> Library -> Library path

For older Delphi releases this setting may appear under:

Tools -> Environment Options -> Library -> Library path

Add the installed source path or the matching compiled binary path. Examples:

%UserProfile%\Documents\losLab\PDFlibPas\Lib
%UserProfile%\Documents\losLab\PDFlibPas\Lib\37.0\Win32\Release
%UserProfile%\Documents\losLab\PDFlibPas\Lib\37.0\Win64\Release

The first path is the default source edition path. The versioned paths are examples for RAD Studio 13 Florence compiled DCUs. Use the BDS-version folder that matches your installed Delphi or C++Builder version

To set only the current project's Search Path, use:

Project -> Options -> Building -> Delphi Compiler -> Search path

For older Delphi releases this setting may appear under:

Project -> Options -> Directories/Conditionals -> Search path

Free Pascal and Lazarus on Windows

Both i386-win32 and x86_64-win64 are supported, including a Win32 compiler installation with a Win64 cross compiler

build-Lazarus-Lib.cmd win32
build-Lazarus-Tests.cmd win32
build-Lazarus-Demo.cmd win32
build-Lazarus-Lib.cmd win64

Use debug for a debug build and norun to build the console tests without running them; set FPC to the full path of fpc.exe when using a custom compiler installation

Compiled units are written to Lib\FPC\i386-win32 or Lib\FPC\x86_64-win64; add the matching directory and Lib\FPC\compat to the project's unit search path, use Delphi syntax mode, and keep the bundled Lib\thirdparty objects available to the linker; the Lazarus runtime package is Lib\FPC\PDFlibPasLaz.lpk

Test executables use Tests\Lazarus\bin\<target> and demo executables use each demo's bin\<target> directory; Win32 AES and JPEG 2000 use the supplied static COFF objects in Lib\thirdparty\Win32f; no codec DLL is required; Win32 uses the built-in Pascal JBIG2 encoder, including when the external encoder option is requested; the external PDFlibJBIG2EncC backend is available on Win64

Trial installations include precompiled units; run build-Lazarus-Demo-TRIAL.cmd win32 or select win64 to build the demos with the matching compiler version and target; when preparing trial binaries from the source tree, build the units first with build-Lazarus-Lib-TRIAL.cmd win32 or win64

Class and Unit Name

The main library unit is PDFlibrary.pas, or PDFlibrary.dcu in a binary package. The main class is TPDFlib

Declare the Class

PDF Library for Delphi is a Delphi library, not a VCL component. It is not installed onto the IDE component palette. Add PDFlibrary to the unit's uses clause, declare a variable of type TPDFlib, and call the Create constructor. When you are finished, call Free, normally inside a try..finally block

First PDF Library Program

Start a new VCL Forms application and add a TButton to the form. Add the PDF Library for Delphi unit to the form unit:

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics,
  Controls, Forms, Dialogs, PDFlibrary;

Double-click the button and add this event handler:

procedure TForm1.Button1Click(Sender: TObject);
var
  PDFlib: TPDFlib;
begin
  PDFlib := TPDFlib.Create;
  try
    PDFlib.DrawText(100, 500, 'Hello from Delphi');
    PDFlib.SaveToFile('.\HelloFromDelphi.pdf');
  finally
    PDFlib.Free;
  end;
end;

Complete Workflows

After the first PDF, explore the bundled Demo/Delphi, Demo/C++Builder, or Demo/Lazarus portfolio: Showcase provides a visual tour, while each domain Lab exposes specialist scenarios from one executable

Run DocumentLab --scenario DocumentInspectionWorkbench for page inventories and diagnostic reports, or supply your own PDF using the scenario's documented command-line arguments

Run ContentLab --scenario WorkflowGallery for a document delivery workflow with tables, annotations, a handover checklist, HTTP output, and saved-file verification

DLL users can start with Demo/CSharp/DLL/WorkflowWorkbench or Demo/VB.NET/DLL/WorkflowWorkbench for report generation, extraction, page composition, and binary memory transfer, or Demo/VC++/DLL/LinkDemo for verified links and navigation

Open Demo/DLL.en-us.html in the installed package for the DLL workflow catalog and architecture-specific build instructions

More Information

Use this HTML reference for detailed API documentation. You can search the navigation pane by function name, category, or topic keyword

For product news and additional information, visit the PDF Library for Delphi product page