Compression Overview

ภาพรวม

HotPDF ใช้ compression และ decompression paths หลายแบบ ขึ้นอยู่กับว่ากำลังสร้าง PDF content ใหม่ หรืออ่าน streams และ images ที่มีอยู่จาก external files

Main Compression Paths

  • FlateDecode: ใช้กับ generated PDF streams ผ่าน THotPDF.Compression และ backed โดย zlib-ng ใน zlib-compatible mode พร้อม 64-bit runtime SIMD dispatch เมื่อมี
  • CompressionLevel: THotPDF.CompressionLevel เลือก clNone, clFastest, clDefault, หรือ clMaximum สำหรับ enhanced Flate paths
  • LZWDecode: รองรับ legacy PDF และ TIFF-style data ผ่าน HPDFLZW.pas
  • DCT/JPEG: ใช้กับ standard JPEG image workflows ที่ HotPDF image support จัดการ และ backed โดย libjpeg-turbo 3.1.90 พร้อม NASM SIMD acceleration objects
  • JBIG2: specialized bilevel image decoding support สำหรับ scanned/document-style content

การลดขนาดเชิงโครงสร้างสำหรับ PDF 1.5+

สำหรับ PDF 1.5+ output HotPDF สามารถวาง structural compression เพิ่มอีก 2 paths บน FlateDecode-compressed streams ทั้งสองเป็น opt-in และทำงานร่วมกันโดยธรรมชาติ:

  • UseXRefStream: แทน textual xref ... trailer cross-reference table ด้วย compressed /Type /XRef stream (ISO 32000-1 7.5.8) ช่วยลด xref overhead ได้ 4-10 เท่าใน documents ขนาดใหญ่
  • UseObjectStreams: pack small indirect dictionaries (multi-page documents, annotations, AcroForm widgets, structure-tree elements, Optional Content layers) เข้า /Type /ObjStm container streams (ISO 32000-1 7.5.7) ที่อ้างผ่าน type-2 xref entries ต้องเปิด UseXRefStream ด้วย smoke 30-page แบบ graphics-only ลดจาก 14502 เป็น 8488 bytes (-41.5%) เมื่อใช้ toggles ทั้งคู่ร่วมกัน
  • copy decompression: DecompressForCopy และ OriginallyCompressed อธิบายว่า loaded-document copy paths materialize compressed source streams อย่างไร

Related Units

  • HPDFZLib.pas สำหรับ FlateDecode และ predictor-aware inflate helpers
  • HPDFLZW.pas สำหรับ LZW decompression
  • HPDFJBIG2.pas สำหรับ JBIG2 decoding support
  • HPDFJpeg2000.pas และ HPDFOpenJpeg.pas สำหรับ JPEG2000-related workflows

See Also