PDFium Delphi Component Docs

Componente TPdf

Unidade: PDFium
TPdf
Use o componente TPdf para abrir, navegar, extrair texto e editar documentos PDF

Exemplo

Pdf.FileName := 'document.pdf';
Pdf.Password := 'password';
Pdf.Active := True; // abrir documento PDF
Pdf.PageNumber := 1; // selecionar página
ShowMessage(Pdf.Text); // extrair texto

Tipos

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;

Dados de favoritos

 

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;

Dados de destino nomeado

 

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

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

Modo de exibição do destino e seus parâmetros nativos ordenados

 

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;

Dados de anotação de link

 

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

type TPdfPermissions = set of TPdfPermission;

Flags tipadas de permissão de documento decodificadas da máscara nativa de permissões

 

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

Um snapshot dos campos padrão do dicionário Info do documento

 

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

Determina o tipo do objeto PDF

 

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

Determina como o documento PDF deve ser exibido quando aberto

 

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

Determina o tipo de uma ação associada a um item de favorito

 

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;

Dados de anotação

 

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

type TPdfAnnotationFlags = set of TPdfAnnotationFlag;

Flags de anotação

 

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

O subtipo da anotação

 

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

Determina como as camadas são misturadas entre si

 

type TPdfDisplayMode = (dmSingleContinuous, dmTwoPageContinuous, dmTwoPageContinuousWithCover);

Determina como as páginas do documento PDF são exibidas

 

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

Recurso do documento PDF informado pelo evento OnUnsupportedFeature

 

type TPdfFillMode = (fmNone, fmAlternate, fmWinding);

Determina como as áreas de preenchimento são formadas quando o caminho se autointersecta

 

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

type TPdfFormFieldFlags = set of TPdfFormFieldFlag;

Flags de campo de formulário

 

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;

Informações de campo de formulário

 

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

Determina o tipo do campo de formulário

 

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

Determina o tipo de formulários no documento PDF

 

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

Tamanho em pixels e dados do objeto de imagem PDF

 

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

A forma a ser usada nas extremidades de subcaminhos abertos

 

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

A forma a ser usada nos cantos de caminhos traçados

 

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

Ponto com coordenadas X e Y

 

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

Área retangular com coordenadas Left, Top, Right e Bottom

 

type TPdfFileIdentifierType = (fidPermanent, fidChanging);

Seletor de identificador de arquivo do trailer. fidPermanent lê a primeira entrada /ID e fidChanging lê a segunda entrada /ID

 

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

Seletor de caixa do dicionário da página usado por PageBox, GetPageBox e SetPageBox

 

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

Dados de ação da árvore de nomes JavaScript em nível de documento

 

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

Informações de assinatura digital

 

type TPdfIntegerArray = array of Integer;

Array de inteiros usado pelas listas de IDs de marked-content da árvore de estrutura

 

type TPdfSingleArray = array of Single;

Array de ponto flutuante de precisão simples usado pelos setters de posição de caractere de objetos de texto

 

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

Intervalos de páginas de impressão baseados em um das preferências do visualizador do documento

 

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;

Dados achatados de elementos de estrutura lógica para páginas PDF tagged

 

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

Retângulo no espaço da página de propriedade do chamador, informado pela seleção nativa de texto de formulário

 

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

Orçamentos de recursos para travessia iterativa nativa da árvore de estrutura

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

Detalhes de conclusão e truncamento retornados pelos métodos de travessia da estrutura

 

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

A versão de um arquivo PDF ou de um destino SaveAs explícito. Os valores possíveis são: versão desconhecida e versões de PDF 1.0 a 1.7. Destinos SaveAs explícitos de PDF 1.3 a PDF 1.7 são normalizados e validados contra a versão de PDF selecionada

 

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

Opções de manuseio de papel de impressão

 

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

Modo de saída de impressão do PDFium no Windows selecionado por SetPdfPrintMode

 

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

type TRenderOptions = set of TRenderOption;

Flags de renderização de página

 

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

A rotação da página PDF. A rotação da página é no sentido horário

 

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

Determina como o documento PDF será salvo

 

type TSearchOption = (seCaseSensitive, seWholeWord, seConsecutive);

type TSearchOptions = set of TSearchOption;

Flags de pesquisa

 

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

type TWebLinks = array of TWebLink;

Informações de URL e limites do link da web

 

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

String larga

 

Constantes

const PointsPerInch: Integer = 72;

O PDF usa pontos com densidade de 72 pontos por polegada

 

const FLAT_NORMALDISPLAY = 0;
const FLAT_PRINT = 1;

Perfis de achatamento passados para FlattenPage / FlattenAllPages. FLAT_NORMALDISPLAY visa à exibição em tela; FLAT_PRINT visa à saída impressa

 

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

Códigos de resultado retornados por 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;

Unidades de leitura em nível de sentença usadas por fluxos de trabalho de texto para fala e leitura assistida por escuta

 

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

type TPdfWordBoxes = array of TPdfWordBox;

Intervalos de texto em nível de palavra e retângulos de página usados pelos realces de leitura sincronizada

 

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

type TPdfSpokenSpans = array of TPdfSpokenSpan;

Trechos mapeados que convertem deslocamentos do motor de fala de volta para o texto da página PDF

 

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

type TPdfSpokenTexts = array of TPdfSpokenText;

Blocos de fala e mapeamentos de origem usados por fluxos de leitura em voz alta e pelo TPdfReadingSession

 

type TPdfReadingSessionState = (pssIdle, pssSpeaking, pssPaused);

Estado de reprodução informado pelo TPdfReadingSession

 

Variáveis Globais

var LibraryName: string = 'pdfium.dll';

Nome da biblioteca PDFium padrão usada quando EnableV8Engine é False. Pode ser alterado antes de chamar LoadLibrary

 

var EnableV8Engine: Boolean = False;

Defina como True antes de carregar para selecionar pdfium.v8.dll da pasta DLLs Win32 ou Win64 correspondente

 

Funções Globais

Propriedades

Métodos

Eventos