已載入文件工具組
HotPDF 可以開啟既有 PDF、執行頁面與表單操作、檢視強型別的文件狀態、轉譯或搜尋頁面、依裝置能力列印,然後儲存結果,整個流程不必換到其他函式庫
頁面操作與合併
THotPDF.DeletePages接受標準的 1 起始頁面範圍語法,重複選取只會去除一次,並保留合法的頁面樹- 刪除已載入頁面時,會一併卸離只隸屬於被刪頁面的 widget 標註與空 AcroForm 欄位分支
THotPDF.InsertPagesFromDocument與THotPDF.AppendPagesFromDocument都接受THPDFMergeOptions- 停用自動重新命名時,插入頁面前會先檢查表單名稱衝突,因此被拒絕的合併不會改變目的文件的頁數
THPDFMergeOption的值為moIncludeOutlines、moIncludeFormFields與moRenameConflictingFormFields- 書籤目的地會依選定的來源到目的頁面對應重新映射;匯入的表單根節點則註冊到目的 AcroForm
THotPDF.InsertLoadedBlankPage會在精確的 0 起始位置插入呼叫端指定大小的空白頁THPDFWatermarkTemplate.MakeCurve會在有序複合的已載入頁面浮水印中加入三次貝茲曲線THPDFPage.AddCurveWatermark在新文件編寫時提供相同的三次貝茲曲線基本圖元- 已載入文件的中繼資料 setter 會把 Info 字典標記為待寫回,增量儲存才能保留編輯過的欄位
ExtractLoadedPagesTextToStream把 UTF-8 頁面文字直接寫進呼叫端持有的串流,可控制範圍、分隔符與 BOMTHPDFViewerModel提供頁面表單欄位點擊測試與確定性的由上而下鍵盤導覽,不需要建立視窗THPDFSignatureInfo.CertificateTimeValidity會分類憑證有效期邊界與簽章時間的一致性,不改變svValid的密碼學語義SetDocumentAttachmentMetadata會在文件儲存前重新命名內嵌檔案並更新其描述- Annotation rectangle endpoints are normalised, dashed borders keep only positive dash lengths, and visual changes invalidate only the affected page's cached renders
THPDFLoadedFormField為屬性檢視器公開旗標、MaxLen、頁面索引、邊界與常用的文字欄位行為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- 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 materialising a full-size byte arrayExportLoadedPagesStructuredserialises 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 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.PagePointToViewandTHPDFViewerModel會建立呼叫端持有的頁面快照,並在重用已載入轉譯快取的同時,把目前頁面直接輸出成 BMPTHPDFViewerModel能以 90 度為單位旋轉目前檢視與產生的快照,不會更動已載入的 PDF 頁面THPDFViewer.ResetView會還原顯示預設值,不卸載文件也不改變目前頁面
表單與搜尋
THotPDF.AddLoadedRadioButton會建立父階選項按鈕欄位,含子 widget、共用匯出值與合法的 on/off 外觀狀態GetLoadedFormFieldNameValuePairs與SetLoadedFormFieldNameValuePairs透過TStrings交換輕量的name=value批次ExtractLoadedPagesTextaggregates 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 materialising 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 cachedExtractLoadedPagesText彙整 1 起始頁面範圍的文字,分隔符由呼叫端指定CMapResourcePath可用呼叫端指定的根目錄覆蓋自動 CMap 尋找,該目錄須包含標準集合資料夾THotPDF.SearchLoadedNext是無狀態的頁內搜尋基本操作,從前一個THPDFTextMatch繼續向前搜尋THPDFLoadedDocumentFacade把已載入的表單、標註、書籤、字型與影像整理成強型別集合物件THPDFLoadedFormInfo包含目前值與預設值、欄位類型、描述、唯讀旗標與選項清單
書籤與資源
THotPDF.GetLoadedOutlineEntries以THPDFLoadedOutlineEntryArray傳回完整的前序走訪快照- 每個
THPDFLoadedOutlineEntry都有索引、父索引、層級、標題與解析後的目的頁面索引 THPDFLoadedOutlineInfo透過THPDFLoadedOutlineCollection公開相同的階層結構THPDFLoadedResourceCollection可列舉字型與已載入影像,並能將支援的影像擷取成呼叫端持有的點陣圖
系統憑證簽署
THotPDF.SignPDFWithSystemCertificatesigns file or stream input through a Windows certificate-store private keyTHotPDF.GetLoadedSignaturePermissionsreads DocMDP, Catalog permission linkage, SigFieldLock, and FieldMDP structures intoTHotPDF.SignPDFWithSystemCertificate透過 Windows 憑證存放區的私密金鑰簽署檔案或串流輸入THPDFCertificateStoreSelector可選擇目前使用者或本機範圍、存放區名稱、SHA-1 指紋,以及是否允許金鑰提供者 UITHPDFCMSSignDigestCallback與HPDFCMSSignPDFStreamWithExternalSigner提供底層的外部摘要簽署掛鉤- CNG 金鑰採 RSA PKCS#1 SHA-256 簽署,舊式 CSP 金鑰則走對等的 CryptoAPI 路徑
列印
THPDFPrintOptions支援逐份列印、紙張代碼、自訂紙張寬度與長度、方向、雙面、紙匣與品質THPDFPrinterCapabilities可回報對應的紙張代碼、名稱與實際尺寸,以及紙匣、解析度、雙面、彩色與最大份數HPDFBuildPrintPageSequence公開確定性的實體頁面順序,供逐份與非逐份列印工作使用
VCL 檢視器元件
THPDFViewerModel管理導覽、縮放狀態、文字搜尋結果、換行與變更通知,不需要建立視窗THPDFViewer把所選頁面轉譯成可捲動的快取點陣圖,支援實際大小、符合頁面、符合寬度、自訂縮放與檢視旋轉,並在轉譯後的頁面上疊顯目前的搜尋命中THPDFSearchPanel把搜尋文字、區分大小寫、全字匹配與上一個/下一個導覽接到檢視器THPDFOutlineViewer顯示完整的遞迴書籤樹,跟隨連結檢視器的文件變更,也能導覽該檢視器THPDFViewerAction的衍生類別提供第一頁、上一頁、下一頁、最後一頁、縮放、符合、旋轉、重設、找下一個與清除搜尋等動作
最小檢視器設定
PDF.LoadFromFile('input.pdf');
PDFViewer.PDFDocument := PDF;
OutlineViewer.Viewer := PDFViewer;
SearchPanel.Viewer := PDFViewer;
PDFViewer.ZoomMode := vzmFitWidth;
所有權與索引
- 已載入頁面索引與目的頁面索引都以 0 為起始
- 頁面範圍字串以 1 為起始,與擷取和列印共用同一個解析器
- Facade 記錄是快照,集合的變更方法都作用於目前載入的文件
- 擷取出來的點陣圖由呼叫端持有
相關的強型別檢視與放置記錄
THPDFPageElementKind、THPDFPageElement與THPDFBaselineRole描述已載入頁面元素檢視所傳回的文字、影像、路徑與基準線結果THPDFWatermarkKind、THPDFWatermarkHorizPos與THPDFWatermarkVertPos決定已載入文件浮水印的內容與位置