PDFium Delphi Component Docs

TPdf component

Unit: PDFium
TPdf
Use TPdf component to open, navigate, extract text, and edit PDF documents

Example

Pdf.FileName := 'document.pdf';
Pdf.Password := 'password';
Pdf.Active := True; // open PDF document
Pdf.PageNumber := 1; // select page
ShowMessage(Pdf.Text); // extract text

Types

type TBookmark = record
  Handle: FPDF_BOOKMARK;
  Title: WString;
  PageNumber: Integer;
  Destination: TDestination;
  DescendantCount: Integer;
  IsOpen: Boolean;
  Action: TPdfAction;
  ActionPageNumber: Integer;
  ActionDestination: TDestination;
  ActionPath: WString;
  HasColor: Boolean;
  Color: TColor;
end;

type TBookmarks = array of TBookmark;

Bookmark data

 

type TDestination = record
  Handle: FPDF_DEST;
  Name: WString;
  PageNumber: Integer;
  ViewMode: TPdfDestinationViewMode;
  ViewParameterCount: Integer;
  ViewParameters: TPdfDestinationViewParameters;
  HasX: Boolean;
  X: Single;
  HasY: Boolean;
  Y: Single;
  HasZoom: Boolean;
  Zoom: Single;
end;

Named destination data

 

type TPdfDestinationViewMode = (dvmUnknown, dvmXYZ, dvmFit, dvmFitHorizontal, dvmFitVertical, dvmFitRectangle, dvmFitBoundingBox, dvmFitBoundingBoxHorizontal, dvmFitBoundingBoxVertical);

type TPdfDestinationViewParameters = array [0..3] of Single;

Destination view mode and its ordered native parameters

 

type TLinkAnnotation = record
  Handle: FPDF_LINK;
  Rectangle: TPdfRectangle;
  PageNumber: Integer;
  Action: TPdfAction;
  ActionPageNumber: Integer;
  ActionPath: WString;
  Points: array of TQuadrilateralPoint;
end;

type TLinkAnnotations = array of TLinkAnnotation;

type TQuadrilateralPoint = array [1..4] of TPdfPoint;

Link annotation data

 

type TPdfPermission = (permPrint, permModify, permCopy, permAnnotate, permFillForms, permAccessibility, permAssemble, permPrintHighQuality);

type TPdfPermissions = set of TPdfPermission;

Typed document permission flags decoded from the native permission mask

 

type TPdfDocumentMetadata = record
  Title: WString;
  Author: WString;
  Subject: WString;
  Keywords: WString;
  Creator: WString;
  Producer: WString;
  CreationDate: WString;
  ModifiedDate: WString;
end;

One snapshot of the standard document Info dictionary fields

 

type TObjectType = (otUnknown, otText, otPath, otImage, otShading, otForm);

Determines type of the PDF object

 

type TPageMode = (pmNone, pmOutline, pmThumbs, pmFullScreen, pmOptionalContentGroup, pmAttachments, pmUnknown);

Determines how the PDF document should be displayed when opened

 

type TPdfAction = (acUnsupported, acGoto, acGotoRemote, acUri, acLaunch);

Determines type of an action associated with a bookmark item

 

type TPdfAnnotation = record
  Subtype: TPdfAnnotationSubtype;
  Flags: TPdfAnnotationFlags;
  HasColor: Boolean;
  Color: TColor;
  ColorAlpha: Byte;
  HasInteriorColor: Boolean;
  InteriorColor: TColor;
  InteriorColorAlpha: Byte;
  HasAttachmentPoints: Boolean;
  AttachmentPoints: TQuadrilateralPoint;
  Rectangle: TPdfRectangle;
  ContentsText: WString;
  AuthorText: WString;
end;

Annotation data

 

type TPdfAnnotationFlag = (afInvisible, afHidden, afPrint, afNoZoom, afNoRotate, afNoView, afReadOnly, afLocked, afToggleNoView);

type TPdfAnnotationFlags = set of TPdfAnnotationFlag;

Annotation flags

 

type TPdfAnnotationSubtype = (anUnknown, anText, anLink, anFreeText, anLine, anSquare, anCircle, anPolygon, anPolyLine, anHighlight, anUnderline, anSquiggly, anStrikeout, anStamp, anCaret, anInk, anPopup, anFileAttachment, anSound, anMovie, anWidget, anScreen, anPrinterMark, anTrapNet, anWaterMark, anThreed, anRichMedia, anXfaWidget, anRedact);

The annotation subtype

 

type TPdfBlendMode = (bmDefault, bmColor, bmColorBurn, bmColorDodge, bmDarken, bmDifference, bmExclusion, bmHardLight, bmHue, bmLighten, bmLuminosity, bmMultiply, bmNormal, bmOverlay, bmSaturation, bmScreen, bmSoftLight);

Determines how layers are blended into each other

 

type TPdfDisplayMode = (dmSingleContinuous, dmTwoPageContinuous, dmTwoPageContinuousWithCover);

Determines how the PDF document pages are displayed

 

type TPdfFeature = (feUnknown, feXfaForm, fePortableCollection, feAttachment, feSecurity, feSharedReview, feSharedFormAcrobat, feSharedFormFilesystem, feSharedFormEmail, fe3dAnnotation, feMovieAnnotation, feSoundAnnotation, feScreenMediaAnnotation, feScreenRichMediaAnnotation, feAttachmentAnnotation, feSignatureAnnotation);

Feature of PDF document reported by OnUnsupportedFeature event

 

type TPdfFillMode = (fmNone, fmAlternate, fmWinding);

Determines how fill areas are formed when path intersects itself

 

type TPdfFormFieldFlag = (ffReadOnly, ffRequired, ffNoExport, ffMultiline, ffChoiceCombo, ffChoiceEdit, ffPassword, ffChoiceMultiSelect);

type TPdfFormFieldFlags = set of TPdfFormFieldFlag;

Form field flags

 

type TPdfFormFieldInfo = record
  Name: WString;
  AlternateName: WString;
  FieldType: TPdfFormFieldType;
  Flags: TPdfFormFieldFlags;
  OptionLabels: array of WString;
  OptionSelected: array of Boolean;
  FontSize: Single;
  Checked: Boolean;
  ExportValue: WString;
  GroupCount: Integer;
  GroupIndex: Integer;
end;

Form field information

 

type TPdfFormFieldType = (fiUnknown, fiPushButton, fiCheckBox, fiRadioButton, fiComboBox, fiListBox, fiTextField, fiSignature);

Determines the type of the form field

 

type TPdfFormType = (ftUnknown, ftNone, ftAcroForm, ftXfaFull, ftXfaForeground);

Determines type of forms in the PDF document

 

type TPdfImage = record
  Width: Integer;
  Height: Integer;
  Data: TBytes;
end;

Size in pixels and data of the PDF image object

 

type TPdfLineCap = (lcDefault, lcButt, lcRound, lcProjectingSquare);

The shape to be used at the ends of open subpaths

 

type TPdfLineJoin = (ljDefault, ljMiter, ljRound, ljBevel);

The shape to be used at the corners of paths that are stroked

 

type TPdfPoint = record
  X, Y: Double;
end;

Point with X and Y coordinates

 

type TPdfRectangle = record
  Left, Top, Right, Bottom: Double;
end;
type TPdfRectangles = array of TPdfRectangle;

Rectangle area with Left, Top, Right and Bottom coordinates

 

type TPdfFileIdentifierType = (fidPermanent, fidChanging);

Trailer file identifier selector. fidPermanent reads the first /ID entry and fidChanging reads the second /ID entry

 

type TPdfPageBox = (pbMedia, pbCrop, pbBleed, pbTrim, pbArt);

Page dictionary box selector used by PageBox, GetPageBox, and SetPageBox

 

type TPdfJavaScriptAction = record
  Name: WString;
  Script: WString;
end;
type TPdfJavaScriptActions = array of TPdfJavaScriptAction;

Document-level JavaScript name-tree action data

 

type TPdfSignature = record
  Content: TBytes;
  Encoding: WString;
  Reason: WString;
  Time: WString;
  Permission: Integer;
end;

Digital signature information

 

type TPdfIntegerArray = array of Integer;

Integer array used by structure-tree marked-content ID lists

 

type TPdfSingleArray = array of Single;

Single-precision floating-point array used by text object character position setters

 

type TPdfPrintPageRange = record
  StartPage: Integer;
  EndPage: Integer;
end;
type TPdfPrintPageRanges = array of TPdfPrintPageRange;

One-based print page ranges from the document viewer preferences

 

type TPdfStructureElement = record
  Level: Integer;
  ParentIndex: Integer;
  TypeName: WString;
  ObjectType: WString;
  Title: WString;
  AlternateText: WString;
  ActualText: WString;
  Expansion: WString;
  ID: WString;
  Language: WString;
  MarkedContentID: Integer;
  MarkedContentIDs: TPdfIntegerArray;
  ChildCount: Integer;
  ChildMarkedContentIDs: TPdfIntegerArray;
  AttributeCount: Integer;
  ListNumbering: WString;
  Scope: WString;
  HasHeaders: Boolean;
  HeadersIds: array of WString;
  ColSpan: Integer;
  RowSpan: Integer;
  HasPrintField: Boolean;
  NamespaceUri: WString;
  RoleMappedNamespaceUri: WString;
  RoleMappedTypeName: WString;
  HasReference: Boolean;
  HasAssociatedFile: Boolean;
  AssociatedFileRelationship: WString;
  AssociatedFileDescription: WString;
  AnnotationSubtype: WString;
  AnnotationContents: WString;
  AnnotationAlternateText: WString;
  IsArtifact: Boolean;
  WidgetCount: Integer;
  HasAppearance: Boolean;
  LabelText: WString;
  FieldAlternateName: WString;
end;

type TPdfStructureElements = array of TPdfStructureElement;

Flattened logical structure element data for tagged PDF pages

 

type TPdfFormSelectionRect = record
  PageNumber: Integer;
  Bounds: TPdfRectangle;
end;

One caller-owned page-space rectangle reported by native form-text selection

 

type TPdfStructureReadOptions = record
  MaxDepth: Integer;
  MaxElements: Integer;
  MaxAttributeValues: Integer;
  DeadlineMilliseconds: Cardinal;
  IncludeAttributes: Boolean;
  class function Default: TPdfStructureReadOptions; static;
end;

Resource budgets for iterative native structure-tree traversal

type TPdfStructureReadStatus = record
  Completed: Boolean;
  ElementsVisited: Integer;
  AttributeValuesVisited: Integer;
  DepthLimitReached: Boolean;
  ElementLimitReached: Boolean;
  AttributeLimitReached: Boolean;
  DeadlineReached: Boolean;
  VisitorStopped: Boolean;
end;

Completion and truncation details returned by structure traversal methods

 

type TPdfVersion = (pvUnknown, pv10, pv11, pv12, pv13, pv14, pv15, pv16, pv17);

The version of a PDF file or an explicit SaveAs target. Possible values are: unknown version, PDF version 1.0 to 1.7. Explicit SaveAs targets from PDF 1.3 through PDF 1.7 are normalised and validated against the selected PDF version

 

type TPrintPaperHandling = (phUndefined, phSimplex, phDuplexFlipShortEdge, phDuplexFlipLongEdge);

Print paper handling options

 

type TPdfPrintMode = (prEmf, prTextOnly, prPostScript2, prPostScript3, prPostScript2PassThrough, prPostScript3PassThrough, prEmfImageMasks, prPostScript3Type42, prPostScript3Type42PassThrough);

Windows PDFium print output mode selected by SetPdfPrintMode

 

type TRenderOption = (reAnnotations, reLcd, reNoNativeText, reGrayscale, reDebugInfo, reNoCatchException, reLimitCache, reHalftone, rePrinting, reReverseByteOrder, reNoSmoothText, reNoSmoothImage, reNoSmoothPath, reInvert, reNightDuotone);

type TRenderOptions = set of TRenderOption;

Page rendering flags

 

type TRotation = (ro0, ro90, ro180, ro270);

The PDF page rotation. The page rotation is rotated clockwise

 

type TSaveOption = (saNone, saIncremental, saNoIncremental, saRemoveSecurity);

Determines how the PDF document will be saved

 

type TSearchOption = (seCaseSensitive, seWholeWord, seConsecutive);

type TSearchOptions = set of TSearchOption;

Search flags

 

type TWebLink = record
  Url: WString;
  Rectangles: TPdfRectangles;
end;

type TWebLinks = array of TWebLink;

URL information and boundaries for the web link

 

type WString = {$ifdef D2009PLUS} string {$else} WideString {$endif D2009PLUS};

Wide string

 

Constants

const PointsPerInch: Integer = 72;

PDF uses points with a density of 72 points per inch

 

const FLAT_NORMALDISPLAY = 0;
const FLAT_PRINT = 1;

Flattening profiles passed to FlattenPage / FlattenAllPages. FLAT_NORMALDISPLAY targets screen display; FLAT_PRINT targets printed output

 

const FLATTEN_FAIL = 0;
const FLATTEN_SUCCESS = 1;
const FLATTEN_NOTHINGTODO = 2;

Result codes returned by FlattenPage

 

type TPdfReadingUnit = record
  Text: WString;
  Kind: TPdfContentFragmentKind;
  HeadingLevel: Integer;
  Page: Integer;
  Rects: TPdfRectangles;
  FragmentIndex: Integer;
  SentenceIndex: Integer;
  IsAlternateText: Boolean;
  Language: WString;
end

type TPdfReadingUnits = array of TPdfReadingUnit;

Sentence-level reading units used by text-to-speech and assistive listen-reading workflows

 

type TPdfWordBox = record
  Text: WString;
  StartIndex: Integer;
  Count: Integer;
  Rect: TPdfRectangle;
  Page: Integer;
end

type TPdfWordBoxes = array of TPdfWordBox;

Word-level text ranges and page rectangles used by synchronised reading highlights

 

type TPdfSpokenSpan = record
  SpokenStart: Integer;
  SpokenCount: Integer;
  Page: Integer;
  StartIndex: Integer;
  Count: Integer;
end

type TPdfSpokenSpans = array of TPdfSpokenSpan;

Mapped runs that translate speech-engine offsets back to PDF page text

 

type TPdfSpokenText = record
  Text: WString;
  Spans: TPdfSpokenSpans;
end

type TPdfSpokenTexts = array of TPdfSpokenText;

Speech chunks and source mappings used by read-aloud workflows and TPdfReadingSession

 

type TPdfReadingSessionState = (pssIdle, pssSpeaking, pssPaused);

Playback state reported by TPdfReadingSession

 

Global Variables

var LibraryName: string = 'pdfium.dll';

Name of the standard PDFium library used when EnableV8Engine is False. Can be changed before calling LoadLibrary

 

var EnableV8Engine: Boolean = False;

Set to True before loading to select pdfium.v8.dll from the matching Win32 or Win64 DLLs folder

 

Global Functions

Properties

Methods

Events