@libpdf/core 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -182,6 +182,8 @@ declare class PdfName implements PdfPrimitive {
182
182
  static readonly Length: PdfName;
183
183
  static readonly Filter: PdfName;
184
184
  static readonly FlateDecode: PdfName;
185
+ /** Cached serialized form (e.g. "/Type"). Computed lazily on first toBytes(). */
186
+ private cachedBytes;
185
187
  private constructor();
186
188
  /**
187
189
  * Get or create an interned PdfName for the given string.
@@ -2675,6 +2677,8 @@ declare class EmbeddedFont extends PdfFont {
2675
2677
  private _subsetTag;
2676
2678
  /** Whether this font is used in a form field (prevents subsetting) */
2677
2679
  private _usedInForm;
2680
+ /** Pre-allocated PDF reference (set by PDFFonts.embed()) */
2681
+ private _ref;
2678
2682
  /** Cached descriptor */
2679
2683
  private _descriptor;
2680
2684
  private constructor();
@@ -2790,6 +2794,22 @@ declare class EmbeddedFont extends PdfFont {
2790
2794
  * Call this before re-encoding if you want a fresh subset.
2791
2795
  */
2792
2796
  resetUsage(): void;
2797
+ /**
2798
+ * Get the pre-allocated PDF reference for this font.
2799
+ *
2800
+ * Set by `PDFFonts.embed()`. At save time, the actual font objects
2801
+ * (Type0 dict, CIDFont, FontDescriptor, font program, ToUnicode)
2802
+ * are created and registered at this ref.
2803
+ *
2804
+ * @throws {Error} if the font was not embedded via `pdf.embedFont()`
2805
+ */
2806
+ get ref(): PdfRef;
2807
+ /**
2808
+ * Set the pre-allocated PDF reference.
2809
+ *
2810
+ * @internal Called by PDFFonts.embed()
2811
+ */
2812
+ setRef(ref: PdfRef): void;
2793
2813
  /**
2794
2814
  * Mark this font as used in a form field.
2795
2815
  *
@@ -4948,6 +4968,8 @@ interface ExtractedChar {
4948
4968
  fontName: string;
4949
4969
  /** Y coordinate of the text baseline */
4950
4970
  baseline: number;
4971
+ /** Index in the content stream extraction order (0-based) */
4972
+ sequenceIndex?: number;
4951
4973
  }
4952
4974
  /**
4953
4975
  * A span of text with the same font and size on the same line.
@@ -8709,6 +8731,24 @@ interface SaveOptions {
8709
8731
  * @default false
8710
8732
  */
8711
8733
  subsetFonts?: boolean;
8734
+ /**
8735
+ * Compress uncompressed streams with FlateDecode (default: true).
8736
+ *
8737
+ * When enabled, streams without a /Filter entry will be compressed
8738
+ * before writing. Streams that already have filters (including image
8739
+ * formats like DCTDecode/JPXDecode) are left unchanged.
8740
+ */
8741
+ compressStreams?: boolean;
8742
+ /**
8743
+ * Minimum stream size in bytes to attempt compression (default: 512).
8744
+ *
8745
+ * Streams smaller than this threshold are written uncompressed.
8746
+ * Deflate initialization has a fixed overhead that dominates for small
8747
+ * payloads, and tiny streams rarely achieve meaningful compression.
8748
+ *
8749
+ * Set to 0 to compress all streams regardless of size.
8750
+ */
8751
+ compressionThreshold?: number;
8712
8752
  }
8713
8753
  /**
8714
8754
  * Options for adding a new page.