PDFiumVCL Docs

TPdf

TPdf

Unit

PDFium

Description

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;
  Action: TPdfAction;
  ActionPageNumber: Integer;
end;

type TBookmarks = array of TBookmark;

Bookmark data.

 

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

Named destination data.

 

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 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);

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);

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);

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 TPdfSignature = record
  Content: TBytes;
  Encoding: WString;
  Reason: WString;
  Time: WString;
  Permission: Integer;
end;

Digital signature information.

 

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

The version of PDF file. Possible values are: unknown version, PDF version 1.0 to 1.7.

 

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

Print paper handling options.

 

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

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.

 

Global Variables

var LibraryName: string = 'pdfium.dll';

Name of the PDFium library. Can be changed before calling LoadLibrary.

 

var EnableV8Engine: Boolean = False;

Set to True to enable V8 engine support for XFA forms.

 

Global Functions

function Loaded: Boolean;

Returns True if the PDFium library is loaded.

 

procedure LoadLibrary;

Loads the PDFium library.

 

procedure UnloadLibrary;

Unloads the PDFium library.

 

function DecodeDate(const Value: string; out DateTime: TDateTime; out DateTimeOffset: Integer): Boolean;

Converts PDF date format to DateTime and DateTimeOffset. DateTimeOffset contains date/time offset (in minutes) to Coordinated Universal Time (UTC).

 

function PointsToInches(Points: Double): Double;

Converts PDF points to inches.

 

function PointsToPixels(Points, PixelsPerInch: Double): Double;

Converts PDF points to pixels.

 

function PixelsToInches(Pixels, PixelsPerInch: Double): Double;

Converts pixels to inches.

 

function PixelsToPoints(Pixels, PixelsPerInch: Double): Double;

Converts pixels to PDF points.

 

Published Properties

property About: string; // read only

Version, copyright, and contact information.

 

property Active: Boolean; // default False

Opens or closes the selected PDF document.

 

property FileName: string;

Name of the PDF file.

 

property FormFill: Boolean; // default True

Enables PDF form fill functionality.

 

property PageNumber: Integer; // default 0

Currently selected page. PageNumber value has to be 1 to PageCount.

 

property Password: string;

Password for PDF file.

 

Public Properties

property Annotation[Index: Integer]: TPdfAnnotation;

Retrieves or sets the specified annotation in the current PDF page. The index value has to be from 0 to AnnotationCount - 1.

 

property AnnotationCount: Integer; // read only

The number of annotations in the current PDF page.

 

property Attachment[Index: Integer]: TBytes;

Retrieves or sets the specified attachment in the PDF document. The index value has to be from 0 to AttachmentCount - 1.

 

property AttachmentCount: Integer; // read only

The number of attachments in the PDF document.

 

property AttachmentName[Index: Integer]: WString; // read only

Retrieves the name of the specified attachment. The index value has to be from 0 to AttachmentCount - 1.

 

property Author: WString; // read only

Author retrieved from PDF document metadata.

 

property Bitmap[Index: Integer]: TBitmap; // read only

Bitmap data of the specified PDF image object. The index value has to be from 0 to BitmapCount - 1. Returned bitmap has to be manually released.

 

property BitmapCount: Integer; // read only

Number of PDF image objects inside the PDF page.

 

property Bookmark[const Title: WString]: TBookmark; // read only

Returns a bookmark in the document, using the bookmark title.

 

property BookmarkChildren[const Bookmark: TBookmark]: TBookmarks; // read only

Returns child bookmarks for the specified bookmark in the document.

 

property BookmarkFrom[Handle: FPDF_BOOKMARK]: TBookmark; // read only

Returns bookmark data from a bookmark handle.

 

property Bookmarks: TBookmarks; // read only

Returns top level bookmarks in the document.

 

property Character[Index: Integer]: WideChar; // read only

Returns the specified character in a page. The index value has to be from 0 to CharacterCount - 1.

 

property CharacterAngle[Index: Integer]: Single; // read only

Returns the rotation angle in radians for the specified character. The index value has to be from 0 to CharacterCount - 1.

 

property CharacterCount: Integer; // read only

Number of characters in a page.

 

property CharacterFontSize[Index: Integer]: Double; // read only

Returns the font size of the specified character in points. The index value has to be from 0 to CharacterCount - 1. FontSize[Index] remains available as a backward-compatible alias.

 

property CharacterFontWeight[Index: Integer]: Integer; // read only

Returns the font weight of the specified character. Typical values are 400 (normal) and 700 (bold). The index value has to be from 0 to CharacterCount - 1.

 

property CharacterGenerated[Index: Integer]: Boolean; // read only

Returns True if the specified character in a page is generated by PDFium. The index value has to be from 0 to CharacterCount - 1.

 

property CharacterIsHyphen[Index: Integer]: Boolean; // read only

Returns True if the specified character in a page is a hyphen. The index value has to be from 0 to CharacterCount - 1.

 

property CharacterMapError[Index: Integer]: Boolean; // read only

Returns True if the specified character in a page has an invalid unicode mapping. The index value has to be from 0 to CharacterCount - 1.

 

property CharacterOrigin[Index: Integer]: TPdfPoint; // read only

Origin of a particular character in a page. The index value has to be from 0 to CharacterCount - 1.

 

property CharacterRectangle[Index: Integer]: TPdfRectangle; // read only

Bounding box of a particular character in a page. The index value has to be from 0 to CharacterCount - 1.

 

property Charcode[Index: Integer]: WideChar; // read only

Returns the specified character code in a page. The index value has to be from 0 to CharacterCount - 1.

 

property Compressed: Boolean; // default True

When True (default), PDF streams are compressed using FlateDecode when saving. The compression engine scans saved PDF data, compresses any uncompressed streams using zlib, and rebuilds the xref table. If all streams are already compressed, the data passes through without modification.

 

property CreationDate: WString; // read only

Creation date retrieved from PDF document metadata.

 

property Creator: WString; // read only

Creator retrieved from PDF document metadata.

 

property Destination[Index: Integer]: TDestination; // read only

Data for the selected named destination. The index value has to be from 0 to DestinationCount - 1.

 

property DestinationByName[const Name: WString]: TDestination; // read only

Data for the selected named destination.

 

property DestinationCount: Integer; // read only

Number of named destinations in the PDF document.

 

property Document: FPDF_DOCUMENT; // read only

PDF document handle.

 

property Find: FPDF_SCHHANDLE; // read only

PDF document search handle.

 

property FontAscent[Index: Integer; FontSize: Single]: Single; // read only

Returns ascent distance for the font used by the specified text object. The index value has to be from 0 to ObjectCount - 1. The FontSize value controls the point-size scaling.

 

property FontBaseName[Index: Integer]: WString; // read only

Returns the base name of the font used by the specified text object. The base name is typically the font's PostScript name. The index value has to be from 0 to ObjectCount - 1.

 

property FontData[Index: Integer]: TBytes; // read only

Returns raw font data for the font used by the specified text object. The index value has to be from 0 to ObjectCount - 1.

 

property FontDescent[Index: Integer; FontSize: Single]: Single; // read only

Returns descent distance for the font used by the specified text object. The index value has to be from 0 to ObjectCount - 1. The FontSize value controls the point-size scaling.

 

property FontFamilyName[Index: Integer]: WString; // read only

Returns the family name of the font used by the specified text object. The index value has to be from 0 to ObjectCount - 1.

 

property FontHandle[Index: Integer]: FPDF_FONT; // read only

Returns the low-level PDFium font handle for the specified text object. The index value has to be from 0 to ObjectCount - 1.

 

property FontIsEmbedded[Index: Integer]: Boolean; // read only

Determines whether the font used by the specified text object is embedded. The index value has to be from 0 to ObjectCount - 1.

 

property FontItalicAngle[Index: Integer]: Integer; // read only

Returns the italic angle of the font used by the specified text object. Angle is defined as degrees counterclockwise from vertical; it is negative for a font that slopes to the right.

 

property FontSize[Index: Integer]: Double; // read only

Returns font size of a particular character in a page. The index value has to be from 0 to CharacterCount - 1.

 

property FontWeight[Index: Integer]: Integer; // read only

Returns the weight of the font used by the specified text object. Typical values are 400 (normal) and 700 (bold). The index value has to be from 0 to ObjectCount - 1.

 

See the Demo\Delphi\FontProperties project for a complete example that reads character metrics and text-object font metadata through TPdf.

 

property FormField[Index: Integer]: WString;

Content of the specified PDF form field. The index value has to be from 0 to FormFieldCount - 1.

 

property FormFieldAt[X, Y: Single]: WString;

Content of the specified PDF form field. X and Y are PDF coordinates.

 

property FormFieldCount: Integer; // read only

Number of form fields inside the PDF page.

 

property FormFieldInfo[Index: Integer]: TPdfFormFieldInfo; // read only

Information about the specified PDF form field. The index value has to be from 0 to FormFieldCount - 1.

 

property FormFieldInfoAt[X, Y: Single]: TPdfFormFieldInfo; // read only

Information about the specified PDF form field. X and Y are PDF coordinates.

 

property FormHandle: FPDF_FORMHANDLE; // read only

PDF form handle.

 

property FormType: TPdfFormType; // read only

Type of forms contained in the PDF document.

 

property HasBookmarkChildren[const Bookmark: TBookmark]: Boolean; // read only

Returns True if the specified bookmark has child bookmarks.

 

property HasFormFieldAt[X, Y: Single]: Boolean; // read only

Determines whether a form field is located at given location. X and Y are PDF coordinates.

 

property Image[Index: Integer]: TPdfImage; // read only

Size in pixels and data of the specified PDF image object. The index value has to be from 0 to ImageCount - 1.

 

property ImageCount: Integer; // read only

Number of PDF image objects inside the PDF page.

 

property IsTagged: Boolean; // read only

Determines if the PDF document is a tagged PDF document.

 

property Keywords: WString; // read only

Keywords retrieved from PDF document metadata.

 

property LinkAnnotation[PageNumber, Index: Integer]: TLinkAnnotation; // read only

Annotation data for the selected link annotation. The index value has to be from 0 to LinkAnnotationCount - 1.

 

property LinkAnnotationCount[PageNumber: Integer]: Integer; // read only

Number of link annotations in the specified PDF page.

 

property MetaText[const Tag: string]: WString; // read only

Text from metadata of the PDF document.

 

property ModifiedDate: WString; // read only

Modified date retrieved from PDF document metadata.

 

property ObjectBitmap[Index: Integer]: TBitmap; // read only

Bitmap rasterisation of the specified PDF object or nil if the specific PDF object isn't an image object. The index value has to be from 0 to ObjectCount - 1. Returned bitmap has to be manually released.

 

property ObjectBounds[Index: Integer]: TPdfRectangle; // read only

Boundaries of the specified PDF object. The index value has to be from 0 to ObjectCount - 1.

 

property ObjectCount: Integer; // read only

Number of PDF objects inside the PDF page.

 

property ObjectHandle[Index: Integer]: Pointer; // read only

Handle of the specified PDF object. The index value has to be from 0 to ObjectCount - 1.

 

property ObjectTransparent[Index: Integer]: Boolean; // read only

Determines whether the specified PDF object contains transparency. The index value has to be from 0 to ObjectCount - 1.

 

property ObjectType[Index: Integer]: TObjectType; // read only

Type of the specified PDF object. The index value has to be from 0 to ObjectCount - 1.

 

property Page: FPDF_PAGE; // read only

PDF document page handle.

 

property PageBounds: TPdfRectangle; // read only

The bounding box of the page. This is the intersection between its media box and crop box.

 

property PageCount: Integer; // read only

Total number of pages in a document.

 

property PageHeight: Double; // read only

Page height (excluding non-displayable area) measured in points. One point is 1/72 inch.

 

property PageLabel[PageNumber: Integer]: WString; // read only

Page label for the specified page. PageNumber value has to be 1 to PageCount.

 

property PageMode: TPageMode; // read only

How the document should be displayed when opened.

 

property PageRotation: TRotation;

The initial PDF page rotation. The PDF page rotation is rotated clockwise.

 

property PageWidth: Double; // read only

Page width (excluding non-displayable area) measured in points. One point is 1/72 inch.

 

property PdfVersion: TPdfVersion; // read only

PDF version of the PDF document.

 

property Permissions: LongWord; // read only

Permission flags of the PDF document. If the document is not protected or was unlocked by the owner, $FFFFFFFF will be returned.

 

property PrintCopies: Integer; // read only

Number of copies to be printed.

 

property PrintPaperHandling: TPrintPaperHandling; // read only

The paper handling option to be used when printing.

 

property PrintScaling: Boolean; // read only

Whether the PDF document prefers to be scaled or not.

 

property Producer: WString; // read only

Producer retrieved from PDF document metadata.

 

property Rectangle[Index: Integer]: TPdfRectangle; // read only

Get a rectangular area of the selected rectangle from the result generated by the RectangleCount function. The index value has to be from 0 to RectangleCount - 1.

 

property Signature[Index: Integer]: TPdfSignature; // read only

Get the specified signature. The index value has to be from 0 to SignatureCount - 1.

 

property SignatureCount: Integer; // read only

Total number of signatures in the PDF document.

 

property Subject: WString; // read only

Subject retrieved from PDF document metadata.

 

property TextPage: FPDF_TEXTPAGE; // read only

PDF document page text handle.

 

property Thumbnail: TBitmap; // read only

Page thumbnail or nil if thumbnail isn't available. Returned bitmap has to be manually released.

 

property Title: WString; // read only

Title retrieved from PDF document metadata.

 

property Transparent: Boolean; // read only

Check whether the content of specified PDF page contains transparency.

 

property UserPermissions: LongWord; // read only

User permission flags of the PDF document. If the document is not protected, $FFFFFFFF will be returned.

 

property ViewerPreference[const Key: string]: WString; // read only

Content of viewer preference with a given key.

 

property WebLink[PageNumber, Index: Integer]: TWebLink; // read only

URL information and boundaries for the selected web link. The index value has to be from 0 to WebLinkCount - 1.

 

property WebLinkCount[PageNumber: Integer]: Integer; // read only

Number of detected web links in the specified page.

 

property XFA: Boolean; // read only

Determines whether pdfium.dll supports XFA.

 

Methods

function AddJpegImage(JpegImage: TStream; X, Y, Width, Height: Double): Boolean;

Add JPEG image to the current PDF page using the specified coordinates.

 

procedure AddPage(PageNumber: Integer; Width, Height: Double);

Construct an empty page.

 

procedure AddPath;

Add created path to the current PDF page.

 

procedure AddPicture(Picture: TPicture; X, Y: Double);

Add picture to the current PDF page using the specified coordinates.

 

procedure AddPicture(Picture: TPicture; X, Y, Width, Height: Double);

Add picture to the current PDF page using the specified coordinates and size.

 

procedure AddText(const Text, Font: WString; FontSize: Single; X, Y: Double; Color: TColor = clBlack; Alpha: Byte = $FF; Angle: Double = 0.0);

Add text to the current PDF page at the specified position.

 

procedure BezierTo(X1, Y1, X2, Y2, X3, Y3: Single);

Add a cubic Bezier curve to the given path, starting at the current point, using specified control points.

 

function CharacterIndexAtPos(X, Y, ToleranceX, ToleranceY: Double): Integer;

Get the index of a character at or nearby a certain position on the page. If there is no character at or nearby the point, return value will be -1. If an error occurs, -3 will be returned.

 

procedure ClosePath;

Add a line between the current point and the initial point of the subpath, thus terminating the current subpath.

 

procedure CreateAnnotation(const Annotation: TPdfAnnotation);

Create a new annotation.

 

function CreateAttachment(const Name: WString): Boolean;

Create a new attachment.

 

procedure CreateDocument;

Create a new PDF document.

 

procedure CreatePath(X, Y: Single; FillMode: TPdfFillMode = fmNone; FillColor: TColor = clBlack; FillAlpha: Byte = $FF; Stroke: Boolean = True; StrokeColor: TColor = clBlack; StrokeAlpha: Byte = $FF; StrokeWidth: Single = 1.0; LineCap: TPdfLineCap = lcDefault; LineJoin: TPdfLineJoin = ljDefault; BlendMode: TPdfBlendMode = bmDefault);

Create a new path object at an initial position.

 

procedure CreatePath(X, Y, Width, Height: Single; FillMode: TPdfFillMode = fmNone; FillColor: TColor = clBlack; FillAlpha: Byte = $FF; Stroke: Boolean = True; StrokeColor: TColor = clBlack; StrokeAlpha: Byte = $FF; StrokeWidth: Single = 1.0; LineCap: TPdfLineCap = lcDefault; LineJoin: TPdfLineJoin = ljDefault; BlendMode: TPdfBlendMode = bmDefault);

Create a new closed path consisting of a specified rectangle.

 

procedure DeleteAnnotation(Index: Integer);

Delete the specified annotation in the current PDF page. The index value has to be from 0 to AnnotationCount - 1.

 

function DeleteAttachment(Index: Integer): Boolean;

Delete the specified attachment. The index value has to be from 0 to AttachmentCount - 1.

 

procedure GenerateFormAppearances;

Regenerates the /AP (appearance stream) for every form widget on every page by rendering each page through FPDF_FFLDraw. This is the recommended companion call to FormField[i] := value assignments — without it, form values may be visible only when the field has focus, and any subsequent flatten operation will silently lose the values. Call after all FormField[] assignments and before SaveAs / FlattenPage / FlattenAllPages.

 

function FlattenPage(nFlag: Integer = FLAT_NORMALDISPLAY): Integer;

Flattens annotations and form widgets on the current page into permanent (non-editable) page content. nFlag selects the flattening profile: FLAT_NORMALDISPLAY (0) for screen display or FLAT_PRINT (1) for printed output. Returns one of FLATTEN_SUCCESS, FLATTEN_NOTHINGTODO, or FLATTEN_FAIL. Call GenerateFormAppearances first when flattening filled-in form values.

 

function FlattenAllPages(nFlag: Integer = FLAT_NORMALDISPLAY): Boolean;

Convenience wrapper that flattens every page in the document. Returns True when every page completes with FLATTEN_SUCCESS or FLATTEN_NOTHINGTODO. Recommended workflow: GenerateFormAppearancesFlattenAllPagesSaveAs.

 

procedure DeletePage(PageNumber: Integer);

Delete the specified PDF page.

 

function DeviceToPage(X, Y, Left, Top, Width, Height: Integer; Rotation: TRotation; out PageX, PageY: Double): Boolean;

Convert the screen coordinate of a point to page coordinate.

 

function FindFirst(const Text: WString; Options: TSearchOptions = []; StartIndex: Integer = 0; DirectionUp: Boolean = True): Integer;

Start a search of the specified text. StartIndex is 0-based, -1 is for end of the page. DirectionUp parameter determines direction of this search operation.

 

function FindNext: Integer;

Search in the direction from page start to end. Returns text position, or -1 if text was not found. Search must be initiated with FindFirst function.

 

function FindPrevious: Integer;

Search in the direction from page end to start. Returns text position, or -1 if text was not found. Search must be initiated with FindFirst function.

 

function ImportPages(Pdf: TPdf; const Range: string; PageNumber: Integer = 1): Boolean;

Import pages from the specified PDF document. Range parameter determines the pages to be imported, such as '1,3,5-7'. PageNumber parameter is the page number to insert from.

 

function ImportPreferences(Pdf: TPdf): Boolean;

Copy the viewer preferences from the specified PDF document.

 

procedure LineTo(X, Y: Single);

Add a line between the current point and a new point in the path.

 

procedure LoadDocument;

Open and load a PDF document from FileName.

 

procedure LoadDocument(Data: Pointer; Size: Integer; Buffered: Boolean = True);

Open and load a PDF document from memory. If Buffered parameter is False then memory data must remain valid until the document is closed.

 

procedure LoadDocument(const Data: TBytes; Buffered: Boolean = True);

Open and load a PDF document from memory. If Buffered parameter is False then memory data must remain valid until the document is closed.

 

procedure LoadDocument(Data: TMemoryStream; Buffered: Boolean = True);

Open and load a PDF document from memory. If Buffered parameter is False then memory data must remain valid until the document is closed.

 

procedure MoveTo(X, Y: Single);

Move a path's current point to the specific position.

 

function PageToDevice(PageX, PageY: Double; Left, Top, Width, Height: Integer; Rotation: TRotation; out X, Y: Integer): Boolean;

Convert the page coordinate of a point to screen coordinate.

 

function RectangleCount(StartIndex: Integer = 0; Count: Integer = MaxInt): Integer;

Count number of rectangular areas occupied by a segment of texts. Function automatically merges small character boxes into bigger one if those characters are on the same line and use same font settings.

 

procedure ReloadPage;

Reloads contents of a page.

 

procedure RenderPage(DeviceContext: HDC; Left, Top, Width, Height: Integer; Rotation: TRotation = ro0; Options: TRenderOptions = []);

Render contents of a page to a device (screen, bitmap, or printer).

 

function RenderPage(Left, Top, Width, Height: Integer; Rotation: TRotation = ro0; Options: TRenderOptions = []; Color: TColor = clWhite): TBitmap;

Render contents of a page to a new bitmap. Returned bitmap has to be manually released.

 

procedure RenderPage(Bitmap: TBitmap; Left, Top, Width, Height: Integer; Rotation: TRotation = ro0; Options: TRenderOptions = []; Color: TColor = clWhite);

Render contents of a page to an existing bitmap.

 

function RenderTile(Left, Top, Width, Height, PageWidth, PageHeight: Integer; Rotation: TRotation = ro0; Options: TRenderOptions = []; Color: TColor = clWhite): TBitmap;

Render rectangular area of a page to a new bitmap. Returned bitmap has to be manually released.

 

procedure RenderTile(Bitmap: TBitmap; Left, Top, Width, Height, PageWidth, PageHeight: Integer; Rotation: TRotation = ro0; Options: TRenderOptions = []; Color: TColor = clWhite);

Render rectangular area of a page to an existing bitmap.

 

function SaveAs(Stream: TStream; Option: TSaveOption = saNone; PdfVersion: TPdfVersion = pvUnknown): Boolean;

Saves the copy of PDF document to the specified stream.

 

function SaveAs(const FileName: string; Option: TSaveOption = saNone; PdfVersion: TPdfVersion = pvUnknown): Boolean;

Saves the copy of PDF document to the specified file.

 

procedure SetText(ObjectIndex: Integer; const Text: WString);

Sets text for the specified text object.

 

function Text(StartIndex: Integer = 0; Count: Integer = MaxInt): WString;

Extract text string from the page. StartIndex and Count parameters determine characters to be extracted. StartIndex parameter is 0-based.

 

function TextInRectangle(Left, Top, Right, Bottom: Double): WString;

Extract text within a rectangular boundary on the page.

 

function TextInRectangle(Rectangle: TPdfRectangle): WString;

Extract text within a rectangular boundary on the page.

 

procedure UpdatePage;

Generate PDF page content of modified PDF page. Without calling this method, the changed PDF information will be lost.

 

Events

property OnFormFieldEnter: TPdfFormFieldEnterEvent;

type TPdfFormFieldEnterEvent = procedure(Sender: TObject; const Text: WString) of object;

Write OnFormFieldEnter event handler to take specific actions when the form field is getting a focus.

 

property OnFormFieldExit: TNotifyEvent;

Write OnFormFieldExit event handler to take specific actions when the form field is losing a focus.

 

property OnPageChange: TNotifyEvent;

Write OnPageChange event handler to take specific actions when the current PDF page was changed.

 

property OnUnsupportedFeature: TPdfUnsupportedFeatureEvent;

type TPdfUnsupportedFeatureEvent = procedure(Sender: TObject; Feature: TPdfFeature) of object;

Occurs on unsupported PDF feature.