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
- Loaded annotation setters update contents, title, unique name, modification date, rectangle, flags, colour, and border style directly on the existing annotation object
- Annotation rectangle endpoints are normalised, 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 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 materialising a full-size byte arrayOptimizeLoadedStreamsselects unfiltered, Flate, LZW, ASCII85, ASCIIHex, and RunLength candidates, spills large work buffers to temporary files, and adopts only replacements that meet a positive savings thresholdSetDocumentAttachmentMetadatarenames an embedded file and updates its description before the document is savedTHPDFLoadedFormFieldexposes flags, MaxLen, page index, bounds, and common text-field behaviours 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 centre 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, MediaBox 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 colour, and background colour 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- Standard CMap mappings are cached per resolved resource root, shared safely by concurrent extractors, and use logarithmic lookup when character and range tables are ordered
THotPDF.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, colour, 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