PDFium Delphi Component Docs

Thành phần TPdf

Unit: PDFium
TPdf
Dùng thành phần TPdf để mở, dẫn hướng, trích xuất văn bản và chỉnh sửa tài liệu PDF

Ví dụ

Pdf.FileName := 'document.pdf';
Pdf.Password := 'password';
Pdf.Active := True; // mở tài liệu PDF
Pdf.PageNumber := 1; // chọn trang
ShowMessage(Pdf.Text); // trích xuất văn bản

Các kiểu

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;

Dữ liệu bookmark

 

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;

Dữ liệu đích đến có tên

 

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

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

Chế độ xem đích đến và các tham số gốc có thứ tự của nó

 

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;

Dữ liệu chú thích liên kết

 

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

type TPdfPermissions = set of TPdfPermission;

Các cờ quyền tài liệu có kiểu được giải mã từ mặt nạ quyền gốc

 

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

Một ảnh chụp các trường từ điển Info tiêu chuẩn của tài liệu

 

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

Xác định kiểu của object PDF

 

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

Xác định cách hiển thị tài liệu PDF khi mở

 

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

Xác định kiểu hành động gắn với một mục bookmark

 

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;

Dữ liệu chú thích

 

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

type TPdfAnnotationFlags = set of TPdfAnnotationFlag;

Các cờ chú thích

 

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

Subtype của chú thích

 

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

Xác định cách các lớp hòa trộn vào nhau

 

type TPdfDisplayMode = (dmSingleContinuous, dmTwoPageContinuous, dmTwoPageContinuousWithCover);

Xác định cách hiển thị các trang tài liệu PDF

 

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

Tính năng của tài liệu PDF được báo qua sự kiện OnUnsupportedFeature

 

type TPdfFillMode = (fmNone, fmAlternate, fmWinding);

Xác định cách tạo các vùng tô khi path tự giao nhau

 

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

type TPdfFormFieldFlags = set of TPdfFormFieldFlag;

Các cờ trường biểu mẫu

 

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;

Thông tin trường biểu mẫu

 

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

Xác định kiểu của trường biểu mẫu

 

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

Xác định kiểu biểu mẫu trong tài liệu PDF

 

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

Kích thước pixel và dữ liệu của image object PDF

 

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

Hình dạng dùng tại hai đầu của các subpath đang mở

 

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

Hình dạng dùng tại các góc của path được viền

 

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

Điểm với tọa độ X và Y

 

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

Vùng hình chữ nhật với các tọa độ Left, Top, Right và Bottom

 

type TPdfFileIdentifierType = (fidPermanent, fidChanging);

Bộ chọn định danh tệp của trailer. fidPermanent đọc mục /ID đầu tiên và fidChanging đọc mục /ID thứ hai

 

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

Bộ chọn box trong từ điển trang dùng bởi PageBox, GetPageBox, và SetPageBox

 

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

Dữ liệu hành động name-tree JavaScript cấp tài liệu

 

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

Thông tin chữ ký số

 

type TPdfIntegerArray = array of Integer;

Mảng số nguyên dùng bởi các danh sách ID marked-content của cây cấu trúc

 

type TPdfSingleArray = array of Single;

Mảng số thực độ chính xác đơn dùng bởi các setter vị trí ký tự của text object

 

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

Các dải trang in tính từ 1 lấy từ viewer preference của tài liệu

 

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;

Dữ liệu phần tử cấu trúc logic được làm phẳng cho các trang tagged PDF

 

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

Một hình chữ nhật trong không gian trang do caller sở hữu được báo từ việc chọn văn bản biểu mẫu gốc

 

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

Các ngân sách tài nguyên cho việc duyệt cây cấu trúc gốc theo kiểu lặp

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

Chi tiết hoàn tất và cắt xén do các phương thức duyệt cấu trúc trả về

 

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

Phiên bản của một tệp PDF hoặc một mục tiêu SaveAs tường minh. Các giá trị có thể là: phiên bản không xác định, phiên bản PDF 1.0 đến 1.7. Các mục tiêu SaveAs tường minh từ PDF 1.3 đến PDF 1.7 được chuẩn hóa và xác thực theo phiên bản PDF đã chọn

 

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

Các tùy chọn xử lý giấy khi in

 

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

Chế độ đầu ra in PDFium trên Windows được chọn bởi SetPdfPrintMode

 

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

type TRenderOptions = set of TRenderOption;

Các cờ kết xuất trang

 

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

Góc xoay của trang PDF. Xoay trang theo chiều kim đồng hồ

 

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

Xác định cách lưu tài liệu PDF

 

type TSearchOption = (seCaseSensitive, seWholeWord, seConsecutive);

type TSearchOptions = set of TSearchOption;

Các cờ tìm kiếm

 

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

type TWebLinks = array of TWebLink;

Thông tin URL và các ranh giới của liên kết web

 

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

Chuỗi wide

 

Hằng số

const PointsPerInch: Integer = 72;

PDF dùng đơn vị point với mật độ 72 point mỗi inch

 

const FLAT_NORMALDISPLAY = 0;
const FLAT_PRINT = 1;

Các profile làm phẳng truyền cho FlattenPage / FlattenAllPages. FLAT_NORMALDISPLAY nhắm hiển thị màn hình; FLAT_PRINT nhắm đầu ra in

 

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

Các mã kết quả do FlattenPage trả về

 

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;

Các đơn vị đọc cấp câu dùng bởi quy trình text-to-speech và nghe-đọc hỗ trợ

 

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

type TPdfWordBoxes = array of TPdfWordBox;

Các dải văn bản cấp từ và hình chữ nhật trang dùng bởi tô sáng đọc đồng bộ

 

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

type TPdfSpokenSpans = array of TPdfSpokenSpan;

Các run được ánh xạ dịch offset của engine phát âm về văn bản trang PDF

 

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

type TPdfSpokenTexts = array of TPdfSpokenText;

Các đoạn phát âm và ánh xạ nguồn dùng bởi quy trình đọc to và TPdfReadingSession

 

type TPdfReadingSessionState = (pssIdle, pssSpeaking, pssPaused);

Trạng thái phát lại do TPdfReadingSession báo

 

Biến toàn cục

var LibraryName: string = 'pdfium.dll';

Tên của thư viện PDFium tiêu chuẩn dùng khi EnableV8Engine là False. Có thể đổi trước khi gọi LoadLibrary

 

var EnableV8Engine: Boolean = False;

Đặt True trước khi nạp để chọn pdfium.v8.dll từ thư mục DLLs Win32 hoặc Win64 tương ứng

 

Hàm toàn cục

Thuộc tính

Phương thức

Sự kiện