Use o FPdfDocumentCore para uma API de documento sem dependência de VCL/LCL ou Graphics, ou chame o TPdf.CreateCoreSnapshot para pontuar um component existente em um snapshot independente apenas RTL
Defina PDFIUMPAS_CORE_ONLY para compilar a API de documento de alto nível sem o framework de widgets VCL/LCL: TPdfView, TPdfReadingSession e os helpers de viewer ficam de fora, e as units de widgets (Forms, Controls, Dialogs, ExtCtrls, Menus, Messages) saem da lista de uses da unit nos dois ramos de compilador; apenas Vcl.Graphics ou a unit Graphics da LCL permanece para a API de renderização de buffer de pixels
A personalidade padrão mantém a API clássica, então projetos existentes compilam sem alteração; um consumidor headless adiciona o define e usa o TPdf diretamente para carregar, extrair texto, editar, salvar e renderizar em bitmaps; o CreateCoreSnapshot ainda exporta o documento ativo para um snapshot limitado independente TPdfDocumentCore
As diferenças headless são explícitas: os timers scripted de formulário do PDFium reportam indisponibilidade (sem bomba de mensagens de janela), prompts de JavaScript devolvem a resposta padrão scripted sem diálogo, alerts usam a message box Win32 crua, e os recursos visuais do controle estão ausentes; o substituto inerte de TPdfView mantém a cola de form-fill compilando enquanto nenhuma instância é criada
Pdf.FileName := 'document.pdf';
Pdf.Password := 'password';
Pdf.Active := True; // abrir documento PDF
Pdf.PageNumber := 1; // selecionar página
ShowMessage(Pdf.Text); // extrair texto
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;
Style: TPdfOutlineStyle;
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;
AttachmentPointSets: TQuadrilateralPoints;
Rectangle: TPdfRectangle;
HasContents: Boolean;
ContentsText: WString;
HasAuthor: Boolean;
AuthorText: WString;
HasName: Boolean;
Name: WString;
HasSubject: Boolean;
Subject: WString;
HasModificationDate: Boolean;
ModificationDate: WString;
HasCreationDate: Boolean;
CreationDate: WString;
HasIcon: Boolean;
Icon: WString;
HasOpacity: Boolean;
Opacity: Double;
HasLineEndpoints: Boolean;
LineStart: TPdfPoint;
LineEnd: TPdfPoint;
HasVertices: Boolean;
Vertices: array of TPdfPoint;
HasInkList: Boolean;
InkList: array of TPdfInkGesture;
HasBorder: Boolean;
BorderHorizontalRadius: Single;
BorderVerticalRadius: Single;
BorderWidth: Single;
HasAppearanceNormal: Boolean;
AppearanceNormal: WString;
HasAppearanceRollover: Boolean;
AppearanceRollover: WString;
HasAppearanceDown: Boolean;
AppearanceDown: WString;
HasLinkUri: Boolean;
LinkUri: 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, fiXfa, fiXfaCheckBox, fiXfaComboBox, fiXfaImageField, fiXfaListBox, fiXfaPushButton, fiXfaSignature, fiXfaTextField);
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;
RawData: TBytes;
Filters: TPdfStringArray;
HorizontalDpi: Single;
VerticalDpi: Single;
BitsPerPixel: LongWord;
ColorSpace: Integer;
MarkedContentId: Integer;
IccProfile: 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;
ByteRange: TPdfIntegerArray;
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;
RawTypeName: 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;
Attributes: TPdfStructureAttributeValues;
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;
AssociatedFileDeclaredInCatalog: Boolean;
AssociatedFileDeclaredInStructure: Boolean;
AssociatedFileInEmbeddedFilesNameTree: Boolean;
AssociatedFileHasReadingOrder: Boolean;
AssociatedFileReadingOrderIndex: Integer;
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, pv20);
A versão de um arquivo PDF ou de um destino SaveAs explícito. Os valores possíveis são: versão desconhecida, versões de PDF 1.0 a 1.7 e 2.0. Destinos SaveAs explícitos de PDF 1.3 a PDF 2.0 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, saSubsetNewFonts);
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;
StartCharIndex: Integer;
CharCount: Integer;
end;
type TWebLinks = array of TWebLink;
Informações de URL e limites do link da web
type WString = {$IFDEF FPC} WideString {$ELSE} string {$ENDIF};
String larga
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;
SourceFragment: TPdfContentFragment;
TableContext: TPdfReaderTableContext;
ListContext: TPdfReaderListContext;
TextStartIndex: Integer;
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;
CharacterIndices: TPdfIntegerArray;
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;
ContextOnly: Boolean;
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
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
Destruir um TPdf vinculado desativa os views sobreviventes dele e limpa as referências de Pdf deles; handles nativos de documento e página obtidos anteriormente não devem mais ser usados