Native Linux and macOS
Description
For Windows 11 ARM64 and Delphi ARM64EC builds, see Windows on ARM
The native FPC backend supports headless library workflows on Linux and macOS, with separate x64 and ARM64 targets producing actual ELF and Mach-O programs; Delphi builds macOS headless dylibs for both architectures and Linux x64 programs with its Linux64 compiler
Use the existing TPDFlib API for PDF creation, saving/loading, text extraction and editing, structured extraction, portable OCR callbacks, bitmap rendering, metadata, encryption, network range access, and native PFX signing
Native platform matrix
| Platform | Native environment | Compiler route |
|---|---|---|
| Linux x64 | Ubuntu WSL 2 or a physical x64 Linux host | FPC x86_64-linux or Delphi Linux64 |
| Linux ARM64 | ARM64 Linux host or virtual machine, including Multipass | FPC aarch64-linux |
| macOS x64 | Intel Mac | Native FPC x86_64-darwin or Delphi OSX64 |
| macOS ARM64 | Apple silicon Mac | Native FPC aarch64-darwin or Delphi OSXARM64 |
Use FPC 3.3.1 with matching RTL/packages and a target that matches the operating system and architecture of your application
Runtime dependencies
| Provider | Library | Purpose |
|---|---|---|
| OpenSSL 3 | libcrypto | AES CBC/GCM, digests, PKCS12 identities, CMS signatures, integrity, and explicit trust-anchor chains |
| libcurl | libcurl with asynchronous DNS | HTTP/HTTPS, bounded binary transport, range access, and RFC 3161 requests |
| Cairo | libcairo | Bitmap image surfaces, paths, clipping, glyph outlines, and images |
| Fontconfig | libfontconfig | Actual native font-file matching, including explicit family substitution |
| libxml2 | System libxml2 on macOS; libxml2.so.16 or libxml2.so.2 on Linux | Delphi XMP XML parsing, namespace-aware editing, and serialization |
| OpenJPEG 2 | libopenjp2 | JPEG 2000 decoding and encoding |
| libjpeg-turbo | libturbojpeg.so.0 (Delphi Linux64 only) | JPEG decoding, including CMYK and YCCK images, and JPEG encoding; FPC uses its own JPEG units |
Linux x64 and ARM64 load their architecture-matched system SONAMEs; macOS ARM64 defaults to /opt/homebrew, macOS x64 defaults to /usr/local, and both use the system libcurl and libxml2
Missing libraries, symbols, or unsupported operations produce explicit failures; no Windows device-context substitute is used
Signing and time stamps
The default PFX provider supports actual RSA and EC identities, detached CMS, CAdES, and legacy attached SHA1 profiles; verification checks PDF ByteRange bytes and the CMS signature
Certificate-chain verification requires explicit trust anchors; embedded certificates do not grant trust, and integrity alone does not imply trust
ApplyPAdESSignatureTimeStamp uses the configured default native HTTP transport to fetch and attach a real RFC 3161 token; reserve enough /Contents capacity before the original signature
Time-stamp verification checks the signed token, message imprint, exclusive critical timeStamping EKU, TSA name, optional expected policy/nonce, and the trusted certificate chain at token generation time
Document time stamps also verify the actual PDF ByteRange imprint; the caller can use the existing DocTimeStamp passthrough workflow and supply the token
Metadata and rendering
The compatibility canvas exposes HandleAllocated as a read-only state query without allocating a device context or accessing a printer; unlike Handle, it is safe to use when checking whether cleanup is needed
The FPC, Delphi macOS and Delphi Linux64 XMP providers use real namespace-aware DOMs and preserve unrelated properties during edits; Delphi uses the system libxml2 parser and serializer
DTD declarations are rejected by the XML reader regardless of source encoding; input and decoded characters are bounded, and a streaming pass limits depth and node events before DOM construction
Rendering uses real native bitmap storage and Cairo image surfaces; banded rendering preserves device-space coordinates and uses guard rows to keep boundary antialiasing consistent
Native family-font embedding resolves an actual Fontconfig file and embeds a complete standalone TrueType program, or the selected TrueType face of a font collection (TTC) rebuilt as a standalone program, with CIDFontType2, Identity CIDToGIDMap, initialized metrics, and Unicode widths; BMP text and portable OCR layers survive PDF save/reload
CFF-flavoured OpenType programs and CFF faces of collections embed their CFF outlines as CIDFontType0 with FontFile3, after the same OS/2 embedding-rights checks. Without embedding (Options 0) the family resolves the same way and becomes a simple TrueType font with WinAnsiEncoding, ToUnicode and widths and descriptor metrics measured from the installed face, so the reader must supply a font of that name; a single-byte code-page suffix such as {1251} is written as /Differences over WinAnsiEncoding, while double-byte code pages and faces without a Unicode cmap are rejected. The embedding entry rejects bitmap-only embedding rights; restricted embedding requires the existing explicit rights override, and fonts that prohibit subsetting remain complete programs
Limits
- Windows device contexts, EMF, GUI, clipboard, and printing are outside the native headless backend
- Delphi Linux64 loads libcurl, libxml2 and libturbojpeg when first needed, so a missing library disables only that feature; the PDFium rendering host and the TPDFlibPrinter page redirect need Windows device contexts and report a failure
- Windows system certificate-store identities are unavailable. Without a platform shaping engine, DrawText and GetTextWidth shape complex scripts and supplementary-plane text with the GSUB and GPOS lookups of the selected font's own embedded TrueType program and show the glyphs through an Identity-H companion font, so extraction returns the source characters
- On Linux x64 the OpenType shaping engine
libPDFlibOpenType.so(shipped inLib/thirdparty/OpenType, glibc 2.38 or later, no C++ runtime dependency) gives DrawText and GetTextWidth full OpenType shaping, including Indic reordering, reph and conjunct forms, Arabic joining and mark positioning. It is loaded from the path named by thePDFLIB_OPENTYPE_ENGINEenvironment variable, from the library module directory or the executable's directory, or fromLib/thirdparty/OpenTypeabove those directories; without it the portable lookups above apply - The standalone TrueType embedding entry draws BMP text through its simple font and supplementary-plane text through the companion font described above; AddTrueTypeFontFromFile and AddOpenTypeFontFromFile also accept CFF-flavoured OpenType files on these platforms
- AddTrueTypeSubsettedFont relies on the Windows font subsetting service and returns 0 on these platforms; embed the font with AddTrueTypeFont or AddTrueTypeFontFromFile instead
- Online OCSP/CRL revocation is unavailable; requests for revocation verification report an unknown result
- When Fontconfig answers a font request with a named instance of an installed variable font, such as the bold instance of a variable family, text that uses the unembedded font is drawn from a static copy of that instance; embedding a font by family name still rejects named instances
- Without a named instance, an unembedded font substituted by an installed variable font takes its axis coordinates from the font descriptor's FontWeight, FontStretch, ItalicAngle and Italic flag
- The default native PFX provider rejects RSA-PSS and extra policy, commitment, or revocation signing attributes
- Native ICC transforms, CMYK included, need LittleCMS 2 at run time; without it ICC-based colors are shown through their alternate or matching device color spaces. Bitmap export writes 1-, 4- and 8-bit indexed BMP files with a black/white, VGA or gray/color-cube table as well as 24- and 32-bit files
- HTTP requires asynchronous DNS support in libcurl to honor DNS lookup timeouts
Compiler prerequisites
Check the selected FPC version, target CPU, and target operating system before building your application
fpc -iV
fpc -iTP
fpc -iTO
Use -n @/path/to/fpc.cfg when selecting an explicit compiler configuration; keep the RTL and package paths consistent with the compiler version and target
Do not add -FcUTF8, because it changes high-byte AnsiString handling and can corrupt binary PDF identifiers and encryption values
macOS C ABI dynamic library
See Dylib build configuration and usage for local configuration templates, the complete output matrix, deployment, C ABI ownership, and a working Python example
The 1192-entry dynamic-library export surface can be built with native Free Pascal on macOS x64 or ARM64 or cross-compiled from Windows with Delphi; both expose the same C symbol names
export FPC=/path/to/aarch64-darwin/fpc
export PDFLIB_FPC_CONFIG=/path/to/fpc.cfg
bash Dylib/Build-native.sh release full
python3 Dylib/examples/create_pdf.py Dylib/OSXARM64/FPC-release-full/libPDFlibDylib.dylib /tmp/hello-dylib.pdf
On an x64 Mac select a native x86_64-darwin compiler and use the corresponding Dylib/OSX64/FPC-release-full output path
Omit PDFLIB_FPC_CONFIG when the compiler already has a valid configuration; use debug trial for the separate trial build, or set PDFLIB_DYLIB_OUTPUT to an external output directory
The C ABI uses 32-bit opaque instance handles and UTF-16 PWideChar strings on both Intel and ARM64 systems; foreign-language bindings must supply UTF-16 code units rather than the host's native wchar_t representation
DLCreateBuffer returns writable data owned by its instance, including embedded zero bytes; DLReleaseBuffer returns 1 on success and 0 for an unknown or already released buffer, and releasing an instance invalidates all its buffers and returned strings
Instance 0 remains the default instance alias; explicit positive handles are not reused during the loaded library's lifetime, and unloading frees outstanding instances and buffers
Serialize calls that use the same instance, and serialize instance creation or release against other C ABI calls; the registry lock does not protect an instance after lookup
Delphi cross-compilation
The Windows build scripts select dccosx64 or dccosxarm64, require a local macOS SDK cache, separate full and trial output, and validate the produced Mach-O header before publishing the build output
Set PDFLIBPAS_MACOS_SDK or pass sdk path; PDFLIBPAS_MACOS_LINKER can select a Mach-O LLVM linker named ld64.lld.exe when the installed default linker cannot read the SDK's .tbd files
Delphi uses POSIX file APIs, named RCDATA resources, system zlib and libcurl, the shared native OpenSSL/Fontconfig/Cairo/OpenJPEG providers, and Apple ImageIO for JPEG images
set PDFLIBPAS_MACOS_SDK=C:\SDKs\MacOSX.sdk
set PDFLIBPAS_MACOS_LINKER=C:\LLVM\bin\ld64.lld.exe
Dylib\Build-dylib.bat osxarm64
Dylib\Build-dylib-TRIAL.bat osxarm64 debug
Dylib\Build-dylib.bat osx64
Dylib\Build-dylib-TRIAL.bat osx64 debug