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
BeginIncrementalUpdate让源文件保持写锁与文件承载状态,只用有界的尾部探测,而不是把完整文件驻留内存SaveIncrementalUpdate只访问被跟踪的更改,把源前缀流式写到新目标;对同一目标使用经验证、带回滚保护的直接追加OpenLoadedPageContentStream把单个或数组/Contents值暴露为一个可 seek 的逻辑流,未过滤段保留在源承载存储中,一次最多解码一个过滤段- 编辑
/Contents为数组的页面会追加新的间接段,不合并也不清除原始流;渲染与兼容物化使用几何增长的 token 与字节缓冲 - 已加载注释 setter 直接在既有注释对象上更新内容、标题、唯一名称、修改日期、矩形、标志、颜色和边框样式
- 注释矩形端点归一化,虚线边框只保留正的划线长度;视觉变化只使受影响页面的缓存渲染失效
ActivateLoadedLinks从定位字形 run 中检测裸网址与电子邮件地址,创建无边框 URI 注释,并跳过与既有链接匹配的候选,无需为每个候选重扫注释列表ExtractLoadedPagesTextToStreamwrites 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- 已加载签名验证支持 RSA PKCS#1 v1.5、参数校验的 RSA-PSS、ECDSA,以及 RFC 3161 文档与签名时间戳;严格的字节区间检查报告已签名修订长度和未签名的尾随字节,同时保留调用方流位置
THPDFSignatureInfo.CertificateTimeValidityclassifies certificate bounds and signed-time consistency without changing cryptographicsvValidsemanticsVerifyLoadedSignatureWithTrust构建到调用方提供信任锚的签名者路径,验证离线 OCSP 或 CRL 证据,优先每签名 VRI 数据,其次文档级 DSS 与调用方证据AnalyzeLoadedSignatureRevisions遍历传统、流式、混合与压缩对象 xref 历史,把后续更改分类为长期验证、表单填写与签名、注释或其他修改,并独立评估 DocMDP 与 FieldMDPSanitiseLoadedDocument对完整对象图应用仅 JavaScript、活跃内容或严格不可信文档策略,移除不可达载荷对象,并准备有界的紧凑重写ScrubLoadedRedactionRemnants在紧凑完整重写前移除元数据、附件、Redact 注释、不可达资源和保留的增量源字节- 有界交叉引用恢复 在
startxref与 xref 数据损坏后重新定位完整的 xref 区段或重建经验证的直接对象偏移,带调用方控制的扫描预算和结构化诊断 - 可扩展加载 让文件流体在修改前保持源承载,惰性解析压缩对象,并接受自定义
THPDFRandomAccessSource实现 DecodeLoadedStreamToStream把有界过滤链运行到调用方持有的流;全文档字节核算、过滤器数量限制、间接引用环检查和管线深度防护可抵御恶意输入ExtractLoadedImageToStream把原生图像载荷或通用解码过滤器输出直接拷贝进调用方持有的流,不物化全尺寸字节数组ExportLoadedPagesStructured把语义阅读顺序、表格、几何、样式与有界图像出现序列化为 HTML、XHTML、XML 或 JSONExtractLoadedTypedTables构建带置信度评分的规范网格,含合并 span、重复表头、跨页延续、类型化值和原子 CSV 或 JSON 导出OptimizeLoadedStreams在未过滤、Flate、LZW、ASCII85、ASCIIHex 与 RunLength 候选间选择,把大工作缓冲溢写到临时文件,可在四策略 zlib 基线后运行带预算的 Zopfli,只采纳达到正节省阈值的替换SubsetLoadedFonts在追踪页面、Form XObject 与注释外观内容后,从受支持的嵌入 TrueType 与 CFF 字体移除不可达字形程序,同时保留既有的字符、CID、字形、宽度和 ToUnicode 映射SetDocumentAttachmentMetadatarenames an embedded file and updates its description before the document is savedTHPDFLoadedFormField为属性检查器暴露标志、MaxLen、页索引、边界和常见文本字段行为THPDFViewerModelcreates caller-owned page snapshots and writes the current page directly as BMP while reusing the loaded render cacheTHPDFViewerModelrotates the current view and generated snapshots in 90-degree steps without modifying the loaded PDF pageTHPDFViewerModel创建旋转感知的增强图元文件,同时保留可缩放的文本与矢量绘图记录THPDFViewer.DrawCurrentView与PrintCurrentView把活动矢量视图适配并居中到调用方 canvas 或打印机页面THPDFViewerModel.ProcessKeyInput提供可测试的页面与缩放命令,方向键滚动仍由查看器处理THPDFViewerModel.ProcessMouseWheel提供可测试的 Ctrl+滚轮缩放,垂直与水平滚动仍由查看器直接处理THPDFViewerModel.GetNextZoomLevel与GetPreviousZoomLevel暴露确定性的标准缩放导航,范围 5% 到 6400%THPDFViewerModel.PagePointToView与ViewPointToPage在页面旋转、视图旋转、MediaBox 偏移与 DPI 之间提供可逆坐标THPDFViewerModel.CreatePageRegionSnapshot只渲染请求的 PDF 矩形,为有界内存的选择快照服务THPDFViewer.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 statesGetLoadedFormFieldNameValuePairs与SetLoadedFormFieldNameValuePairs通过 TStrings 交换轻量的name=value批次(经TStringsExtractLoadedPagesText聚合从 1 开始的页面范围,并用调用方选择的分隔符连接CMapResourcePathoverrides automatic CMap discovery with a caller-selected root containing the standard collection folders- 赋值
CMapResourcePath会清除已加载字体解码器,即使路径未变;被替换的外部资源需要一并重载时,请先调用HPDFClearCMapCaches - 标准 CMap 映射按解析出的资源根缓存,支持并发表访问,字符表与范围表有序时使用对数查找
- 内嵌完整的 UniJIS、UniGB、UniCNS、UniKS 的 UCS2 与 UTF16 映射,覆盖横排与竖排文本,包括补充标量以及
/DW2缺席时的标准竖排默认值 - 已加载字体解码器使用文档作用域的 32 MiB 加权 LRU 缓存,供文本提取、SVG 导出、文本替换与显式解码器请求共享
GetLoadedFontDecoder返回独立深拷贝;内部只读消费者复用缓存的解析核心LoadedFontDecoderCacheMaxBytes、GetLoadedFontDecoderCacheInfo与ResetLoadedFontDecoderCacheStatistics控制并度量缓存复用- 低分辨率灰度与 RGB JPEG 区域使用降采样逆 DCT 和直接扫描行重采样,不物化全分辨率光栅
GetLastJPEGReducedDecodeInfo报告最近一次兼容请求的源、缩放、输出、扫描行与工作内存几何AcquireLoadedImageStream与AcquireLoadedImageRegionAtResolution返回不可变共享句柄,热命中不拷贝像素;缓存的TBitmap方法保留调用方持有的兼容性GetImageDecodeConcurrencyInfo报告活动飞行、并行 owner 解码峰值、重复等待、完成与失败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.SignPDFWithSystemCertificate通过 Windows 证书存储私钥对文件或流输入签名THotPDF.GetLoadedSignaturePermissions把 DocMDP、Catalog 权限关联、SigFieldLock 和 FieldMDP 结构读入THPDFSignaturePermissionInfo,而不把结构性策略当作加密有效性THPDFCertificateStoreSelectorselects 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