|
Compression Overview
總覽
HotPDF 會依據正在產生新的 PDF 內容,或是從外部檔案讀取既有 streams 與 images,使用不同的壓縮與解壓縮路徑
Main Compression Paths
- FlateDecode: 透過 THotPDF.Compression 用於產生的 PDF streams,並由 zlib-ng 的 zlib 相容模式支援;可用時會使用 64-bit runtime SIMD dispatch
- CompressionLevel: THotPDF.CompressionLevel selects
clNone, clFastest, clDefault, or clMaximum for enhanced Flate paths.
- LZWDecode: 透過 HPDFLZW.pas 支援舊版 PDF 與 TIFF 風格資料
- DCT/JPEG: 用於 HotPDF 影像支援處理的標準 JPEG 影像工作流程,並由含 NASM SIMD 加速物件的 libjpeg-turbo 3.1.90 支援
- JBIG2 and JPEG2000: 可用於來源格式本身已使用這些 codecs 的專門影像工作流程
PDF 1.5+ structural size reduction
對於 PDF 1.5+ 輸出,HotPDF 可以在 FlateDecode 壓縮 streams 之上再疊加兩個額外的結構壓縮路徑。兩者皆為選用,且自然成對使用:
- UseXRefStream: Replace the textual
xref ... trailer cross-reference table with a compressed /Type /XRef stream (ISO 32000-1 7.5.8). Cuts xref overhead by 4-10x on large documents.
- UseObjectStreams: 將小型 indirect dictionaries(多頁檔案、註解、AcroForm widgets、structure-tree elements、Optional Content layers)封裝到
/Type /ObjStm container streams (ISO 32000-1 7.5.7),並透過 type-2 xref entries 參照。也需要啟用 UseXRefStream。兩個開關合併使用時,一份 30 頁純圖形 smoke 檔案會從 14502 bytes 縮小到 8488 bytes(-41.5%)
- Copy decompression: DecompressForCopy and
OriginallyCompressed describe how loaded-document copy paths materialize compressed source streams.
Related Units
- HPDFZLib.pas for FlateDecode and predictor-aware inflate helpers
- HPDFLZW.pas for LZW decompression
- HPDFJBIG2.pas for JBIG2 decoding support
- HPDFJpeg2000.pas and HPDFOpenJpeg.pas for JPEG2000-related workflows
請參閱
|