THotPDF Advanced Workflow Methods

This page collects advanced public THotPDF methods that support loaded-document repair, file-backed rewriting, xref-stream parsing, conformance output, and shaping workflows

Prefer the task-focused pages such as page operation methods, loaded form field methods, utility methods, CMS validation reports, PDF/UA-2 structure, and ShapingFeatures for common application code

Loaded Document Resolution

Method Usage
DoPageOperationProgressSupports loaded-document resolution, form-field lookup, encryption metadata, or object-number bookkeeping in advanced workflows
ResolveLoadedObjectSupports loaded-document resolution, form-field lookup, encryption metadata, or object-number bookkeeping in advanced workflows
ResolveLoadedDictionarySupports loaded-document resolution, form-field lookup, encryption metadata, or object-number bookkeeping in advanced workflows
ResolveLoadedArraySupports loaded-document resolution, form-field lookup, encryption metadata, or object-number bookkeeping in advanced workflows
EnsureLoadedRootIndexSupports loaded-document resolution, form-field lookup, encryption metadata, or object-number bookkeeping in advanced workflows
MaterializeLazyStreamsSupports loaded-document resolution, form-field lookup, encryption metadata, or object-number bookkeeping in advanced workflows
FindLoadedFormFieldByIndexSupports loaded-document resolution, form-field lookup, encryption metadata, or object-number bookkeeping in advanced workflows
FindLoadedFormFieldByNameSupports loaded-document resolution, form-field lookup, encryption metadata, or object-number bookkeeping in advanced workflows
ConfigurePDFVersionSupports loaded-document resolution, form-field lookup, encryption metadata, or object-number bookkeeping in advanced workflows
RecoverReloadFEKFromBytesSupports loaded-document resolution, form-field lookup, encryption metadata, or object-number bookkeeping in advanced workflows
LoadedEncryptVersionSupports loaded-document resolution, form-field lookup, encryption metadata, or object-number bookkeeping in advanced workflows
IsObjStmMemberObjectSupports loaded-document resolution, form-field lookup, encryption metadata, or object-number bookkeeping in advanced workflows
SyncMaxObjNumFromLoadedObjectsSupports loaded-document resolution, form-field lookup, encryption metadata, or object-number bookkeeping in advanced workflows

Direct File State and Rewrite

Method Usage
ClearDirectFileStateSupports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling
GetDirectFileIndexSupports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling
DAFindReplacementIndexSupports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling
DAReadObjectSourceSupports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling
DAStoreObjectSourceSupports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling
DAAppendObjectSourceInternalSupports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling
DATryBuildCompressedFileStateSupports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling
DADirectLoadObjectFromBodySupports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling
DARecoverAES256FileKeySupports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling
DADirectPrepareObjectForAES256EncryptSupports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling
DADirectDecryptObjectAES256Supports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling
DAWriteDirectAES256RewriteSupports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling
DADirectEncryptFileAES256Supports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling
DADirectDecryptFileAES256Supports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling
DAWriteFullRewriteSupports file-backed direct rewriting, AES-256 encryption or decryption, and object-source state handling

XRef Stream and Object Parsing

Method Usage
LoadXRefStreamDocumentaesgcmUses the bounded-memory Direct File path to emit PDF 2.0 AESV4 streams with incremental CTR and GHASH processing
DecryptFileAuthenticates every AESV4 stream before atomically replacing the requested output file
AddStandalonePDFMACAdds a fixed 32-byte KDFSalt, a direct standalone AuthCode, exact full-file ByteRange coverage, CMS AuthenticatedData, and selectable SHA-2 or SHA-3 document digests
SignPDFWithPFXAndAttachedPDFMACCreates one encrypted signed revision with a direct /AttachedToSig trailer binding, an indirect SigObjRef, and a PDF MAC unsigned attribute that authenticates the raw CMS signature value
ValidatePDFMACValidates standalone or signature-attached locations and returns distinct status values for invalid passwords, malformed data, unsupported algorithms, policy rejection, coverage failures, document modification, signature binding failures, and authentication failures
ValidatePDFMACChainValidates every incremental revision from oldest to newest with cumulative xref indexing and reports the exact revision for a missing, replaced, salt-changed, digest-downgraded, or permission-downgraded PDF MAC

Public-Key Encryption and Signature Evidence

MethodUsage
AddPubKeyRecipientCertificateBuilds an AES-256 CMS recipient envelope from an RSA certificate with explicit RSA-OAEP digest and MGF1 policies
AddPubKeyAgreementRecipientBuilds P-256, P-384, P-521, X25519, or X448 key-agreement recipient envelopes using X9.63 KDF and AES-256 key wrap
HPDFCMSBuildCounterSignerInfoCreates a countersignature whose signed messageDigest binds the parent signature value without a contentType attribute
HPDFVerifyCMSCounterSignaturesExtracts and verifies every CMS counterSignature value against its parent signature bytes
RenewPAdESLTATimestampAppends a validated RFC 3161 document timestamp while preserving every earlier PDF revision byte-for-byte

PDF/UA-2 Structure

MethodUsage
AddStructRoleMapNSAdds a namespace-aware role mapping with a default PDF 1.7 or explicit target namespace
SetStructureAttributeNameAdds or replaces a name-valued attribute in an owner-specific structure attribute dictionary
SetStructureAttributeNumberAdds or replaces an integer-valued structure attribute
SetStructureTableCellHeadersWrites explicit table header identifiers for a header or data cell
AssociateFileWithStructureAssociates an indirect Filespec with a structure element
AddAccessibleFormulaCreates a Formula structure element with alternative or actual text
AddAccessibleMathMLFormulaCreates a Formula with an associated MathML file and MathML namespace child
ValidatePDFUA2StructureRuns bounded one-pass validation and returns typed issues or shared machine-readable findings with clause, object, and page locations
RepairPDFUA2StructureAtomically normalises recoverable PDF/UA-2 namespaces, structure attributes, semantic containers, accessibility text, language inheritance, heading order, and Artifact tags and can report per-finding repair provenance
ComplianceFindingsToJSONSerialises shared PDF/UA-2, PDF/A-4, and PDF/X-6 findings as deterministic versioned JSON

Stable Native C ABI

ExportUsage
hpdf_document_createCreates a validated opaque document handle through a flat cdecl boundary
hpdf_document_load_from_ioLoads from versioned 64-bit random-access callbacks without a complete-source staging buffer
hpdf_document_save_to_ioStreams serialised bytes to a callback and retries partial writes until each chunk is complete
hpdf_document_page_countReturns the loaded page count through a fixed-width output pointer
hpdf_document_destroyReleases a registered handle and rejects repeated destruction

Deterministic Differential Regression

FunctionUsage
HPDFProbeHotPDFDocumentProduces bounded SHA-256 parse, render, text, or save fingerprints with domain-specific normalisation
HPDFCompareRegressionResultsDeterministicRepeats two named engine probes, rejects instability and isolated exceptions, and compares selected domains in fixed order
HPDFDifferentialRegressionInfoToJSONSerialises signatures, instability, errors, counts, engine names, and the input digest as hotpdf.differential.v1

Continuous Malformed-PDF Corpus

FunctionUsage
HPDFDefaultCorpusStoreOptionsReturns bounded minimisation, input, storage, and lock-retry defaults
HPDFMinimizeAndStoreCorpusCaseRevalidates and re-minimises matching cases under one process-safe lock, then atomically retains the smallest signature-equivalent PDF
HPDFCorpusCaseInfoToJSONSerialises the stable case ID, failure signature, content digest, and byte count as hotpdf.corpus.case.v1

PDF/X-6 Exchange

MethodUsage
AddPDFX6PageOutputIntentAttaches an embedded ICC output intent to one PDF 2.0 page
AddPDFX6ExternalOutputIntentAdds an external PDF/X-6p or N-colourant PDF/X-6n output profile reference at catalogue or page scope
ValidatePDFX6Runs bounded non-mutating PDF/X-6 validation with typed or shared clause-aware object and page diagnostics

XRef Stream and Object Parsing

Method Usage
LoadXRefStreamDocumentFromFileSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
LoadXRefStreamDocumentEncFromFileSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
XRefProbeObjCountSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
XRefProbeObjNumSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
XRefProbeCompactCountSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
XRefProbeType2MismatchesSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
XRefProbeObjHasKeySupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
XRefProbeObjNameValSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
XRefProbeCompactObjNumSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
XRefProbeType2EncryptedSkippedSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
XRefProbeCountReplacementCharsSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
XRefProbeObjStringValSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
XRefProbeDecryptObjStmSkipsSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
TryParseModernPDFSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
CreateBasicPageContentSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
CreatePDF16PageReferenceSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
CreateBasicResourcesSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
CreatePDF16ResourcesSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ParseSimplePageObjectSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ParseRealPageContentSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ProcessObjectStreamsForDecompressionSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ScanAndLoadReferencedObjectsSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ForceLoadMissingReferencedObjectsSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
FindAllObjectStreamsSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ExtractStreamParametersSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ProcessFlateDecodeSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
AnalyzePageObjectSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ExtendPageArrSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ParseSimpleDictionarySupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ParseSimpleArraySupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF filesTHPDFDictionaryObject
ParseSimpleStreamSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF filesTHPDFArrayObject
ParseSimpleStreamParses a stream body into a THPDFStreamObject
FindAndProcessObjectStreamSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ExtractObjectFromStreamSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ExtractRawObjectFromStreamSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
IsObjectInStreamSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
GetObjectFromStreamSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ParseModernPageObjectSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
IntelligentDecompressSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
DecompressFlateDecodeSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ParseObjectStreamSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ReorderPageArrByPagesTreeSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
GetCorrectPageOrderFromPagesTreeSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
GetPageObjectIdSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
GetPageArrIndexForObjectNumberSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ExtractNumericValueSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ParseDecompressedObjectsSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
LoadCompressedXrefStreamSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
LoadObjectStreamsDirectlySupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ParseXrefStreamDataSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files
ProcessObjectStreamObjectsSupports xref-stream and object-stream parsing, recovery, and diagnostics for modern PDF files

Conformance and Font Output

Method Usage
BuildAndApplyUnicodeFontSubsetSupports Unicode font-subset sharing and PDF/A, PDF/X, or PDF/UA conformance checks during output
EnsurePDFUATabsOnAnnotatedPagesSupports Unicode font-subset sharing and PDF/A, PDF/X, or PDF/UA conformance checks during output
EnsurePDFAOutputIntentSupports Unicode font-subset sharing and PDF/A, PDF/X, or PDF/UA conformance checks during output
EnsurePDFAColorSpaceConsistencySupports Unicode font-subset sharing and PDF/A, PDF/X, or PDF/UA conformance checks during output
EmitDocumentDefaultColorSpacesSupports Unicode font-subset sharing and PDF/A, PDF/X, or PDF/UA conformance checks during output
EnsurePDFXOutputIntentSupports Unicode font-subset sharing and PDF/A, PDF/X, or PDF/UA conformance checks during output
EnsurePDFXPageBoxesSupports Unicode font-subset sharing and PDF/A, PDF/X, or PDF/UA conformance checks during output
ValidatePDFX6GenerationProfileFails closed when the selected PDF/X-6 generation graph violates the profile
_FindPAdESDSSStreamByDERFinds an existing DSS stream whose DER bytes match a certificate, OCSP response, or CRL while building PAdES VRI references

Advanced Shaping Helpers

Method Usage
ApplyArabicGSUBPositionalApplies Arabic positional GSUB substitutions and maps shaped glyph IDs through synthetic codepoints
ArabicGSUBShapeToGIDsReturns the Arabic GSUB-shaped glyph-ID sequence without emitting text
ApplyArabicGSUBNativeShapingApplies native Arabic GSUB shaping for fonts that provide positional glyph substitutions
ApplyLatinLigatureFeatureApplies a named Latin ligature feature such as liga or clig to a Unicode run
ApplyLatinSingleSubstitutionFeatureApplies a named Latin single-substitution feature to a Unicode run
ApplyLatinFractionFeatureApplies the frac feature to a numeric fraction run when the font supplies the required substitutions
ApplyArabicGSUBPositionalSupports advanced GSUB shaping, glyph mapping, and synthetic-codepoint workflows before text emission
ArabicGSUBShapeToGIDsSupports advanced GSUB shaping, glyph mapping, and synthetic-codepoint workflows before text emission
ApplyArabicGSUBNativeShapingSupports advanced GSUB shaping, glyph mapping, and synthetic-codepoint workflows before text emission
ApplyLatinLigatureFeatureSupports advanced GSUB shaping, glyph mapping, and synthetic-codepoint workflows before text emission
ApplyLatinSingleSubstitutionFeatureSupports advanced GSUB shaping, glyph mapping, and synthetic-codepoint workflows before text emission
ApplyLatinFractionFeatureSupports advanced GSUB shaping, glyph mapping, and synthetic-codepoint workflows before text emission
ApplyArabicGSUBRefinementSupports advanced GSUB shaping, glyph mapping, and synthetic-codepoint workflows before text emission

See also