Loaded Document Toolkit
HotPDF can open an existing PDF, apply page and form operations, inspect typed document state, render or search pages, print with device capabilities, and save the result without moving the workflow to another library
Page operations and merging
THotPDF.DeletePagesaccepts the standard one-based page-range syntax, removes duplicate selections once, and preserves a valid page tree- Deleting loaded pages detaches widget annotations and empty AcroForm field branches that belonged only to the deleted pages
THotPDF.InsertPagesFromDocumentandTHotPDF.AppendPagesFromDocumentacceptTHPDFMergeOptions- Form-name conflicts are checked before page insertion when automatic renaming is disabled, so a rejected merge leaves the destination page count unchanged
THPDFMergeOptionvalues aremoIncludeOutlines,moIncludeFormFields, andmoRenameConflictingFormFields- Outline destinations are remapped through the selected source-to-destination page map, while imported form roots are registered in the destination AcroForm
THotPDF.InsertLoadedBlankPageinserts a caller-sized blank page at an exact zero-based positionTHPDFWatermarkTemplate.MakeCurveadds a cubic Bezier curve to ordered composite loaded-page watermarksTHPDFPage.AddCurveWatermarkprovides the same cubic Bezier primitive during new-document authoring- Loaded document metadata setters mark the Info dictionary dirty so incremental saves retain edited fields
BeginIncrementalUpdatekeeps the source file write-locked and file-backed with a bounded tail probe instead of retaining the complete file in memorySaveIncrementalUpdatevisits only tracked changes, streams the source prefix to a new target, and uses validated rollback-protected direct append for the same targetOpenLoadedPageContentStreamexposes single and array/Contentsvalues as one seekable logical stream, retains unfiltered segments in source-backed storage, and decodes at most one filtered segment at a time- Editing a page whose
/Contentsvalue is an array appends a fresh indirect segment without coalescing or clearing the original streams, while rendering and compatibility materialization use geometrically growing token and byte buffers - Loaded annotation setters update contents, title, unique name, modification date, rectangle, flags, color, and border style directly on the existing annotation object
- Annotation rectangle endpoints are normalized, dashed borders keep only positive dash lengths, and visual changes invalidate only the affected page's cached renders
ActivateLoadedLinksdetects bare web and email addresses from positioned glyph runs, creates borderless URI annotations, and skips matching existing links without rescanning the annotation list for every candidateExtractLoadedPagesTextToStreamwrites UTF-8 page text directly to a caller-owned stream with range, separator, and BOM controlsTHPDFViewerModelexposes page form-field hit testing and deterministic top-to-bottom keyboard navigation without creating a window- Loaded-signature verification supports RSA PKCS#1 v1.5, parameter-validated RSA-PSS, ECDSA, and RFC 3161 document and signature timestamps; strict byte-range checks report signed-revision length and unsigned trailing bytes while preserving caller stream position
THPDFSignatureInfo.CertificateTimeValidityclassifies certificate bounds and signed-time consistency without changing cryptographicsvValidsemanticsVerifyLoadedSignatureWithTrustbuilds the signer path to caller-supplied trust anchors and validates offline OCSP or CRL evidence, preferring per-signature VRI data before document-level DSS and caller evidenceAnalyzeLoadedSignatureRevisionswalks traditional, stream, hybrid, and compressed-object xref histories, classifies later changes as long-term validation, form filling and signing, annotations, or other modifications, and evaluates DocMDP and FieldMDP independentlySanitiseLoadedDocumentapplies JavaScript-only, active-content, or strict untrusted-document policies to the complete object graph, removes unreachable payload objects, and prepares a bounded compact rewriteScrubLoadedRedactionRemnantsremoves metadata, attachments, Redact annotations, unreachable resources, and retained incremental source bytes before a compact full rewrite- Bounded cross-reference recovery relocates intact xref sections or rebuilds validated direct-object offsets after damaged
startxrefand xref data, with caller-controlled scan budgets and structured diagnostics - Scalable loading keeps file stream bodies source-backed until mutation, lazily resolves compressed objects, and accepts custom
THPDFRandomAccessSourceimplementations DecodeLoadedStreamToStreamruns bounded filter chains into caller-owned streams while document-wide byte accounting, filter-count limits, indirect-reference cycle checks, and pipeline-depth guards protect hostile inputsExtractLoadedImageToStreamcopies native image payloads or generic decoded filter output directly into caller-owned streams without materializing a full-size byte arrayExportLoadedPagesStructuredserializes semantic reading order, tables, geometry, styles, and bounded image occurrences as HTML, XHTML, XML, or JSONExtractLoadedTypedTablesbuilds confidence-scored canonical grids with merged spans, repeated headers, cross-page continuation, typed values, and atomic CSV or JSON exportOptimizeLoadedStreamsselects unfiltered, Flate, LZW, ASCII85, ASCIIHex, and RunLength candidates, spills large work buffers to temporary files, can run budgeted Zopfli after a four-strategy zlib baseline, and adopts only replacements that meet a positive savings thresholdSubsetLoadedFontsremoves unreachable glyph programs from supported embedded TrueType and CFF fonts after tracing page, Form XObject, and annotation appearance content, while preserving existing character, CID, glyph, width, and ToUnicode mappingsSetDocumentAttachmentMetadatarenames an embedded file and updates its description before the document is savedTHPDFLoadedFormFieldexposes flags, MaxLen, page index, bounds, and common text-field behaviors for property inspectorsTHPDFViewerModelcreates caller-owned page snapshots and writes the current page as BMP, JPEG, or PNG to files and streams while reusing the loaded render cacheTHPDFViewerModelrotates the current view and generated snapshots in 90-degree steps without modifying the loaded PDF pageTHPDFViewerModelcreates rotation-aware enhanced metafiles while retaining scalable text and vector drawing recordsTHPDFViewer.DrawCurrentViewandPrintCurrentViewfit and center the active vector view on a caller canvas or printer pageTHPDFViewerModel.ProcessKeyInputprovides testable page and zoom commands while the Viewer handles arrow-key scrollingTHPDFViewerModel.ProcessMouseWheelprovides testable Ctrl+wheel zoom while the Viewer handles vertical and horizontal scrolling directlyTHPDFViewerModel.GetNextZoomLevelandGetPreviousZoomLevelexpose deterministic standard zoom navigation from 5% through 6400%THPDFViewerModel.PagePointToViewandViewPointToPageprovide reversible coordinates across page rotation, view rotation, page box offsets, and DPITHPDFViewerModel.CreatePageRegionSnapshotrenders only the requested PDF rectangle for bounded-memory selection snapshotsTHPDFViewer.ResetViewrestores presentation defaults without unloading the document or changing the current page
Forms and search
THotPDF.AddLoadedRadioButtoncreates a parent radio field with child widgets, shared export values, and valid on/off appearance states- Loaded form fields can update flags, maximum length, justification, tooltip, per-widget rectangles, rotation, visibility, printing, border width and color, and background color with incremental-save dirty tracking
GetLoadedFormFieldNameValuePairsandSetLoadedFormFieldNameValuePairsexchange lightweightname=valuebatches throughTStringsExtractLoadedPagesTextaggregates a one-based page range with a caller-selected separatorCMapResourcePathoverrides automatic CMap discovery with a caller-selected root containing the standard collection folders- Assigning
CMapResourcePathclears loaded-font decoders even when the path is unchanged; callHPDFClearCMapCachesfirst when replaced external resources must also be reloaded - Standard CMap mappings are cached per resolved resource root, support concurrent table access, and use logarithmic lookup when character and range tables are ordered
- Complete UniJIS, UniGB, UniCNS, and UniKS UCS2 and UTF16 mappings are embedded for horizontal and vertical text, including supplementary scalars and standard vertical defaults when
/DW2is absent - Loaded-font decoders use a document-scoped 32 MiB weighted LRU cache shared by text extraction, SVG export, text replacement, and explicit decoder requests
GetLoadedFontDecoderreturns an independent deep copy while internal read-only consumers reuse the cached parsed coreLoadedFontDecoderCacheMaxBytes,GetLoadedFontDecoderCacheInfo, andResetLoadedFontDecoderCacheStatisticscontrol and measure cache reuse- Low-resolution grayscale and RGB JPEG regions use reduced inverse-DCT scaling and direct scanline resampling without materializing a full-resolution raster
GetLastJPEGReducedDecodeInforeports source, scaled, output, scanline, and working-memory geometry for the latest compatible requestAcquireLoadedImageStreamandAcquireLoadedImageRegionAtResolutionreturn immutable shared handles without warm-hit pixel copies, while the cachedTBitmapmethods preserve caller-owned compatibilityGetImageDecodeConcurrencyInforeports active flights, peak parallel owner decodes, duplicate waits, completions, and failuresTHotPDF.SearchLoadedNextis a stateless page-local search primitive that moves forward from a previousTHPDFTextMatchTHPDFLoadedDocumentFacadegroups loaded forms, annotations, outlines, fonts, and images into typed collection objectsTHPDFLoadedFormInfoincludes the current and default value, field type, description, read-only flag, and choice options
Outlines and resources
THotPDF.GetLoadedOutlineEntriesreturns a complete preorder snapshot asTHPDFLoadedOutlineEntryArray- Each
THPDFLoadedOutlineEntryhas an index, parent index, level, title, and resolved destination page index THPDFLoadedOutlineInfoexposes the same hierarchy throughTHPDFLoadedOutlineCollectionTHPDFLoadedResourceCollectionenumerates fonts and loaded images and can extract supported images as caller-owned bitmaps
System certificate signing
THotPDF.SignPDFWithSystemCertificatesigns file or stream input through a Windows certificate-store private keyTHotPDF.GetLoadedSignaturePermissionsreads DocMDP, Catalog permission linkage, SigFieldLock, and FieldMDP structures intoTHPDFSignaturePermissionInfowithout treating structural policy as cryptographic validityTHPDFCertificateStoreSelectorselects current-user or local-machine scope, store name, SHA-1 thumbprint, and whether key-provider UI is allowedTHPDFCMSSignDigestCallbackandHPDFCMSSignPDFStreamWithExternalSignerprovide the underlying external-digest signer hook- CNG keys use RSA PKCS#1 SHA-256 signing and legacy CSP keys use the equivalent CryptoAPI path
Printing
THPDFPrintOptionssupports collated copies, paper code, custom paper width and length, orientation, duplex, bin, and qualityTHPDFPrinterCapabilitiesreports parallel paper codes, names, and physical sizes alongside bins, resolutions, duplex, color, and maximum copiesHPDFBuildPrintPageSequenceexposes the deterministic physical page sequence used for collated and uncollated jobs
VCL viewer components
THPDFViewerModelowns navigation, zoom state, text-search results, wrapping, and change notifications without creating a windowTHPDFViewerrenders the selected page into a scrollable cached bitmap, supports actual size, fit page, fit width, custom zoom, and view rotation, and draws current search hits over the rendered pageTHPDFSearchPanelconnects search text, case sensitivity, whole-word matching, and next or previous navigation to a viewerTHPDFOutlineViewerdisplays the full recursive bookmark tree, follows document changes from the linked viewer, and navigates the linked viewerTHPDFViewerActiondescendants provide first, prior, next, last, zoom, fit, rotation, reset, find-next, and clear-search actions
Minimal viewer setup
PDF.LoadFromFile('input.pdf');
PDFViewer.PDFDocument := PDF;
OutlineViewer.Viewer := PDFViewer;
SearchPanel.Viewer := PDFViewer;
PDFViewer.ZoomMode := vzmFitWidth;
Ownership and indexing
- Loaded page indexes and destination page indexes are zero-based
- Page-range strings are one-based and use the same parser as extraction and printing
- Facade records are snapshots and collection mutation methods operate on the current loaded document
- Extracted bitmaps are owned by the caller
Related typed inspection and placement records
THPDFPageElementKind,THPDFPageElement, andTHPDFBaselineRoledescribe text, image, path, and baseline results returned by loaded page-element inspectionTHPDFWatermarkKind,THPDFWatermarkHorizPos, andTHPDFWatermarkVertPosselect the content and placement of loaded-document watermarks