Core Components
- TPdf - Main PDF document handling component for opening, navigating, extracting text, and editing PDF documents
- TPdfView - Visual component for displaying and interacting with PDF pages
- TPdfThumbnailView - Scrollable thumbnail side panel for page navigation
Document Operations
- Document Loading - Load PDF files from disk, memory streams, byte arrays, or on-demand TStream adapters via
LoadCustomDocument. PDFium reads blocks on demand so multi-GB documents and remote / database-backed sources do not need an up-front in-memory copy.- Password Protection - Open password-protected PDF documents and report effective
UserPermissionsfor the authenticated session- Document Creation - Build new PDF documents from scratch with
CreateDocument,AddPage,AddText,AddImage,AddPicture,AddJpegImage, andCreatePath- Document Saving - Save modified documents with various options (incremental, remove security) and explicit PDF target versions from PDF 1.0 through PDF 1.7
- PDF/A-1b Output -
SaveAsPdfA/SaveAsPdfAToStreampost-process the base save with an incremental update that injects an XMP metadata stream, an sRGB ICC OutputIntent, and an updated document catalog so the result is PDF/A-1b conformant. Custom ICC profiles are supported throughTPdfASaveOptions.IccProfileData.- PDF/A Validation -
ValidatePdfAand the read-onlyPdfAConformanceproperty scan an open document for XMPpdfaidmarkers, OutputIntent with embedded ICC, encryption presence, and report the conformance level (pac1a,pac1b,pac2b,pac3b,pacNone, orpacUnknown) plus a list ofTPdfAValidationIssueentries describing each problem found- PDF Version Compliance Validator - When SaveAs targets PDF 1.0 through PDF 1.7 the writer rejects any dictionary entry, filter, annotation subtype, action type, font, colour space, or encryption parameter introduced after the chosen target version (e.g. JBIG2Decode, MarkInfo, OutputIntents, AES / AES-256, Polygon / Caret / Watermark / Redact annotations, JavaScript / Trans / SetState actions)
- Stream Compression - Automatic FlateDecode compression ensures all PDF streams are optimally compressed when saving; set
Compressed := Falseto opt out for debug pipelines- Document Merging - Import pages from other PDF documents
- Page Subset Import -
ImportPagesByIndexcopies an explicit zero-based index array from a source document, with InsertAt = 0 to insert before page 1 or InsertAt = PageCount to append. Pass an empty index array to import every source page.- N-up Composition -
ImportNPagesToOnereturns a brand-newTPdfwhose pages are NumX×NumY composites of the source document's pages, sized in PDF user units (1 unit = 1/72 in)- Page Reordering -
MovePagesreorders pages in place using a zero-based index array and a destination index for the first moved page- Form XObject Page Reuse -
CreateXObjectFromPagemanufactures a reusableTPdfXObjecthandle from any page of another document;InsertFormObjectFromXObjectinserts ONE copy of the wrapped page into the current page. Ideal for watermarks, template overlays, and "stamp one page onto many" workflows. The destination page object can be positioned, scaled, and rotated throughFPDFPageObj_SetMatrixand theTPdfMatrixhelpers.- Page Management - Add, delete, and manipulate individual pages;
AddPage(0, ...)inserts the very first page and activates it immediately- Page Boxes - Read and write MediaBox, CropBox, BleedBox, TrimBox, and ArtBox on the current page
- Catalog Language - Read and write the document language stored in the catalog /Lang entry
- Trailer File IDs - Read permanent and changing trailer /ID entries as binary bytes
- Document JavaScript Actions - Enumerate document-level JavaScript name-tree action names and scripts
- Tagged PDF Structure Tree - Inspect logical structure elements, accessibility text, language, marked-content IDs, and hierarchy for tagged PDF pages
- Viewer Preferences - Read
PrintCopies,PrintPageRanges,PrintScaling, andPrintPaperHandlingfrom the document's viewer-preference dictionary; saved PDFs default to a Fit Height first-page open action
Text Operations
- Text Extraction - Extract text from PDF pages with character-level precision via
Text,TextInRectangle, indexedCharacter,CharacterRectangle, andCharacterOriginproperties- Text Search - Find text with case-sensitive, whole word, and consecutive search options using
FindFirst,FindNext,FindPrevious- Search Highlight Overlay -
TPdfView.HighlightSearchTextscans the current view page and paints a real alpha-blendedHighlightColoroverlay over every match on each redraw, returning the match count.ClearHighlightremoves the overlay; navigating to a different page clears it automatically because matches are page-specific.HighlightColordefaults toclYellowand is published so applications can theme it.- Character Properties - Access font size, weight, angle, and positioning for individual characters with the
CharacterAngle,CharacterFontSize,CharacterFontWeight,CharacterGenerated,CharacterIsHyphen, andCharacterMapErrorindexed properties- European Character Support -
AddTextautomatically loads and caches the matching system TrueType font before creating a text object, so accented Czech, French, German, Spanish, Portuguese, Polish, and Turkish characters that PDFium's built-in standard fonts cannot represent now render correctly without any code change- Text Addition - Add new text to PDF pages with custom fonts, colours, transparency, and rotation
- Text Object Positioning - Set per-character positions for existing text objects through
SetTextPositionsandTPdfSingleArray- Font Information - Retrieve font properties including family name, embedding status, italic angle, ascent / descent, and raw font data on a per-page-object basis
Annotation Support
- Annotation Types - Support for text, link, highlight, underline, strikeout, and many other annotation types
- Annotation Creation - Create new annotations programmatically
- Annotation Editing - Modify existing annotation properties including colour, transparency, and content
- Link Annotations - Handle internal and external links with action support
Form Support
- Form Types - Support for AcroForm and XFA forms
- Form Fill - Interactive form filling with JavaScript support
- V8 DLL Selection - Set
EnableV8Enginebefore loading to usepdfium.v8.dllfrom the matchingDLLs\Win32orDLLs\Win64folder and query V8/XFA helper availability viaV8FeaturesAvailable,XfaBStrHelpersAvailable, andGetRecommendedV8Flags- Field Access - Read and write form field values by index or position
- Field Information - Access field type, flags, name, and other properties
- Field Flags - Update AcroForm field flags by index or position through
SetFormFieldFlags/SetFormFieldFlagsAt, including read-only, required, password, and multi-select flags- Form Flattening -
GenerateFormAppearancesregenerates the /AP appearance stream for every form widget on every page, andFlattenPage/FlattenAllPagesbake annotations and form fields into static page content (non-editable)- Form Widget Text Selection & Undo / Redo - On the focused AcroForm widget the view exposes
GetSelectedFormText(currently selected text),SelectAllFormText(select every character), andFormUndo/FormRedo/FormCanUndo/FormCanRedo(drive PDFium's per-widget edit history). All six short-circuit safely when the view is inactive or no widget is focused.
Image Operations
- Image Extraction - Extract bitmaps from PDF pages with the indexed
Bitmapproperty; iterateBitmapCountto save every image to disk- JPEG Insertion -
AddJpegImagetakes a TStream of raw JPEG bytes and embeds the image as a /DCTDecode XObject without re-encoding- Picture Support -
AddPictureaccepts aTPictureobject with automatic format conversion through the registered VCL/LCL graphic classes- Direct Image Insertion -
AddImage(FileName)recognises any format registered with the VCL or LCL graphics units (BMP, PNG via PngImage, JPG, ...) and shares the AddPicture pipeline.AddImage(TBitmap)skips the TPicture intermediary, which simplifies callers that already hold a TBitmap from rendering or batch generation work.- Image ICC Profile - Image page objects expose their embedded ICC profile data when present (binding for
FPDFImageObj_GetIccProfileDataDecoded)- Thumbnail Generation - Generate page thumbnail bitmaps via the
Thumbnailproperty
Helper Units
- Async Infrastructure -
FPdfAsyncexposesIPdfCancellationToken/IPdfCancellationTokenSourcefor cooperative cancel-from-UI semantics, a reusablePdfNoCancellationTokensingleton, and a lightweightTPdfFuture<T>helper that runs a worker on a background thread and posts aTPdfFutureResult<T>envelope back to the main thread, distinguishing success, cancellation, and failure cases- Stream Adapter -
TPdfStreamAdapterbridges a PascalTStreamto PDFium'sFPDF_FILEACCESScallbacks soLoadCustomDocumentreads blocks on demand instead of buffering the entire PDF in memory- Matrix Composition -
FPdfMatrixwraps PDFium'sFS_MATRIXwith an OO API forTranslate,Scale,Rotate,HorizontalFlip,VerticalFlip,CentralFlip,Skew, andMultiply.Multiplysnapshots the six matrix elements before computing the new row values, avoiding the alternative-Pascal-implementation pitfall where earlier elements get overwritten during the same call and produce incorrect compositions.- Cancellable Progressive Rendering -
TPdf.RenderPageProgressivedrives PDFium'sFPDF_RenderPageBitmap_Start+RenderPage_Continueloop and polls anIPdfCancellationTokenbetween iterations via theIFSDK_PAUSEcallback so long high-DPI renders can abort mid-page instead of blocking until completion. Returns aTPdfProgressiveStatusofprsDone,prsCancelled, orprsFailed.- Zero-Copy Render Path -
RenderPage/RenderTile/RenderPageProgressivewrite PDFium output directly into the destinationTBitmap's DIB buffer instead of staging through an internal buffer, saving one width × height × 4 bytes memory copy per render - most noticeable at high DPI (thumbnail panels, print-quality export, batch export). A per-scanline fallback path is preserved when the destination DIB cannot be wrapped safely.
Drawing Operations
- Path Drawing - Create paths with lines, Bezier curves, and closed shapes
- Object Removal - Remove page objects and regenerate page content from TPdf or TPdfView
- Fill and Stroke - Configure fill mode, colours, transparency, and stroke properties
- Blend Modes - Support for various PDF blend modes
- Line Styles - Configure line cap, line join, and stroke width
Digital Signatures
- Signature Detection - Detect and enumerate digital signatures in PDF documents
- Signature Information - Access signature contents, byte range, sub-filter, reason, and time
- MDP Permissions - Query document modification detection and prevention permissions
Attachment Support
- Attachment Access - Read, create, modify, and delete embedded file attachments
- Attachment Names - Access attachment filenames
- Attachment Types - Read embedded file MIME subtype values when present
- Bookmarks - Navigate document bookmarks with hierarchical support via the
Bookmarksarray,BookmarkChildren,HasBookmarkChildren, andBookmarkFromtraversal helpers- Named Destinations - Access named destinations by index or name through
Destination,DestinationByName, andDestinationCount- Page Labels - Retrieve page labels for each page via
PageLabel; useful when documents use Roman numerals for front matter- Web Links - Detect and navigate web links on pages with
WebLink,WebLinkCount, andTPdfView.WebLinkAtPos- Link Annotations - Access link annotations with action and destination information through
LinkAnnotation,LinkAnnotationCount, andTPdfView.LinkAnnotationAtPos- Safe Link Click Handling - TPdfView raises
OnAnnotationLinkClick/OnWebLinkClickevents before automatic goto / URI handling, with launch actions disabled by default. Link click detection runs only when the gesture is a click rather than a drag, using a fresh MouseDown anchor so panning gestures still flow through the existing scroll path unchanged.
Rendering
- High-Quality Rendering - Render pages to device context, bitmap, or tile through
RenderPage/RenderTile, with zero-copy direct writes into the destination DIB buffer- Cancellable Progressive Rendering -
RenderPageProgressivedrives PDFium's progressive loop and polls anIPdfCancellationTokenbetween iterations, returningprsDone,prsCancelled, orprsFailed. The bitmap holds the partial work done so far when cancelled.- Render Options - LCD text optimisation (
reLcd), annotations (reAnnotations), greyscale, and printing mode flags- Skia Hooks - Low-level
FPDF_RenderPageSkiaandFPDF_FFLDrawSkiabindings are available when callers provide an external SkCanvas (depends on bundled DLL exports)- Print Mode Selection - Set EMF, text-only, PostScript, pass-through, image-mask, and Type 42 PDFium print modes via
SetPdfPrintModewithTPdfPrintMode- Async Overlay - TPdfView can display an opt-in loading overlay while application-owned workers render with separate TPdf instances
- Page Rotation - Support for 0, 90, 180, and 270 degree rotation (
ro0,ro90,ro180,ro270)- Transparency Detection -
Transparentproperty reports whether any object on the current page has transparency, including blend modes and partial alpha
Viewing (TPdfView)
- Display Modes -
dmSingleContinuous,dmTwoPageContinuous, anddmTwoPageContinuousWithCover(the cover page stands alone, then continues with two-page spreads). The unit-levelComputeSpreadPageshelper exposes the spread-page math without instantiating a viewer.- Fit Mode -
FitModechooses how the page sits in the viewport:pfmNone(manual zoom),pfmActualSize(100%),pfmFitPage(whole page fits in the viewport), andpfmFitWidth(page width matches viewport width). The active fit mode is re-applied automatically on Resize and when the current page changes; setting Zoom directly cancels the active fit mode (FitMode reverts topfmNone), matching the standard PDF viewer convention.- Zoom Control - Variable zoom with
PageZoom,PageWidthZoom,PageHeightZoom, andActualSizeZoomper-page helpers- Page Colour -
PageColordecouples the rendered PDF page background from the surrounding control'sColor. Default isclWhite, so PDF pages now render as paper-white regardless of the host application's theme. Dark-mode viewers can keep the scroll area dark while leaving the actual PDF page white (or any colour the application picks).- Interactive Text Selection - End-user drag-to-select text on PDF pages, with hit-test auto-switching between selection and pan: clicking on a character starts a selection drag, clicking on whitespace pans. Double-click selects the word, triple-click selects the line,
Ctrl+Aselects the page (both pages in spread mode),Ctrl+Ccopies asCF_UNICODETEXT,Shift+arrowsextend selection, hover over text switches the cursor tocrIBeam, and dragging into a viewer edge auto-scrolls the page. New publishedSelectionColorandOnSelectionChange; new publicHasSelection,SelectedText,SelectionCharCount,ClearSelection,SelectAll,CopySelectionToClipboard. Spread display modes select across both visible pages with CR/LF joining. A default right-click Copy popup is auto-attached when the host has not assigned its ownPopupMenu. Gated by the v1.17.0AllowUserTextSelectionflag for kiosk hosts.- Coordinate Mapping - Convert between viewer device coordinates and PDF page coordinates with
DeviceToPage/PageToDevice, including overloads that take aTRectand return aTPdfRectangle- Text Selection and Hit Testing - Resolve characters under viewer points with
CharacterIndexAtPosand paint text selection highlights viaPaintSelection- Mouse & Keyboard - Full input device support with mouse drag scrolling, PgUp / PgDn / Ctrl+Home / Ctrl+End shortcuts, and wheel-up / wheel-down page navigation. Ctrl+wheel is reserved for application zoom and skipped by the navigation handler.
- User Input Lock-Down -
AllowUserPageChangecontrols keyboard page shortcuts,ChangePageOnMouseScrollingcontrols wheel page jumps, andAllowUserTextSelectioncontrols mouse / keyboard text-selection input. All three default to True; flip them False to lock down kiosks, preview panes, or read-only embeddings without subclassing.- Async Render Overlay -
AsyncRendering,LoadingText, andLoadingColordraw a small "Loading..." indicator over the rendered page so applications using their own worker for long renders share a consistent visual affordance. Defaults preserve existing behaviour.TPdfnow serialises render and page-unload calls per instance; applications still own worker dispatch and must avoid mutating a document while a render is in flight.- Safe Link Click Handling -
LinkOptionsis a published set that controls automatic behaviour for the four PDF link action types:loAutoGoto(page jump),loAutoOpenURI(ShellExecute),loAutoLaunch(ShellExecute), andloAutoEmbeddedGoto(reserved). Defaults enableloAutoGotoandloAutoOpenURIonly;loAutoLaunchandloAutoEmbeddedGotostay off so a stray click cannot run an arbitrary program.OnAnnotationLinkClickandOnWebLinkClickfire before any automatic action and let the application mark the event Handled or redirect it.- Form Interaction - Interactive form editing within the viewer, plus the v1.23.0 selection / Undo / Redo helpers
- Visual Styling -
PageShadowSize,PageShadowColor, andPageBorderColorpaint an optional drop shadow under the page rectangle and a one-pixel border around it;SmoothScrollnow animates line/page scrollbar commands in timer-driven segments while thumb tracking remains immediate- Thumbnail Navigation -
TPdfThumbnailView(unitFPdfThumbnail) renders one page thumbnail per row in a scrollable side panel with hover and selection highlighting plus click-to-go navigation. Designed to sit next to a TPdfView. Properties:CurrentPageIndex,ThumbnailWidth,ThumbnailHeight,TextColor,HoverColor,SelectionColor,BorderColor; event:OnPageClick.
Compression
- Automatic Compression - When the
Compressedproperty is True (default), all PDF streams are ensured to be FlateDecode compressed when saving- Post-Processing - The compression engine scans saved PDF data and compresses any uncompressed streams using zlib maximum compression
- Cross-Reference Rebuild - Automatically rebuilds the xref table when stream compression changes byte offsets
- Zero Overhead - If all streams are already compressed, the data passes through without modification
Security
- Password Support - Open password-protected PDF documents
- Permissions - Read document and user permissions; the
SecurityAuditdemo combines permissions, attachments, document JavaScript, URI / Launch links, signatures, XFA, and V8 availability into a read-only risk surface with TXT / JSON report save and TXT copy actions- Security Removal - Save documents with security removed (when authorized)
Printing
- Print Modes - Choose between EMF, text-only, PostScript Level 2 / 3, PostScript pass-through, EMF image-mask, and Type 42 print modes through the global
SetPdfPrintModefunction- Viewer Preferences - Surface document author intent through
PrintCopies,PrintPageRanges(one-based page ranges),PrintScaling, andPrintPaperHandling;SetPdfPrintPaperHandlingDevModemaps the duplex hint into WindowsDEVMODE.dmDuplex- N-up Printing - The Delphi, C++Builder, and Lazarus
PrintPreferencesdemos show N-up sheet composition (1 / 2 / 4 / 9 pages per sheet) with odd / even page filtering, greyscale rendering, optional 1-pixel cell borders, PDF author print preferences, and duplex intent mapping viaSetPdfPrintPaperHandlingDevMode
Shipped Demos
The
Demo\Delphi,Demo\CBuilder, andDemo\Lazarustrees ship runnable sample projects that exercise the live API surface across all three IDE families. Highlights:
- PDFViewer / MultiPageViewer / SplitView - End-to-end TPdfView usage: load, navigate, zoom, rotate, two-page spread, cover-aware layouts, and Delphi / C++Builder / Lazarus side-by-side PDF comparison with synchronized commands
- ViewerInteractionLab - Delphi, C++Builder, and Lazarus focused TPdfView interaction samples for display modes, fit modes, page colours, rotation, search highlighting, text selection, selected-text preview, clipboard actions, and DeviceToPage coordinate feedback
- SearchAndSelect - Delphi, Lazarus, and C++Builder focused workflow samples for all-page search result listing, previous / next match navigation, double-click result jumping,
HighlightSearchText, match-case / whole-word search,AllowUserTextSelection,SelectedText,SelectAll,CopySelectionToClipboard,ClearSelection, and spread display modes- PreflightReport - Delphi, Lazarus, and C++Builder workflow demos plus a Delphi console companion around reusable
FPdfPreflightReport, collecting PDF/A, PDF/UA, PDF/E, PDF/X, PDF/R, and PDF/VT validation results into status, priority, issue category, issue-category counts, next-action summary rows, issue recommendations, text / Markdown / JSON / CSV preview, TXT / HTML / Markdown / JSON / CSV reports, scriptable report generation, batch list and directory processing with report-directory routing, TXT / JSON / HTML aggregate summaries, CSV row manifests, optional report attachment embedding, and CI gating exit codes- ContentExtractionLab - Delphi, Lazarus, and C++Builder unified content inventory workflow for document metadata, page text, page objects, images, attachments, links, annotations, bookmarks, and font / character metrics with TXT / JSON export, all / none category selection, source-PDF save, and report copy actions
- WatermarkStamp - Delphi, Lazarus, and C++Builder reusable Form XObject workflow for centred watermarks, corner stamps, and page number labels across a multi-page target PDF
- CreatePDF - Build a multi-page PDF from scratch with text, images, paths, and watermark composition
- EuropeanText - Add accented Czech / French / German / Spanish / Portuguese / Polish / Turkish text using system TrueType fonts
- ExtractText / ExtractTextPages / ExtractImages / ContentExtractionLab - Save extracted text or embedded images to disk, split text into one TXT file per page, or generate a multi-category content inventory report in one pass
- FormFill - Read AcroForm field metadata, write values, regenerate /AP appearances, and save either the editable or the flattened result
- FontProperties - Inspect indexed character / font metadata through both TPdf and TPdfView in Delphi, C++Builder, and Lazarus
- MergePDF / SplitPDF - Combine multiple source PDFs or split one PDF into per-page output files
- PDFtoJpg / BatchExport - Delphi, C++Builder, and Lazarus one-shot or batched multi-file PDF to JPG conversion with per-file overall progress, per-page current progress, DPI / quality / password inputs, and a cooperatively-cancellable batch backed by
IPdfCancellationToken- StandardsLab - Delphi, C++Builder, and Lazarus workflow samples for PDF/A, PDF/UA, PDF/E, PDF/X, PDF/R, and PDF/VT validation, issue reporting, and standards-oriented save outputs
- PrintPDF / PrintPreferences - Delphi, C++Builder, and Lazarus standard PDF printing with preview, page ranges, copies, collate, progress, and cancellation (PrintPDF), plus Delphi, C++Builder, and Lazarus N-up sheet composition with odd / even filtering and PDF author print preferences (PrintPreferences)
- SecurityAudit - Delphi, C++Builder, and Lazarus read-only risk-surface samples for permissions, attachments, JavaScript actions, URI / Launch links, web links, signatures, XFA state, V8 / XFA helper availability, and TXT / JSON audit reports
- Attachment - Create PDFs, add / list / extract / delete / save embedded file attachments with MIME subtype display
- ImageToPDF - Delphi, C++Builder, and Lazarus image batch conversion into one PDF, one image per page, with preview and per-image progress
The Delphi, C++Builder, and Lazarus regression suites cover 147 (Pas) / 123 (C++) cases sharing the same fixture PDFs so behaviour stays byte-aligned across all three IDE families.
Platform Support
- Delphi - Delphi XE5 (RAD Studio XE5) through Delphi 13.1 Florence (RAD Studio 13.1)
- C++Builder - C++Builder XE5 (RAD Studio XE5) through C++Builder 13.1 Florence
- Lazarus - Free Pascal / Lazarus support
- Win32 / Win64 - Both 32-bit and 64-bit Windows platforms