@libpdf/core 0.2.4 → 0.2.6

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
@@ -1543,6 +1543,110 @@ declare function rectToQuadPoints(rect: Rect): number[];
1543
1543
  */
1544
1544
  declare function rectsToQuadPoints(rects: Rect[]): number[][];
1545
1545
  //#endregion
1546
+ //#region src/content/operators.d.ts
1547
+ /** Valid operand types */
1548
+ type Operand = number | string | PdfName | PdfString | PdfArray | PdfDict;
1549
+ /** All PDF content stream operator names */
1550
+ declare const Op: {
1551
+ readonly PushGraphicsState: "q";
1552
+ readonly PopGraphicsState: "Q";
1553
+ readonly ConcatMatrix: "cm";
1554
+ readonly SetLineWidth: "w";
1555
+ readonly SetLineCap: "J";
1556
+ readonly SetLineJoin: "j";
1557
+ readonly SetMiterLimit: "M";
1558
+ readonly SetDashPattern: "d";
1559
+ readonly SetRenderingIntent: "ri";
1560
+ readonly SetFlatness: "i";
1561
+ readonly SetGraphicsState: "gs";
1562
+ readonly MoveTo: "m";
1563
+ readonly LineTo: "l";
1564
+ readonly CurveTo: "c";
1565
+ readonly CurveToInitial: "v";
1566
+ readonly CurveToFinal: "y";
1567
+ readonly ClosePath: "h";
1568
+ readonly Rectangle: "re";
1569
+ readonly Stroke: "S";
1570
+ readonly CloseAndStroke: "s";
1571
+ readonly Fill: "f";
1572
+ readonly FillCompat: "F";
1573
+ readonly FillEvenOdd: "f*";
1574
+ readonly FillAndStroke: "B";
1575
+ readonly FillAndStrokeEvenOdd: "B*";
1576
+ readonly CloseFillAndStroke: "b";
1577
+ readonly CloseFillAndStrokeEvenOdd: "b*";
1578
+ readonly EndPath: "n";
1579
+ readonly Clip: "W";
1580
+ readonly ClipEvenOdd: "W*";
1581
+ readonly SetCharSpacing: "Tc";
1582
+ readonly SetWordSpacing: "Tw";
1583
+ readonly SetHorizontalScale: "Tz";
1584
+ readonly SetLeading: "TL";
1585
+ readonly SetFont: "Tf";
1586
+ readonly SetTextRenderMode: "Tr";
1587
+ readonly SetTextRise: "Ts";
1588
+ readonly BeginText: "BT";
1589
+ readonly EndText: "ET";
1590
+ readonly MoveText: "Td";
1591
+ readonly MoveTextSetLeading: "TD";
1592
+ readonly SetTextMatrix: "Tm";
1593
+ readonly NextLine: "T*";
1594
+ readonly ShowText: "Tj";
1595
+ readonly ShowTextArray: "TJ";
1596
+ readonly MoveAndShowText: "'";
1597
+ readonly MoveSetSpacingShowText: "\"";
1598
+ readonly SetStrokingColorSpace: "CS";
1599
+ readonly SetNonStrokingColorSpace: "cs";
1600
+ readonly SetStrokingColor: "SC";
1601
+ readonly SetStrokingColorN: "SCN";
1602
+ readonly SetNonStrokingColor: "sc";
1603
+ readonly SetNonStrokingColorN: "scn";
1604
+ readonly SetStrokingGray: "G";
1605
+ readonly SetNonStrokingGray: "g";
1606
+ readonly SetStrokingRGB: "RG";
1607
+ readonly SetNonStrokingRGB: "rg";
1608
+ readonly SetStrokingCMYK: "K";
1609
+ readonly SetNonStrokingCMYK: "k";
1610
+ readonly DrawXObject: "Do";
1611
+ readonly DesignateMarkedContentPoint: "MP";
1612
+ readonly DesignateMarkedContentPointProps: "DP";
1613
+ readonly BeginMarkedContent: "BMC";
1614
+ readonly BeginMarkedContentProps: "BDC";
1615
+ readonly EndMarkedContent: "EMC";
1616
+ readonly PaintShading: "sh";
1617
+ readonly BeginInlineImage: "BI";
1618
+ readonly BeginInlineImageData: "ID";
1619
+ readonly EndInlineImage: "EI";
1620
+ };
1621
+ type Op = (typeof Op)[keyof typeof Op];
1622
+ /**
1623
+ * A single content stream operator with its operands.
1624
+ * Immutable - create via factory functions or Operator.of().
1625
+ */
1626
+ declare class Operator {
1627
+ readonly op: Op;
1628
+ readonly operands: readonly Operand[];
1629
+ private constructor();
1630
+ /**
1631
+ * Create an operator with operands.
1632
+ */
1633
+ static of(op: Op, ...operands: Operand[]): Operator;
1634
+ /**
1635
+ * Serialize to bytes for content stream output.
1636
+ * Format: "operand1 operand2 ... operator"
1637
+ */
1638
+ toBytes(): Uint8Array;
1639
+ /**
1640
+ * Serialize to PDF content stream syntax string.
1641
+ * Format: "operand1 operand2 ... operator"
1642
+ */
1643
+ toString(): string;
1644
+ /**
1645
+ * Get byte length when serialized (for pre-allocation).
1646
+ */
1647
+ byteLength(): number;
1648
+ }
1649
+ //#endregion
1546
1650
  //#region src/io/binary-scanner.d.ts
1547
1651
  /**
1548
1652
  * Scanner extended with big-endian binary reading methods.
@@ -3575,213 +3679,625 @@ declare class TextField extends TerminalField {
3575
3679
  setValue(value: string): void;
3576
3680
  }
3577
3681
  //#endregion
3578
- //#region src/images/pdf-image.d.ts
3682
+ //#region src/svg/path-executor.d.ts
3579
3683
  /**
3580
- * PDFImage represents an embedded image XObject.
3581
- *
3582
- * @example
3583
- * ```typescript
3584
- * const image = await pdf.embedImage(jpegBytes);
3585
- * console.log(`Image size: ${image.width}x${image.height}`);
3586
- *
3587
- * page.drawImage(image, {
3588
- * x: 50,
3589
- * y: 500,
3590
- * width: 200,
3591
- * });
3592
- * ```
3684
+ * Options for SVG path execution.
3593
3685
  */
3594
- declare class PDFImage {
3595
- /** Image width in pixels */
3596
- readonly width: number;
3597
- /** Image height in pixels */
3598
- readonly height: number;
3599
- /** Reference to the image XObject in the document */
3600
- readonly ref: PdfRef;
3686
+ interface SvgPathExecutorOptions {
3601
3687
  /**
3602
- * Scale factor to convert pixels to points.
3603
- * Default is 1 (1 pixel = 1 point).
3604
- * For print-quality (300 DPI), use 72/300 = 0.24.
3688
+ * Flip Y coordinates (negate Y values).
3689
+ *
3690
+ * SVG uses a top-left origin with Y increasing downward.
3691
+ * PDF uses a bottom-left origin with Y increasing upward.
3692
+ *
3693
+ * When true (default), Y coordinates are negated to convert
3694
+ * SVG paths to PDF coordinate space.
3695
+ *
3696
+ * @default true
3605
3697
  */
3606
- readonly scale: number;
3607
- constructor(ref: PdfRef, width: number, height: number, scale?: number);
3698
+ flipY?: boolean;
3608
3699
  /**
3609
- * Width in points (pixels * scale).
3700
+ * Scale factor to apply to all coordinates.
3701
+ * @default 1
3610
3702
  */
3611
- get widthInPoints(): number;
3703
+ scale?: number;
3612
3704
  /**
3613
- * Height in points (pixels * scale).
3705
+ * X offset to add after scaling and flipping.
3706
+ * @default 0
3614
3707
  */
3615
- get heightInPoints(): number;
3708
+ translateX?: number;
3616
3709
  /**
3617
- * Aspect ratio (width / height).
3710
+ * Y offset to add after scaling and flipping.
3711
+ * @default 0
3618
3712
  */
3619
- get aspectRatio(): number;
3713
+ translateY?: number;
3620
3714
  }
3621
3715
  //#endregion
3622
- //#region src/text/types.d.ts
3716
+ //#region src/drawing/resources/types.d.ts
3623
3717
  /**
3624
- * Types for text extraction from PDF documents.
3625
- *
3626
- * These types represent text content extracted from PDF pages,
3627
- * including position information for searching and highlighting.
3718
+ * Common types for drawing resources.
3628
3719
  */
3629
3720
  /**
3630
- * Rectangle in PDF coordinates (origin at bottom-left).
3721
+ * Bounding box in PDF coordinate space.
3722
+ *
3723
+ * Defines a rectangle where (x, y) is the lower-left corner.
3724
+ * Used for patterns, Form XObjects, and clipping regions.
3631
3725
  */
3632
- interface BoundingBox {
3633
- /** Left edge (x coordinate) */
3726
+ interface BBox {
3634
3727
  x: number;
3635
- /** Bottom edge (y coordinate) */
3636
3728
  y: number;
3637
- /** Width of the box */
3638
3729
  width: number;
3639
- /** Height of the box */
3640
3730
  height: number;
3641
3731
  }
3642
3732
  /**
3643
- * A single extracted character with its position and style information.
3733
+ * Matrix for transforming a pattern.
3734
+ *
3735
+ * Standard PDF transformation matrix [a, b, c, d, e, f] where:
3736
+ * - a, d: Scale factors
3737
+ * - b, c: Rotation/skew factors
3738
+ * - e, f: Translation
3644
3739
  */
3645
- interface ExtractedChar {
3646
- /** The Unicode character(s) */
3647
- char: string;
3648
- /** Bounding box of the character */
3649
- bbox: BoundingBox;
3650
- /** Font size in points */
3651
- fontSize: number;
3652
- /** Font name (e.g., "Helvetica", "Arial-BoldMT") */
3653
- fontName: string;
3654
- /** Y coordinate of the text baseline */
3655
- baseline: number;
3656
- }
3740
+ type PatternMatrix = [a: number, b: number, c: number, d: number, e: number, f: number];
3657
3741
  /**
3658
- * A span of text with the same font and size on the same line.
3742
+ * PDF blend modes for compositing.
3743
+ *
3744
+ * These control how colors are combined when drawing over existing content.
3659
3745
  */
3660
- interface TextSpan {
3661
- /** The text content */
3662
- text: string;
3663
- /** Bounding box around the entire span */
3664
- bbox: BoundingBox;
3665
- /** Individual characters (for precise positioning) */
3666
- chars: ExtractedChar[];
3667
- /** Font size in points */
3668
- fontSize: number;
3669
- /** Font name */
3670
- fontName: string;
3671
- }
3746
+ type BlendMode = "Normal" | "Multiply" | "Screen" | "Overlay" | "Darken" | "Lighten" | "ColorDodge" | "ColorBurn" | "HardLight" | "SoftLight" | "Difference" | "Exclusion" | "Hue" | "Saturation" | "Color" | "Luminosity";
3747
+ //#endregion
3748
+ //#region src/drawing/resources/shading.d.ts
3672
3749
  /**
3673
- * A line of text (multiple spans on the same baseline).
3750
+ * Axial (linear) shading coordinates: start point (x0, y0) to end point (x1, y1).
3751
+ *
3752
+ * The gradient is drawn along the line from (x0, y0) to (x1, y1).
3674
3753
  */
3675
- interface TextLine$1 {
3676
- /** Combined text from all spans */
3677
- text: string;
3678
- /** Bounding box around the entire line */
3679
- bbox: BoundingBox;
3680
- /** Individual spans within the line */
3681
- spans: TextSpan[];
3682
- /** Y coordinate of the baseline */
3683
- baseline: number;
3684
- }
3754
+ type AxialCoords = [x0: number, y0: number, x1: number, y1: number];
3685
3755
  /**
3686
- * Full page text extraction result.
3756
+ * Radial shading coordinates: two circles defined by center and radius.
3757
+ *
3758
+ * - First circle: center (x0, y0), radius r0
3759
+ * - Second circle: center (x1, y1), radius r1
3760
+ *
3761
+ * The gradient blends between the two circles.
3687
3762
  */
3688
- interface PageText {
3689
- /** Page index (0-based) */
3690
- pageIndex: number;
3691
- /** Page width in points */
3692
- width: number;
3693
- /** Page height in points */
3694
- height: number;
3695
- /** All text lines on the page */
3696
- lines: TextLine$1[];
3697
- /** Plain text content (lines joined with newlines) */
3698
- text: string;
3699
- }
3763
+ type RadialCoords = [x0: number, y0: number, r0: number, x1: number, y1: number, r1: number];
3700
3764
  /**
3701
- * A search match result.
3765
+ * A color stop in a gradient.
3766
+ *
3767
+ * @example
3768
+ * ```typescript
3769
+ * const stops: ColorStop[] = [
3770
+ * { offset: 0, color: rgb(1, 0, 0) }, // Red at start
3771
+ * { offset: 0.5, color: rgb(1, 1, 0) }, // Yellow at midpoint
3772
+ * { offset: 1, color: rgb(0, 1, 0) }, // Green at end
3773
+ * ];
3774
+ * ```
3702
3775
  */
3703
- interface TextMatch {
3704
- /** The matched text */
3705
- text: string;
3706
- /** Bounding box around the entire match */
3707
- bbox: BoundingBox;
3708
- /** Page index where the match was found */
3709
- pageIndex: number;
3710
- /** Individual character bounding boxes (useful for multi-line matches or highlighting) */
3711
- charBoxes: BoundingBox[];
3776
+ interface ColorStop {
3777
+ /** Position along the gradient (0 = start, 1 = end) */
3778
+ offset: number;
3779
+ /** Color at this position */
3780
+ color: Color;
3712
3781
  }
3713
3782
  /**
3714
- * Options for text extraction.
3783
+ * Options for creating an axial (linear) shading.
3784
+ *
3785
+ * @example
3786
+ * ```typescript
3787
+ * const gradient = pdf.createAxialShading({
3788
+ * coords: [0, 0, 100, 0], // Horizontal gradient, 100pt wide
3789
+ * stops: [
3790
+ * { offset: 0, color: rgb(1, 0, 0) },
3791
+ * { offset: 1, color: rgb(0, 0, 1) },
3792
+ * ],
3793
+ * });
3794
+ * ```
3715
3795
  */
3716
- interface ExtractTextOptions {
3796
+ interface AxialShadingOptions {
3717
3797
  /**
3718
- * Include individual character positions.
3719
- * Default: true (needed for search support)
3798
+ * Line segment defining the gradient direction: [x0, y0, x1, y1].
3799
+ *
3800
+ * - (x0, y0): Start point where offset 0 colors appear
3801
+ * - (x1, y1): End point where offset 1 colors appear
3720
3802
  */
3721
- includeChars?: boolean;
3722
- }
3723
- /**
3724
- * Options for text search.
3725
- */
3726
- interface FindTextOptions {
3727
- /** Page indices to search (default: all pages) */
3728
- pages?: number[];
3729
- /** Case-sensitive matching (default: true) */
3730
- caseSensitive?: boolean;
3731
- /** Match whole words only (default: false) */
3732
- wholeWord?: boolean;
3803
+ coords: AxialCoords;
3804
+ /** Color stops defining the gradient colors and positions */
3805
+ stops: ColorStop[];
3806
+ /**
3807
+ * Whether to extend the gradient beyond its bounds.
3808
+ *
3809
+ * - [true, true] (default): Extend both ends with the endpoint colors
3810
+ * - [false, false]: No extension, transparent beyond bounds
3811
+ */
3812
+ extend?: [boolean, boolean];
3733
3813
  }
3734
- //#endregion
3735
- //#region src/svg/path-executor.d.ts
3736
3814
  /**
3737
- * Options for SVG path execution.
3815
+ * Options for creating a radial shading.
3816
+ *
3817
+ * @example
3818
+ * ```typescript
3819
+ * // Classic radial gradient: point to circle
3820
+ * const radial = pdf.createRadialShading({
3821
+ * coords: [50, 50, 0, 50, 50, 50], // From center point to 50pt radius
3822
+ * stops: [
3823
+ * { offset: 0, color: rgb(1, 1, 1) }, // White at center
3824
+ * { offset: 1, color: rgb(0, 0, 0) }, // Black at edge
3825
+ * ],
3826
+ * });
3827
+ * ```
3738
3828
  */
3739
- interface SvgPathExecutorOptions {
3829
+ interface RadialShadingOptions {
3740
3830
  /**
3741
- * Flip Y coordinates (negate Y values).
3831
+ * Two circles defining the gradient: [x0, y0, r0, x1, y1, r1].
3742
3832
  *
3743
- * SVG uses a top-left origin with Y increasing downward.
3744
- * PDF uses a bottom-left origin with Y increasing upward.
3833
+ * - First circle: center (x0, y0), radius r0
3834
+ * - Second circle: center (x1, y1), radius r1
3745
3835
  *
3746
- * When true (default), Y coordinates are negated to convert
3747
- * SVG paths to PDF coordinate space.
3836
+ * Common patterns:
3837
+ * - Point-to-circle: r0 = 0 for a classic radial gradient from center
3838
+ * - Circle-to-circle: Both radii > 0 for cone/spotlight effects
3839
+ */
3840
+ coords: RadialCoords;
3841
+ /** Color stops defining the gradient colors and positions */
3842
+ stops: ColorStop[];
3843
+ /**
3844
+ * Whether to extend the gradient beyond its bounds.
3748
3845
  *
3749
- * @default true
3846
+ * - [true, true] (default): Extend both ends
3847
+ * - [false, false]: No extension
3750
3848
  */
3751
- flipY?: boolean;
3849
+ extend?: [boolean, boolean];
3850
+ }
3851
+ /**
3852
+ * Options for creating a linear gradient using CSS-style angle and length.
3853
+ *
3854
+ * This is a convenience wrapper around axial shading that uses familiar
3855
+ * CSS gradient conventions.
3856
+ *
3857
+ * @example
3858
+ * ```typescript
3859
+ * // Horizontal gradient (left to right)
3860
+ * const gradient = pdf.createLinearGradient({
3861
+ * angle: 90, // CSS: 0 = up, 90 = right, 180 = down, 270 = left
3862
+ * length: 100, // Gradient spans 100pt
3863
+ * stops: [
3864
+ * { offset: 0, color: rgb(1, 0, 0) },
3865
+ * { offset: 1, color: rgb(0, 0, 1) },
3866
+ * ],
3867
+ * });
3868
+ * ```
3869
+ */
3870
+ interface LinearGradientOptions {
3752
3871
  /**
3753
- * Scale factor to apply to all coordinates.
3754
- * @default 1
3872
+ * Angle in degrees using CSS convention:
3873
+ * - 0: Bottom to top
3874
+ * - 90: Left to right
3875
+ * - 180: Top to bottom
3876
+ * - 270: Right to left
3755
3877
  */
3756
- scale?: number;
3878
+ angle: number;
3879
+ /** Length of the gradient in points */
3880
+ length: number;
3881
+ /** Color stops defining the gradient colors and positions */
3882
+ stops: ColorStop[];
3883
+ }
3884
+ /**
3885
+ * A shading (gradient) resource.
3886
+ *
3887
+ * Shadings define smooth color transitions (gradients) that can fill
3888
+ * arbitrary shapes. Two types are supported:
3889
+ * - **axial**: Linear gradient along a line segment
3890
+ * - **radial**: Circular gradient between two circles
3891
+ *
3892
+ * @example
3893
+ * ```typescript
3894
+ * const gradient = pdf.createAxialShading({
3895
+ * coords: [0, 0, 100, 0],
3896
+ * stops: [
3897
+ * { offset: 0, color: rgb(1, 0, 0) },
3898
+ * { offset: 1, color: rgb(0, 0, 1) },
3899
+ * ],
3900
+ * });
3901
+ *
3902
+ * const name = page.registerShading(gradient);
3903
+ * page.drawOperators([
3904
+ * ops.pushGraphicsState(),
3905
+ * ops.rectangle(50, 50, 100, 100),
3906
+ * ops.clip(),
3907
+ * ops.endPath(),
3908
+ * ops.paintShading(name),
3909
+ * ops.popGraphicsState(),
3910
+ * ]);
3911
+ * ```
3912
+ */
3913
+ declare class PDFShading {
3914
+ readonly type = "shading";
3915
+ readonly ref: PdfRef;
3916
+ readonly shadingType: "axial" | "radial";
3917
+ constructor(ref: PdfRef, shadingType: "axial" | "radial");
3757
3918
  /**
3758
- * X offset to add after scaling and flipping.
3759
- * @default 0
3919
+ * Create the PDF dictionary for an axial shading.
3760
3920
  */
3761
- translateX?: number;
3921
+ static createAxialDict(options: AxialShadingOptions): PdfDict;
3762
3922
  /**
3763
- * Y offset to add after scaling and flipping.
3764
- * @default 0
3923
+ * Create the PDF dictionary for a radial shading.
3765
3924
  */
3766
- translateY?: number;
3925
+ static createRadialDict(options: RadialShadingOptions): PdfDict;
3926
+ /**
3927
+ * Calculate axial gradient coordinates from angle and length.
3928
+ *
3929
+ * CSS angle convention: 0 = up, 90 = right, 180 = down, 270 = left
3930
+ */
3931
+ static calculateAxialCoords(angle: number, length: number): AxialCoords;
3767
3932
  }
3768
3933
  //#endregion
3769
- //#region src/fonts/standard-14.d.ts
3934
+ //#region src/drawing/resources/pattern.d.ts
3770
3935
  /**
3771
- * Standard 14 font names.
3936
+ * Options for creating a tiling pattern.
3937
+ *
3938
+ * Tiling patterns repeat a small graphic cell to fill an area. The cell is
3939
+ * defined by operators that draw into the bbox, and the pattern tiles with
3940
+ * the specified step sizes.
3941
+ *
3942
+ * @example
3943
+ * ```typescript
3944
+ * // Checkerboard pattern
3945
+ * const pattern = pdf.createTilingPattern({
3946
+ * bbox: { x: 0, y: 0, width: 10, height: 10 },
3947
+ * xStep: 10,
3948
+ * yStep: 10,
3949
+ * operators: [
3950
+ * ops.setNonStrokingGray(0.8),
3951
+ * ops.rectangle(0, 0, 5, 5),
3952
+ * ops.fill(),
3953
+ * ],
3954
+ * });
3955
+ * ```
3772
3956
  */
3773
- declare const STANDARD_14_FONTS: readonly ["Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique", "Helvetica", "Helvetica-Bold", "Helvetica-Oblique", "Helvetica-BoldOblique", "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic", "Symbol", "ZapfDingbats"];
3774
- type Standard14FontName = (typeof STANDARD_14_FONTS)[number];
3957
+ interface TilingPatternOptions {
3958
+ /**
3959
+ * Bounding box of the pattern cell.
3960
+ *
3961
+ * Defines the coordinate space for the pattern's operators.
3962
+ * Usually starts at { x: 0, y: 0, width, height }.
3963
+ */
3964
+ bbox: BBox;
3965
+ /**
3966
+ * Horizontal distance between pattern cell origins.
3967
+ *
3968
+ * Set equal to bbox width for seamless tiling, or larger for gaps.
3969
+ */
3970
+ xStep: number;
3971
+ /**
3972
+ * Vertical distance between pattern cell origins.
3973
+ *
3974
+ * Set equal to bbox height for seamless tiling, or larger for gaps.
3975
+ */
3976
+ yStep: number;
3977
+ /** Operators that draw the pattern cell content */
3978
+ operators: Operator[];
3979
+ }
3775
3980
  /**
3776
- * Standard 14 fonts enum for convenient access.
3981
+ * Options for creating an image pattern.
3982
+ *
3983
+ * Image patterns tile an embedded image to fill an area, similar to
3984
+ * CSS `background-image` with `background-repeat: repeat`.
3777
3985
  *
3778
3986
  * @example
3779
3987
  * ```typescript
3780
- * page.drawText("Hello", { font: StandardFonts.Helvetica });
3781
- * page.drawText("Bold", { font: StandardFonts.HelveticaBold });
3988
+ * const image = pdf.embedImage(textureBytes);
3989
+ * const pattern = pdf.createImagePattern({
3990
+ * image,
3991
+ * width: 50, // Tile size in points
3992
+ * height: 50,
3993
+ * });
3994
+ *
3995
+ * const patternName = page.registerPattern(pattern);
3996
+ * page.drawOperators([
3997
+ * ops.setNonStrokingColorSpace(ColorSpace.Pattern),
3998
+ * ops.setNonStrokingColorN(patternName),
3999
+ * ops.rectangle(100, 100, 300, 200),
4000
+ * ops.fill(),
4001
+ * ]);
3782
4002
  * ```
3783
4003
  */
3784
- declare const StandardFonts: {
4004
+ interface ImagePatternOptions {
4005
+ /**
4006
+ * The embedded image to use as the pattern tile.
4007
+ *
4008
+ * Created via `pdf.embedImage()`, `pdf.embedJpeg()`, or `pdf.embedPng()`.
4009
+ */
4010
+ image: {
4011
+ ref: PdfRef;
4012
+ width: number;
4013
+ height: number;
4014
+ };
4015
+ /**
4016
+ * Width of each tile in points.
4017
+ *
4018
+ * If not specified, uses the image's natural width in points.
4019
+ */
4020
+ width?: number;
4021
+ /**
4022
+ * Height of each tile in points.
4023
+ *
4024
+ * If not specified, uses the image's natural height in points.
4025
+ */
4026
+ height?: number;
4027
+ }
4028
+ /**
4029
+ * Options for creating a shading pattern.
4030
+ *
4031
+ * Shading patterns wrap a gradient (shading) so it can be used as a fill or
4032
+ * stroke color, just like tiling patterns.
4033
+ *
4034
+ * @example
4035
+ * ```typescript
4036
+ * // Create a gradient
4037
+ * const gradient = pdf.createAxialShading({
4038
+ * coords: [0, 0, 100, 0],
4039
+ * stops: [
4040
+ * { offset: 0, color: rgb(1, 0, 0) },
4041
+ * { offset: 1, color: rgb(0, 0, 1) },
4042
+ * ],
4043
+ * });
4044
+ *
4045
+ * // Wrap in a pattern (optionally with transform)
4046
+ * const pattern = pdf.createShadingPattern({
4047
+ * shading: gradient,
4048
+ * matrix: [1, 0, 0, 1, 50, 100], // Translate by (50, 100)
4049
+ * });
4050
+ * ```
4051
+ */
4052
+ interface ShadingPatternOptions {
4053
+ /**
4054
+ * The shading (gradient) to use.
4055
+ *
4056
+ * Created via pdf.createAxialShading() or pdf.createRadialShading().
4057
+ */
4058
+ shading: PDFShading;
4059
+ /**
4060
+ * Optional transformation matrix for the pattern.
4061
+ *
4062
+ * Transforms the shading's coordinate space. Useful for positioning
4063
+ * a gradient relative to shapes that will use it.
4064
+ *
4065
+ * Default: identity matrix (no transformation)
4066
+ */
4067
+ matrix?: PatternMatrix;
4068
+ }
4069
+ /**
4070
+ * A tiling pattern resource (PatternType 1).
4071
+ *
4072
+ * Tiling patterns repeat a small graphic cell to fill an area.
4073
+ * Useful for textures, backgrounds, and decorative fills.
4074
+ *
4075
+ * @example
4076
+ * ```typescript
4077
+ * const dots = pdf.createTilingPattern({
4078
+ * bbox: { x: 0, y: 0, width: 10, height: 10 },
4079
+ * xStep: 10,
4080
+ * yStep: 10,
4081
+ * operators: [
4082
+ * ops.setNonStrokingGray(0.5),
4083
+ * ops.moveTo(7, 5),
4084
+ * ops.curveTo(7, 6.1, 6.1, 7, 5, 7),
4085
+ * ops.curveTo(3.9, 7, 3, 6.1, 3, 5),
4086
+ * ops.curveTo(3, 3.9, 3.9, 3, 5, 3),
4087
+ * ops.curveTo(6.1, 3, 7, 3.9, 7, 5),
4088
+ * ops.fill(),
4089
+ * ],
4090
+ * });
4091
+ *
4092
+ * const name = page.registerPattern(dots);
4093
+ * ```
4094
+ */
4095
+ declare class PDFTilingPattern {
4096
+ readonly type = "pattern";
4097
+ readonly ref: PdfRef;
4098
+ readonly patternType = "tiling";
4099
+ constructor(ref: PdfRef);
4100
+ /**
4101
+ * Create the PDF stream for a tiling pattern.
4102
+ */
4103
+ static createStream(options: TilingPatternOptions, contentBytes: Uint8Array): PdfStream;
4104
+ /**
4105
+ * Create the PDF stream for an image pattern.
4106
+ */
4107
+ static createImageStream(options: ImagePatternOptions): PdfStream;
4108
+ }
4109
+ /**
4110
+ * A shading pattern resource (PatternType 2).
4111
+ *
4112
+ * Shading patterns wrap a gradient (shading) so it can be used as a fill or
4113
+ * stroke color. Unlike direct shading fills via `paintShading()`, shading
4114
+ * patterns work with any path shape without explicit clipping.
4115
+ *
4116
+ * @example
4117
+ * ```typescript
4118
+ * const gradient = pdf.createAxialShading({
4119
+ * coords: [0, 0, 100, 0],
4120
+ * stops: [
4121
+ * { offset: 0, color: rgb(1, 0, 0) },
4122
+ * { offset: 1, color: rgb(0, 0, 1) },
4123
+ * ],
4124
+ * });
4125
+ *
4126
+ * const gradientPattern = pdf.createShadingPattern({ shading: gradient });
4127
+ * const name = page.registerPattern(gradientPattern);
4128
+ * ```
4129
+ */
4130
+ declare class PDFShadingPattern {
4131
+ readonly type = "pattern";
4132
+ readonly ref: PdfRef;
4133
+ readonly patternType = "shading";
4134
+ readonly shading: PDFShading;
4135
+ constructor(ref: PdfRef, shading: PDFShading);
4136
+ /**
4137
+ * Create the PDF dictionary for a shading pattern.
4138
+ */
4139
+ static createDict(options: ShadingPatternOptions): PdfDict;
4140
+ }
4141
+ /**
4142
+ * Any pattern resource (tiling or shading).
4143
+ */
4144
+ type PDFPattern = PDFTilingPattern | PDFShadingPattern;
4145
+ //#endregion
4146
+ //#region src/drawing/resources/extgstate.d.ts
4147
+ /**
4148
+ * Options for creating extended graphics state.
4149
+ */
4150
+ interface ExtGStateOptions {
4151
+ /** Fill (non-stroking) opacity (0-1) */
4152
+ fillOpacity?: number;
4153
+ /** Stroke opacity (0-1) */
4154
+ strokeOpacity?: number;
4155
+ /** Blend mode for compositing */
4156
+ blendMode?: BlendMode;
4157
+ }
4158
+ /**
4159
+ * An extended graphics state resource.
4160
+ *
4161
+ * Extended graphics state (ExtGState) provides advanced rendering options
4162
+ * not available in the basic graphics state:
4163
+ * - **Opacity**: Separate fill and stroke transparency
4164
+ * - **Blend modes**: Photoshop-style compositing (Multiply, Screen, etc.)
4165
+ *
4166
+ * @example
4167
+ * ```typescript
4168
+ * const semiTransparent = pdf.createExtGState({
4169
+ * fillOpacity: 0.5,
4170
+ * blendMode: "Multiply",
4171
+ * });
4172
+ *
4173
+ * const name = page.registerExtGState(semiTransparent);
4174
+ * page.drawOperators([
4175
+ * ops.pushGraphicsState(),
4176
+ * ops.setGraphicsState(name),
4177
+ * ops.setNonStrokingRGB(1, 0, 0),
4178
+ * ops.rectangle(100, 100, 50, 50),
4179
+ * ops.fill(),
4180
+ * ops.popGraphicsState(),
4181
+ * ]);
4182
+ * ```
4183
+ */
4184
+ declare class PDFExtGState {
4185
+ readonly type = "extgstate";
4186
+ readonly ref: PdfRef;
4187
+ constructor(ref: PdfRef);
4188
+ /**
4189
+ * Create the PDF dictionary for an extended graphics state.
4190
+ *
4191
+ * Opacity values are clamped to the range [0, 1].
4192
+ */
4193
+ static createDict(options: ExtGStateOptions): PdfDict;
4194
+ }
4195
+ //#endregion
4196
+ //#region src/drawing/resources/form-xobject.d.ts
4197
+ /**
4198
+ * Options for creating a Form XObject (reusable content).
4199
+ *
4200
+ * Form XObjects are like "stamps" - define once, use many times.
4201
+ * They're perfect for watermarks, headers, footers, and repeated graphics.
4202
+ *
4203
+ * @example
4204
+ * ```typescript
4205
+ * // Create a "DRAFT" watermark stamp
4206
+ * const draftStamp = pdf.createFormXObject({
4207
+ * bbox: { x: 0, y: 0, width: 200, height: 50 },
4208
+ * operators: [
4209
+ * ops.setNonStrokingRGB(0.9, 0.1, 0.1),
4210
+ * ops.beginText(),
4211
+ * ops.setFont(fontName, 36),
4212
+ * ops.moveText(10, 10),
4213
+ * ops.showText("DRAFT"),
4214
+ * ops.endText(),
4215
+ * ],
4216
+ * });
4217
+ *
4218
+ * // Use on every page
4219
+ * for (const page of pdf.getPages()) {
4220
+ * const name = page.registerXObject(draftStamp);
4221
+ * page.drawOperators([
4222
+ * ops.pushGraphicsState(),
4223
+ * ops.concatMatrix(1, 0, 0, 1, 200, 700),
4224
+ * ops.paintXObject(name),
4225
+ * ops.popGraphicsState(),
4226
+ * ]);
4227
+ * }
4228
+ * ```
4229
+ */
4230
+ interface FormXObjectOptions {
4231
+ /**
4232
+ * Bounding box of the Form XObject.
4233
+ *
4234
+ * Defines the coordinate space for the form's operators.
4235
+ * Usually starts at { x: 0, y: 0, width, height }.
4236
+ */
4237
+ bbox: BBox;
4238
+ /** Operators that draw the form content */
4239
+ operators: Operator[];
4240
+ }
4241
+ /**
4242
+ * A Form XObject (reusable content) resource.
4243
+ *
4244
+ * Form XObjects are like "stamps" - define once, use many times.
4245
+ * They're ideal for:
4246
+ * - Watermarks applied to every page
4247
+ * - Headers and footers
4248
+ * - Logos and repeated graphics
4249
+ * - Any content that appears multiple times
4250
+ *
4251
+ * @example
4252
+ * ```typescript
4253
+ * const logo = pdf.createFormXObject({
4254
+ * bbox: { x: 0, y: 0, width: 100, height: 50 },
4255
+ * operators: [
4256
+ * ops.setNonStrokingRGB(0.2, 0.4, 0.8),
4257
+ * ops.rectangle(0, 0, 100, 50),
4258
+ * ops.fill(),
4259
+ * ],
4260
+ * });
4261
+ *
4262
+ * // Use on multiple pages
4263
+ * for (const page of pdf.getPages()) {
4264
+ * const name = page.registerXObject(logo);
4265
+ * page.drawOperators([
4266
+ * ops.pushGraphicsState(),
4267
+ * ops.concatMatrix(1, 0, 0, 1, 50, 700),
4268
+ * ops.paintXObject(name),
4269
+ * ops.popGraphicsState(),
4270
+ * ]);
4271
+ * }
4272
+ * ```
4273
+ */
4274
+ declare class PDFFormXObject {
4275
+ readonly type = "formxobject";
4276
+ readonly ref: PdfRef;
4277
+ readonly bbox: BBox;
4278
+ constructor(ref: PdfRef, bbox: BBox);
4279
+ /**
4280
+ * Create the PDF stream for a Form XObject.
4281
+ */
4282
+ static createStream(options: FormXObjectOptions, contentBytes: Uint8Array): PdfStream;
4283
+ }
4284
+ //#endregion
4285
+ //#region src/fonts/standard-14.d.ts
4286
+ /**
4287
+ * Standard 14 font names.
4288
+ */
4289
+ declare const STANDARD_14_FONTS: readonly ["Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique", "Helvetica", "Helvetica-Bold", "Helvetica-Oblique", "Helvetica-BoldOblique", "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic", "Symbol", "ZapfDingbats"];
4290
+ type Standard14FontName = (typeof STANDARD_14_FONTS)[number];
4291
+ /**
4292
+ * Standard 14 fonts enum for convenient access.
4293
+ *
4294
+ * @example
4295
+ * ```typescript
4296
+ * page.drawText("Hello", { font: StandardFonts.Helvetica });
4297
+ * page.drawText("Bold", { font: StandardFonts.HelveticaBold });
4298
+ * ```
4299
+ */
4300
+ declare const StandardFonts: {
3785
4301
  readonly Helvetica: "Helvetica";
3786
4302
  readonly HelveticaBold: "Helvetica-Bold";
3787
4303
  readonly HelveticaOblique: "Helvetica-Oblique";
@@ -3798,7 +4314,7 @@ declare const StandardFonts: {
3798
4314
  readonly ZapfDingbats: "ZapfDingbats";
3799
4315
  };
3800
4316
  //#endregion
3801
- //#region src/api/drawing/types.d.ts
4317
+ //#region src/drawing/types.d.ts
3802
4318
  /**
3803
4319
  * Text alignment for multiline text.
3804
4320
  */
@@ -3900,11 +4416,23 @@ interface DrawRectangleOptions {
3900
4416
  width: number;
3901
4417
  /** Height in points */
3902
4418
  height: number;
3903
- /** Fill color (omit for no fill) */
4419
+ /** Fill color (omit for no fill, mutually exclusive with pattern) */
3904
4420
  color?: Color;
3905
- /** Border/stroke color (omit for no stroke) */
4421
+ /**
4422
+ * Fill pattern (tiling or shading pattern).
4423
+ * Use instead of color to fill with a gradient or repeating pattern.
4424
+ * Mutually exclusive with color.
4425
+ */
4426
+ pattern?: PDFPattern;
4427
+ /** Border/stroke color (omit for no stroke, mutually exclusive with borderPattern) */
3906
4428
  borderColor?: Color;
3907
- /** Border width in points (default: 1 if borderColor set) */
4429
+ /**
4430
+ * Stroke pattern (tiling or shading pattern).
4431
+ * Use instead of borderColor to stroke with a gradient or repeating pattern.
4432
+ * Mutually exclusive with borderColor.
4433
+ */
4434
+ borderPattern?: PDFPattern;
4435
+ /** Border width in points (default: 1 if borderColor/borderPattern set) */
3908
4436
  borderWidth?: number;
3909
4437
  /** Dash pattern array (e.g., [5, 3] for 5pt dash, 3pt gap) */
3910
4438
  borderDashArray?: number[];
@@ -3956,11 +4484,23 @@ interface DrawCircleOptions {
3956
4484
  y: number;
3957
4485
  /** Circle radius in points */
3958
4486
  radius: number;
3959
- /** Fill color (omit for no fill) */
4487
+ /** Fill color (omit for no fill, mutually exclusive with pattern) */
3960
4488
  color?: Color;
3961
- /** Border/stroke color (omit for no stroke) */
4489
+ /**
4490
+ * Fill pattern (tiling or shading pattern).
4491
+ * Use instead of color to fill with a gradient or repeating pattern.
4492
+ * Mutually exclusive with color.
4493
+ */
4494
+ pattern?: PDFPattern;
4495
+ /** Border/stroke color (omit for no stroke, mutually exclusive with borderPattern) */
3962
4496
  borderColor?: Color;
3963
- /** Border width in points (default: 1 if borderColor set) */
4497
+ /**
4498
+ * Stroke pattern (tiling or shading pattern).
4499
+ * Use instead of borderColor to stroke with a gradient or repeating pattern.
4500
+ * Mutually exclusive with borderColor.
4501
+ */
4502
+ borderPattern?: PDFPattern;
4503
+ /** Border width in points (default: 1 if borderColor/borderPattern set) */
3964
4504
  borderWidth?: number;
3965
4505
  /** Fill opacity 0-1 (default: 1) */
3966
4506
  opacity?: number;
@@ -3979,11 +4519,23 @@ interface DrawEllipseOptions {
3979
4519
  xRadius: number;
3980
4520
  /** Vertical radius in points */
3981
4521
  yRadius: number;
3982
- /** Fill color (omit for no fill) */
4522
+ /** Fill color (omit for no fill, mutually exclusive with pattern) */
3983
4523
  color?: Color;
3984
- /** Border/stroke color (omit for no stroke) */
4524
+ /**
4525
+ * Fill pattern (tiling or shading pattern).
4526
+ * Use instead of color to fill with a gradient or repeating pattern.
4527
+ * Mutually exclusive with color.
4528
+ */
4529
+ pattern?: PDFPattern;
4530
+ /** Border/stroke color (omit for no stroke, mutually exclusive with borderPattern) */
3985
4531
  borderColor?: Color;
3986
- /** Border width in points (default: 1 if borderColor set) */
4532
+ /**
4533
+ * Stroke pattern (tiling or shading pattern).
4534
+ * Use instead of borderColor to stroke with a gradient or repeating pattern.
4535
+ * Mutually exclusive with borderColor.
4536
+ */
4537
+ borderPattern?: PDFPattern;
4538
+ /** Border width in points (default: 1 if borderColor/borderPattern set) */
3987
4539
  borderWidth?: number;
3988
4540
  /** Fill opacity 0-1 (default: 1) */
3989
4541
  opacity?: number;
@@ -4028,11 +4580,23 @@ interface DrawSvgPathOptions {
4028
4580
  * @default true
4029
4581
  */
4030
4582
  flipY?: boolean;
4031
- /** Fill color (default: black; omit to stroke only if borderColor set) */
4583
+ /** Fill color (default: black; omit to stroke only if borderColor set, mutually exclusive with pattern) */
4032
4584
  color?: Color;
4033
- /** Stroke color (omit for no stroke) */
4585
+ /**
4586
+ * Fill pattern (tiling or shading pattern).
4587
+ * Use instead of color to fill with a gradient or repeating pattern.
4588
+ * Mutually exclusive with color.
4589
+ */
4590
+ pattern?: PDFPattern;
4591
+ /** Stroke color (omit for no stroke, mutually exclusive with borderPattern) */
4034
4592
  borderColor?: Color;
4035
- /** Stroke width in points (default: 1 if borderColor set) */
4593
+ /**
4594
+ * Stroke pattern (tiling or shading pattern).
4595
+ * Use instead of borderColor to stroke with a gradient or repeating pattern.
4596
+ * Mutually exclusive with borderColor.
4597
+ */
4598
+ borderPattern?: PDFPattern;
4599
+ /** Stroke width in points (default: 1 if borderColor/borderPattern set) */
4036
4600
  borderWidth?: number;
4037
4601
  /** Line cap style */
4038
4602
  lineCap?: LineCap;
@@ -4053,13 +4617,44 @@ interface DrawSvgPathOptions {
4053
4617
  }
4054
4618
  /**
4055
4619
  * Options for path painting.
4620
+ *
4621
+ * @example
4622
+ * ```typescript
4623
+ * // Solid color fill
4624
+ * page.drawPath().rectangle(0, 0, 100, 100).fill({ color: rgb(1, 0, 0) });
4625
+ *
4626
+ * // Pattern fill (tiling or shading pattern)
4627
+ * const gradient = pdf.createAxialShading({...});
4628
+ * const pattern = pdf.createShadingPattern({ shading: gradient });
4629
+ * page.drawPath().circle(50, 50, 30).fill({ pattern });
4630
+ *
4631
+ * // Stroke with pattern
4632
+ * page.drawPath().rectangle(0, 0, 100, 100).stroke({
4633
+ * borderPattern: pattern,
4634
+ * borderWidth: 5,
4635
+ * });
4636
+ * ```
4056
4637
  */
4057
4638
  interface PathOptions {
4058
- /** Fill color (omit for no fill) */
4639
+ /** Fill color (omit for no fill, mutually exclusive with pattern) */
4059
4640
  color?: Color;
4060
- /** Stroke color (omit for no stroke) */
4641
+ /**
4642
+ * Fill pattern (tiling or shading pattern).
4643
+ *
4644
+ * Use instead of color to fill with a gradient or repeating pattern.
4645
+ * Mutually exclusive with color.
4646
+ */
4647
+ pattern?: PDFPattern;
4648
+ /** Stroke color (omit for no stroke, mutually exclusive with borderPattern) */
4061
4649
  borderColor?: Color;
4062
- /** Stroke width in points (default: 1 if borderColor set) */
4650
+ /**
4651
+ * Stroke pattern (tiling or shading pattern).
4652
+ *
4653
+ * Use instead of borderColor to stroke with a gradient or repeating pattern.
4654
+ * Mutually exclusive with borderColor.
4655
+ */
4656
+ borderPattern?: PDFPattern;
4657
+ /** Stroke width in points (default: 1 if borderColor/borderPattern set) */
4063
4658
  borderWidth?: number;
4064
4659
  /** Line cap style */
4065
4660
  lineCap?: LineCap;
@@ -4087,7 +4682,7 @@ declare function lineCapToNumber(cap: LineCap): 0 | 1 | 2;
4087
4682
  */
4088
4683
  declare function lineJoinToNumber(join: LineJoin): 0 | 1 | 2;
4089
4684
  //#endregion
4090
- //#region src/api/drawing/path-builder.d.ts
4685
+ //#region src/drawing/path-builder.d.ts
4091
4686
  /**
4092
4687
  * Callback type for appending content to a page.
4093
4688
  * Accepts a string (for ASCII-only content) or raw bytes.
@@ -4095,33 +4690,66 @@ declare function lineJoinToNumber(join: LineJoin): 0 | 1 | 2;
4095
4690
  type ContentAppender = (content: string | Uint8Array) => void;
4096
4691
  /**
4097
4692
  * Callback type for registering a graphics state and returning its name.
4693
+ * Returns null if no graphics state is needed (both opacities undefined).
4694
+ */
4695
+ type GraphicsStateRegistrar = (options: {
4696
+ fillOpacity?: number;
4697
+ strokeOpacity?: number;
4698
+ }) => string | null;
4699
+ /**
4700
+ * Callback type for registering a shading and returning its name.
4098
4701
  */
4099
- type GraphicsStateRegistrar = (fillOpacity?: number, strokeOpacity?: number) => string | null;
4702
+ type ShadingRegistrar = (shading: PDFShading) => string;
4703
+ /**
4704
+ * Callback type for registering a pattern and returning its name.
4705
+ */
4706
+ type PatternRegistrar = (pattern: PDFPattern) => string;
4100
4707
  /**
4101
4708
  * PathBuilder provides a fluent interface for constructing PDF paths.
4102
4709
  *
4103
4710
  * @example
4104
4711
  * ```typescript
4105
- * // Triangle
4712
+ * // Triangle with solid color
4106
4713
  * page.drawPath()
4107
4714
  * .moveTo(300, 200)
4108
4715
  * .lineTo(350, 300)
4109
4716
  * .lineTo(250, 300)
4110
4717
  * .close()
4111
4718
  * .fill({ color: rgb(0, 0, 1) });
4719
+ *
4720
+ * // Rectangle with gradient fill
4721
+ * const gradient = pdf.createAxialShading({
4722
+ * coords: [0, 0, 100, 0],
4723
+ * stops: [
4724
+ * { offset: 0, color: rgb(1, 0, 0) },
4725
+ * { offset: 1, color: rgb(0, 0, 1) },
4726
+ * ],
4727
+ * });
4728
+ * const gradientPattern = pdf.createShadingPattern({ shading: gradient });
4729
+ * page.drawPath()
4730
+ * .rectangle(50, 50, 100, 100)
4731
+ * .fill({ pattern: gradientPattern });
4732
+ *
4733
+ * // Circle with tiling pattern fill
4734
+ * const pattern = pdf.createTilingPattern({...});
4735
+ * page.drawPath()
4736
+ * .circle(200, 200, 50)
4737
+ * .fill({ pattern });
4112
4738
  * ```
4113
4739
  */
4114
4740
  declare class PathBuilder {
4115
4741
  private readonly pathOps;
4116
4742
  private readonly appendContent;
4117
4743
  private readonly registerGraphicsState;
4744
+ private readonly registerShading?;
4745
+ private readonly registerPattern?;
4118
4746
  /** Current point for quadratic-to-cubic conversion */
4119
4747
  private currentX;
4120
4748
  private currentY;
4121
4749
  /** Start point of current subpath (for close operations) */
4122
4750
  private subpathStartX;
4123
4751
  private subpathStartY;
4124
- constructor(appendContent: ContentAppender, registerGraphicsState: GraphicsStateRegistrar);
4752
+ constructor(appendContent: ContentAppender, registerGraphicsState: GraphicsStateRegistrar, registerShading?: ShadingRegistrar, registerPattern?: PatternRegistrar);
4125
4753
  /**
4126
4754
  * Move to a point (start a new subpath).
4127
4755
  */
@@ -4232,58 +4860,219 @@ declare class PathBuilder {
4232
4860
  * Paint the path with the given options.
4233
4861
  */
4234
4862
  private paint;
4863
+ /**
4864
+ * Register a pattern and return its name, or undefined if no pattern.
4865
+ */
4866
+ private ensurePatternRegistered;
4235
4867
  /**
4236
4868
  * Emit operators to the page content.
4237
4869
  */
4238
4870
  private emitOps;
4239
4871
  }
4240
4872
  //#endregion
4241
- //#region src/security/credentials.d.ts
4873
+ //#region src/images/pdf-image.d.ts
4242
4874
  /**
4243
- * Credentials for decrypting PDF documents.
4875
+ * PDFImage represents an embedded image XObject.
4244
4876
  *
4245
- * Currently supports password-based authentication (Standard security handler).
4246
- * Certificate-based authentication (Public Key handler) is planned for the future.
4247
- */
4248
- /**
4249
- * Password credential for Standard security handler.
4250
- */
4251
- interface PasswordCredential {
4252
- type: "password";
4253
- password: string;
4254
- }
4255
- /**
4256
- * Certificate credential for Public Key security handler (future).
4877
+ * @example
4878
+ * ```typescript
4879
+ * const image = await pdf.embedImage(jpegBytes);
4880
+ * console.log(`Image size: ${image.width}x${image.height}`);
4881
+ *
4882
+ * page.drawImage(image, {
4883
+ * x: 50,
4884
+ * y: 500,
4885
+ * width: 200,
4886
+ * });
4887
+ * ```
4257
4888
  */
4258
- interface CertificateCredential {
4259
- type: "certificate";
4260
- certificate: Uint8Array;
4261
- privateKey: Uint8Array;
4889
+ declare class PDFImage {
4890
+ /** Image width in pixels */
4891
+ readonly width: number;
4892
+ /** Image height in pixels */
4893
+ readonly height: number;
4894
+ /** Reference to the image XObject in the document */
4895
+ readonly ref: PdfRef;
4896
+ /**
4897
+ * Scale factor to convert pixels to points.
4898
+ * Default is 1 (1 pixel = 1 point).
4899
+ * For print-quality (300 DPI), use 72/300 = 0.24.
4900
+ */
4901
+ readonly scale: number;
4902
+ constructor(ref: PdfRef, width: number, height: number, scale?: number);
4903
+ /**
4904
+ * Width in points (pixels * scale).
4905
+ */
4906
+ get widthInPoints(): number;
4907
+ /**
4908
+ * Height in points (pixels * scale).
4909
+ */
4910
+ get heightInPoints(): number;
4911
+ /**
4912
+ * Aspect ratio (width / height).
4913
+ */
4914
+ get aspectRatio(): number;
4262
4915
  }
4916
+ //#endregion
4917
+ //#region src/text/types.d.ts
4263
4918
  /**
4264
- * Credentials for decrypting a document.
4919
+ * Types for text extraction from PDF documents.
4265
4920
  *
4266
- * Can be provided as:
4267
- * - A plain string (shorthand for password credential)
4268
- * - A PasswordCredential object
4269
- * - A CertificateCredential object (future support)
4921
+ * These types represent text content extracted from PDF pages,
4922
+ * including position information for searching and highlighting.
4270
4923
  */
4271
- type DecryptionCredential = PasswordCredential | CertificateCredential;
4272
4924
  /**
4273
- * Input type that accepts either explicit credentials or string shorthand.
4925
+ * Rectangle in PDF coordinates (origin at bottom-left).
4274
4926
  */
4275
- type CredentialInput = DecryptionCredential | string;
4276
- //#endregion
4277
- //#region src/security/permissions.d.ts
4927
+ interface BoundingBox {
4928
+ /** Left edge (x coordinate) */
4929
+ x: number;
4930
+ /** Bottom edge (y coordinate) */
4931
+ y: number;
4932
+ /** Width of the box */
4933
+ width: number;
4934
+ /** Height of the box */
4935
+ height: number;
4936
+ }
4278
4937
  /**
4279
- * Parsed permission flags.
4280
- *
4281
- * All permissions default to true for unencrypted documents.
4938
+ * A single extracted character with its position and style information.
4282
4939
  */
4283
- interface Permissions {
4284
- /** Print the document (bit 3) */
4285
- print: boolean;
4286
- /** Print at full resolution (bit 12) - if false, only low-res printing */
4940
+ interface ExtractedChar {
4941
+ /** The Unicode character(s) */
4942
+ char: string;
4943
+ /** Bounding box of the character */
4944
+ bbox: BoundingBox;
4945
+ /** Font size in points */
4946
+ fontSize: number;
4947
+ /** Font name (e.g., "Helvetica", "Arial-BoldMT") */
4948
+ fontName: string;
4949
+ /** Y coordinate of the text baseline */
4950
+ baseline: number;
4951
+ }
4952
+ /**
4953
+ * A span of text with the same font and size on the same line.
4954
+ */
4955
+ interface TextSpan {
4956
+ /** The text content */
4957
+ text: string;
4958
+ /** Bounding box around the entire span */
4959
+ bbox: BoundingBox;
4960
+ /** Individual characters (for precise positioning) */
4961
+ chars: ExtractedChar[];
4962
+ /** Font size in points */
4963
+ fontSize: number;
4964
+ /** Font name */
4965
+ fontName: string;
4966
+ }
4967
+ /**
4968
+ * A line of text (multiple spans on the same baseline).
4969
+ */
4970
+ interface TextLine$1 {
4971
+ /** Combined text from all spans */
4972
+ text: string;
4973
+ /** Bounding box around the entire line */
4974
+ bbox: BoundingBox;
4975
+ /** Individual spans within the line */
4976
+ spans: TextSpan[];
4977
+ /** Y coordinate of the baseline */
4978
+ baseline: number;
4979
+ }
4980
+ /**
4981
+ * Full page text extraction result.
4982
+ */
4983
+ interface PageText {
4984
+ /** Page index (0-based) */
4985
+ pageIndex: number;
4986
+ /** Page width in points */
4987
+ width: number;
4988
+ /** Page height in points */
4989
+ height: number;
4990
+ /** All text lines on the page */
4991
+ lines: TextLine$1[];
4992
+ /** Plain text content (lines joined with newlines) */
4993
+ text: string;
4994
+ }
4995
+ /**
4996
+ * A search match result.
4997
+ */
4998
+ interface TextMatch {
4999
+ /** The matched text */
5000
+ text: string;
5001
+ /** Bounding box around the entire match */
5002
+ bbox: BoundingBox;
5003
+ /** Page index where the match was found */
5004
+ pageIndex: number;
5005
+ /** Individual character bounding boxes (useful for multi-line matches or highlighting) */
5006
+ charBoxes: BoundingBox[];
5007
+ }
5008
+ /**
5009
+ * Options for text extraction.
5010
+ */
5011
+ interface ExtractTextOptions {
5012
+ /**
5013
+ * Include individual character positions.
5014
+ * Default: true (needed for search support)
5015
+ */
5016
+ includeChars?: boolean;
5017
+ }
5018
+ /**
5019
+ * Options for text search.
5020
+ */
5021
+ interface FindTextOptions {
5022
+ /** Page indices to search (default: all pages) */
5023
+ pages?: number[];
5024
+ /** Case-sensitive matching (default: true) */
5025
+ caseSensitive?: boolean;
5026
+ /** Match whole words only (default: false) */
5027
+ wholeWord?: boolean;
5028
+ }
5029
+ //#endregion
5030
+ //#region src/security/credentials.d.ts
5031
+ /**
5032
+ * Credentials for decrypting PDF documents.
5033
+ *
5034
+ * Currently supports password-based authentication (Standard security handler).
5035
+ * Certificate-based authentication (Public Key handler) is planned for the future.
5036
+ */
5037
+ /**
5038
+ * Password credential for Standard security handler.
5039
+ */
5040
+ interface PasswordCredential {
5041
+ type: "password";
5042
+ password: string;
5043
+ }
5044
+ /**
5045
+ * Certificate credential for Public Key security handler (future).
5046
+ */
5047
+ interface CertificateCredential {
5048
+ type: "certificate";
5049
+ certificate: Uint8Array;
5050
+ privateKey: Uint8Array;
5051
+ }
5052
+ /**
5053
+ * Credentials for decrypting a document.
5054
+ *
5055
+ * Can be provided as:
5056
+ * - A plain string (shorthand for password credential)
5057
+ * - A PasswordCredential object
5058
+ * - A CertificateCredential object (future support)
5059
+ */
5060
+ type DecryptionCredential = PasswordCredential | CertificateCredential;
5061
+ /**
5062
+ * Input type that accepts either explicit credentials or string shorthand.
5063
+ */
5064
+ type CredentialInput = DecryptionCredential | string;
5065
+ //#endregion
5066
+ //#region src/security/permissions.d.ts
5067
+ /**
5068
+ * Parsed permission flags.
5069
+ *
5070
+ * All permissions default to true for unencrypted documents.
5071
+ */
5072
+ interface Permissions {
5073
+ /** Print the document (bit 3) */
5074
+ print: boolean;
5075
+ /** Print at full resolution (bit 12) - if false, only low-res printing */
4287
5076
  printHighQuality: boolean;
4288
5077
  /** Modify document contents (bit 4) */
4289
5078
  modify: boolean;
@@ -5003,6 +5792,8 @@ declare class PDFPage {
5003
5792
  readonly index: number;
5004
5793
  /** Document context for registering objects */
5005
5794
  private readonly ctx;
5795
+ /** Resource cache for deduplication - maps object refs to resource names */
5796
+ private _resourceCache;
5006
5797
  constructor(ref: PdfRef, dict: PdfDict, index: number, ctx: PDFContext);
5007
5798
  /**
5008
5799
  * Get the MediaBox (page boundary).
@@ -5049,6 +5840,12 @@ declare class PDFPage {
5049
5840
  * returns the width of the MediaBox instead.
5050
5841
  */
5051
5842
  get height(): number;
5843
+ /**
5844
+ * Get the effective box for dimension calculations.
5845
+ *
5846
+ * Returns CropBox if it's smaller than MediaBox, otherwise MediaBox.
5847
+ */
5848
+ private getEffectiveBox;
5052
5849
  /**
5053
5850
  * Whether the page is in landscape orientation.
5054
5851
  *
@@ -5290,6 +6087,10 @@ declare class PDFPage {
5290
6087
  * ```
5291
6088
  */
5292
6089
  drawImage(image: PDFImage, options?: DrawImageOptions): void;
6090
+ /**
6091
+ * Compute image dimensions based on options, preserving aspect ratio when appropriate.
6092
+ */
6093
+ private computeImageDimensions;
5293
6094
  /**
5294
6095
  * Start building a custom path.
5295
6096
  *
@@ -5298,7 +6099,7 @@ declare class PDFPage {
5298
6099
  *
5299
6100
  * @example
5300
6101
  * ```typescript
5301
- * // Triangle
6102
+ * // Triangle with solid color
5302
6103
  * page.drawPath()
5303
6104
  * .moveTo(100, 100)
5304
6105
  * .lineTo(200, 100)
@@ -5306,7 +6107,7 @@ declare class PDFPage {
5306
6107
  * .close()
5307
6108
  * .fill({ color: rgb(1, 0, 0) });
5308
6109
  *
5309
- * // Complex shape
6110
+ * // Complex shape with fill and stroke
5310
6111
  * page.drawPath()
5311
6112
  * .moveTo(50, 50)
5312
6113
  * .curveTo(100, 100, 150, 100, 200, 50)
@@ -5316,6 +6117,22 @@ declare class PDFPage {
5316
6117
  * color: rgb(0.9, 0.9, 1),
5317
6118
  * borderColor: rgb(0, 0, 1),
5318
6119
  * });
6120
+ *
6121
+ * // Circle with gradient fill (using shading pattern)
6122
+ * const gradient = pdf.createAxialShading({
6123
+ * coords: [0, 0, 100, 0],
6124
+ * stops: [{ offset: 0, color: rgb(1, 0, 0) }, { offset: 1, color: rgb(0, 0, 1) }],
6125
+ * });
6126
+ * const gradientPattern = pdf.createShadingPattern({ shading: gradient });
6127
+ * page.drawPath()
6128
+ * .circle(200, 200, 50)
6129
+ * .fill({ pattern: gradientPattern });
6130
+ *
6131
+ * // Rectangle with tiling pattern fill
6132
+ * const pattern = pdf.createTilingPattern({...});
6133
+ * page.drawPath()
6134
+ * .rectangle(50, 300, 100, 100)
6135
+ * .fill({ pattern });
5319
6136
  * ```
5320
6137
  */
5321
6138
  drawPath(): PathBuilder;
@@ -5362,6 +6179,206 @@ declare class PDFPage {
5362
6179
  * ```
5363
6180
  */
5364
6181
  drawSvgPath(pathData: string, options?: DrawSvgPathOptions): void;
6182
+ /**
6183
+ * Emit raw PDF operators to the page content stream.
6184
+ *
6185
+ * This is the low-level drawing API that gives you direct control over
6186
+ * PDF content stream operators. Use this when you need advanced features
6187
+ * like matrix transforms, graphics state stack, gradients, or patterns
6188
+ * that aren't available through the high-level drawing methods.
6189
+ *
6190
+ * **Important**: The caller is responsible for valid operator sequences.
6191
+ * Invalid sequences may produce corrupted PDFs that won't render correctly.
6192
+ *
6193
+ * @param operators - Array of operators to emit
6194
+ *
6195
+ * @example
6196
+ * ```typescript
6197
+ * import { PDF, ops } from "@libpdf/core";
6198
+ *
6199
+ * const pdf = await PDF.create();
6200
+ * const page = pdf.addPage();
6201
+ *
6202
+ * page.drawOperators([
6203
+ * ops.pushGraphicsState(),
6204
+ * ops.concatMatrix(1, 0, 0, 1, 100, 200), // translate
6205
+ * ops.setNonStrokingRGB(1, 0, 0),
6206
+ * ops.rectangle(0, 0, 50, 50),
6207
+ * ops.fill(),
6208
+ * ops.popGraphicsState(),
6209
+ * ]);
6210
+ * ```
6211
+ */
6212
+ drawOperators(operators: Operator[]): void;
6213
+ /**
6214
+ * Register a font resource and return its operator name.
6215
+ *
6216
+ * The same font registered multiple times returns the same name (deduplication).
6217
+ *
6218
+ * @param font - Font to register (EmbeddedFont or Standard 14 font name)
6219
+ * @returns The resource name for use with operators (e.g., "F0")
6220
+ *
6221
+ * @example
6222
+ * ```typescript
6223
+ * const font = await pdf.embedFont(fontBytes);
6224
+ * const fontName = page.registerFont(font);
6225
+ *
6226
+ * page.drawOperators([
6227
+ * ops.beginText(),
6228
+ * ops.setFont(fontName, 12),
6229
+ * ops.showText("Hello"),
6230
+ * ops.endText(),
6231
+ * ]);
6232
+ * ```
6233
+ */
6234
+ registerFont(font: FontInput): string;
6235
+ /**
6236
+ * Register an image resource and return its operator name.
6237
+ *
6238
+ * The same image registered multiple times returns the same name (deduplication).
6239
+ *
6240
+ * @param image - The PDFImage to register
6241
+ * @returns The resource name for use with paintXObject operator (e.g., "Im0")
6242
+ *
6243
+ * @example
6244
+ * ```typescript
6245
+ * const image = await pdf.embedImage(imageBytes);
6246
+ * const imageName = page.registerImage(image);
6247
+ *
6248
+ * page.drawOperators([
6249
+ * ops.pushGraphicsState(),
6250
+ * ops.concatMatrix(100, 0, 0, 100, 200, 500),
6251
+ * ops.paintXObject(imageName),
6252
+ * ops.popGraphicsState(),
6253
+ * ]);
6254
+ * ```
6255
+ */
6256
+ registerImage(image: PDFImage): string;
6257
+ /**
6258
+ * Register a shading (gradient) resource and return its operator name.
6259
+ *
6260
+ * The same shading registered multiple times returns the same name (deduplication).
6261
+ *
6262
+ * @param shading - The PDFShading to register
6263
+ * @returns The resource name for use with paintShading operator (e.g., "Sh0")
6264
+ *
6265
+ * @example
6266
+ * ```typescript
6267
+ * const gradient = pdf.createAxialShading({
6268
+ * coords: [0, 0, 100, 0],
6269
+ * stops: [{ offset: 0, color: rgb(1, 0, 0) }, { offset: 1, color: rgb(0, 0, 1) }],
6270
+ * });
6271
+ * const shadingName = page.registerShading(gradient);
6272
+ *
6273
+ * page.drawOperators([
6274
+ * ops.pushGraphicsState(),
6275
+ * ops.rectangle(50, 50, 100, 100),
6276
+ * ops.clip(),
6277
+ * ops.endPath(),
6278
+ * ops.paintShading(shadingName),
6279
+ * ops.popGraphicsState(),
6280
+ * ]);
6281
+ * ```
6282
+ */
6283
+ registerShading(shading: PDFShading): string;
6284
+ /**
6285
+ * Register a pattern resource and return its operator name.
6286
+ *
6287
+ * The same pattern registered multiple times returns the same name (deduplication).
6288
+ *
6289
+ * @param pattern - The PDFPattern to register
6290
+ * @returns The resource name for use with setNonStrokingColorN operator (e.g., "P0")
6291
+ *
6292
+ * @example
6293
+ * ```typescript
6294
+ * // Create a checkerboard pattern
6295
+ * const pattern = pdf.createTilingPattern({
6296
+ * bbox: { x: 0, y: 0, width: 10, height: 10 },
6297
+ * xStep: 10,
6298
+ * yStep: 10,
6299
+ * operators: [
6300
+ * ops.setNonStrokingGray(0.8),
6301
+ * ops.rectangle(0, 0, 5, 5),
6302
+ * ops.fill(),
6303
+ * ],
6304
+ * });
6305
+ * const patternName = page.registerPattern(pattern);
6306
+ *
6307
+ * // Fill a rectangle with the pattern
6308
+ * page.drawOperators([
6309
+ * ops.setNonStrokingColorSpace(ColorSpace.Pattern),
6310
+ * ops.setNonStrokingColorN(patternName),
6311
+ * ops.rectangle(100, 100, 200, 200),
6312
+ * ops.fill(),
6313
+ * ]);
6314
+ * ```
6315
+ */
6316
+ registerPattern(pattern: PDFPattern): string;
6317
+ /**
6318
+ * Register an extended graphics state resource and return its operator name.
6319
+ *
6320
+ * The same ExtGState registered multiple times returns the same name (deduplication).
6321
+ *
6322
+ * @param state - The PDFExtGState to register
6323
+ * @returns The resource name for use with setGraphicsState operator (e.g., "GS0")
6324
+ *
6325
+ * @example
6326
+ * ```typescript
6327
+ * const gs = pdf.createExtGState({
6328
+ * fillOpacity: 0.5,
6329
+ * strokeOpacity: 0.8,
6330
+ * blendMode: "Multiply",
6331
+ * });
6332
+ * const gsName = page.registerExtGState(gs);
6333
+ *
6334
+ * page.drawOperators([
6335
+ * ops.pushGraphicsState(),
6336
+ * ops.setGraphicsState(gsName),
6337
+ * ops.setNonStrokingRGB(1, 0, 0),
6338
+ * ops.rectangle(100, 100, 50, 50),
6339
+ * ops.fill(),
6340
+ * ops.popGraphicsState(),
6341
+ * ]);
6342
+ * ```
6343
+ */
6344
+ registerExtGState(state: PDFExtGState): string;
6345
+ /**
6346
+ * Register a Form XObject resource and return its operator name.
6347
+ *
6348
+ * The same XObject registered multiple times returns the same name (deduplication).
6349
+ *
6350
+ * @param xobject - The PDFFormXObject or PDFEmbeddedPage to register
6351
+ * @returns The resource name for use with paintXObject operator (e.g., "Fm0")
6352
+ *
6353
+ * @example
6354
+ * ```typescript
6355
+ * // Create a reusable stamp
6356
+ * const stamp = pdf.createFormXObject({
6357
+ * bbox: { x: 0, y: 0, width: 100, height: 50 },
6358
+ * operators: [
6359
+ * ops.setNonStrokingRGB(1, 0, 0),
6360
+ * ops.rectangle(0, 0, 100, 50),
6361
+ * ops.fill(),
6362
+ * ops.beginText(),
6363
+ * ops.setFont(fontName, 12),
6364
+ * ops.setNonStrokingGray(1),
6365
+ * ops.moveText(10, 18),
6366
+ * ops.showText("STAMP"),
6367
+ * ops.endText(),
6368
+ * ],
6369
+ * });
6370
+ * const xobjectName = page.registerXObject(stamp);
6371
+ *
6372
+ * // Use the stamp at different positions
6373
+ * page.drawOperators([
6374
+ * ops.pushGraphicsState(),
6375
+ * ops.concatMatrix(1, 0, 0, 1, 200, 700),
6376
+ * ops.paintXObject(xobjectName),
6377
+ * ops.popGraphicsState(),
6378
+ * ]);
6379
+ * ```
6380
+ */
6381
+ registerXObject(xobject: PDFFormXObject | PDFEmbeddedPage): string;
5365
6382
  /** Cached annotations for this page */
5366
6383
  private _annotationCache;
5367
6384
  /**
@@ -5635,19 +6652,21 @@ declare class PDFPage {
5635
6652
  * Returns the name assigned to the XObject.
5636
6653
  */
5637
6654
  private addXObjectResource;
5638
- /**
5639
- * Add a graphics state to the page's resources.
5640
- * Returns the name assigned to the ExtGState.
5641
- */
5642
- private addGraphicsState;
5643
6655
  /**
5644
6656
  * Generate a unique name not already in the dictionary.
5645
6657
  */
5646
6658
  private generateUniqueName;
5647
6659
  /**
5648
- * Format a number for PDF content stream (avoid unnecessary decimals).
6660
+ * Register a resource reference in a resource subdictionary.
6661
+ *
6662
+ * Handles deduplication via cache and existing entry scanning.
6663
+ *
6664
+ * @param ref - The object reference to register
6665
+ * @param resourceType - The resource subdictionary key (e.g., "Font", "XObject")
6666
+ * @param prefix - The name prefix (e.g., "F", "Im", "Sh")
6667
+ * @returns The resource name for use in operators
5649
6668
  */
5650
- private formatNumber;
6669
+ private registerResource;
5651
6670
  /**
5652
6671
  * Create and register a content stream.
5653
6672
  *
@@ -5674,17 +6693,20 @@ declare class PDFPage {
5674
6693
  */
5675
6694
  private getBox;
5676
6695
  /**
5677
- * Register a graphics state for opacity and return its name.
5678
- * Returns null if no opacity is needed.
6696
+ * Create and register a graphics state, returning its resource name.
6697
+ *
6698
+ * This is an internal helper for high-level drawing methods.
6699
+ * For the public low-level API, use `pdf.createExtGState()` + `page.registerExtGState()`.
5679
6700
  */
5680
- private registerGraphicsStateForOpacity;
6701
+ private registerGraphicsState;
5681
6702
  /**
5682
- * Append operators to the page content stream.
5683
- *
5684
- * Uses Operator.toBytes() directly to avoid UTF-8 round-trip corruption
5685
- * of non-ASCII bytes in PdfString operands (e.g., WinAnsi-encoded text).
6703
+ * Append operators to the page content stream (foreground).
5686
6704
  */
5687
6705
  private appendOperators;
6706
+ /**
6707
+ * Prepend operators to the page content stream (background).
6708
+ */
6709
+ private prependOperators;
5688
6710
  /**
5689
6711
  * Add a font resource to the page and return its name.
5690
6712
  */
@@ -8499,43 +9521,257 @@ declare class PDF {
8499
9521
  */
8500
9522
  embedPng(bytes: Uint8Array): PDFImage;
8501
9523
  /**
8502
- * Access the attachments API for managing file attachments.
9524
+ * Create an axial (linear) shading with explicit coordinates.
9525
+ *
9526
+ * @param options - Shading options including coords and color stops
9527
+ * @returns PDFShading resource for use with page.registerShading()
8503
9528
  *
8504
9529
  * @example
8505
9530
  * ```typescript
8506
- * // List attachments
8507
- * const attachments = await pdf.attachments.list();
8508
- *
8509
- * // Add an attachment
8510
- * await pdf.attachments.add("report.pdf", pdfBytes, {
8511
- * description: "Annual report",
9531
+ * const gradient = pdf.createAxialShading({
9532
+ * coords: [0, 0, 100, 0], // x0, y0, x1, y1
9533
+ * stops: [
9534
+ * { offset: 0, color: rgb(1, 0, 0) },
9535
+ * { offset: 0.5, color: rgb(0, 1, 0) },
9536
+ * { offset: 1, color: rgb(0, 0, 1) },
9537
+ * ],
8512
9538
  * });
8513
- *
8514
- * // Get attachment data
8515
- * const data = await pdf.attachments.get("report.pdf");
8516
- *
8517
- * // Remove an attachment
8518
- * await pdf.attachments.remove("old-file.txt");
9539
+ * const shadingName = page.registerShading(gradient);
8519
9540
  * ```
8520
9541
  */
8521
- get attachments(): PDFAttachments;
9542
+ createAxialShading(options: AxialShadingOptions): PDFShading;
8522
9543
  /**
8523
- * List all attachments in the document.
9544
+ * Create a radial shading with explicit coordinates.
8524
9545
  *
8525
- * Convenience method that delegates to `pdf.attachments.list()`.
9546
+ * @param options - Shading options including coords and color stops
9547
+ * @returns PDFShading resource for use with page.registerShading()
8526
9548
  *
8527
- * @returns Map of attachment name to attachment info
9549
+ * @example
9550
+ * ```typescript
9551
+ * const radial = pdf.createRadialShading({
9552
+ * coords: [50, 50, 0, 50, 50, 50], // x0, y0, r0, x1, y1, r1
9553
+ * stops: [
9554
+ * { offset: 0, color: rgb(1, 1, 1) },
9555
+ * { offset: 1, color: rgb(0, 0, 0) },
9556
+ * ],
9557
+ * });
9558
+ * const shadingName = page.registerShading(radial);
9559
+ * ```
8528
9560
  */
8529
- getAttachments(): Map<string, AttachmentInfo>;
9561
+ createRadialShading(options: RadialShadingOptions): PDFShading;
8530
9562
  /**
8531
- * Get the raw bytes of an attachment.
9563
+ * Create a linear gradient using angle and length (CSS-style).
8532
9564
  *
8533
- * Convenience method that delegates to `pdf.attachments.get()`.
9565
+ * @param options - Gradient options including angle, length, and color stops
9566
+ * @returns PDFShading resource for use with page.registerShading()
8534
9567
  *
8535
- * @param name The attachment name (key in the EmbeddedFiles tree)
8536
- * @returns The attachment bytes, or null if not found
9568
+ * @example
9569
+ * ```typescript
9570
+ * const gradient = pdf.createLinearGradient({
9571
+ * angle: 90, // CSS convention: 0 = up, 90 = right, 180 = down, 270 = left
9572
+ * length: 100,
9573
+ * stops: [
9574
+ * { offset: 0, color: rgb(1, 0, 0) },
9575
+ * { offset: 1, color: rgb(0, 0, 1) },
9576
+ * ],
9577
+ * });
9578
+ * const shadingName = page.registerShading(gradient);
9579
+ * ```
8537
9580
  */
8538
- getAttachment(name: string): Uint8Array | null;
9581
+ createLinearGradient(options: LinearGradientOptions): PDFShading;
9582
+ /**
9583
+ * Create a tiling pattern.
9584
+ *
9585
+ * @param options - Pattern options including bbox, step sizes, and operators
9586
+ * @returns PDFPattern resource for use with page.registerPattern()
9587
+ *
9588
+ * @example
9589
+ * ```typescript
9590
+ * const pattern = pdf.createTilingPattern({
9591
+ * bbox: { x: 0, y: 0, width: 10, height: 10 },
9592
+ * xStep: 10,
9593
+ * yStep: 10,
9594
+ * operators: [
9595
+ * ops.setNonStrokingRGB(0.8, 0.8, 0.8),
9596
+ * ops.rectangle(0, 0, 5, 5),
9597
+ * ops.fill(),
9598
+ * ],
9599
+ * });
9600
+ * const patternName = page.registerPattern(pattern);
9601
+ * ```
9602
+ */
9603
+ createTilingPattern(options: TilingPatternOptions): PDFTilingPattern;
9604
+ /**
9605
+ * Create an image pattern for filling shapes with a tiled image.
9606
+ *
9607
+ * This is a convenience method that creates a tiling pattern containing
9608
+ * an embedded image. Similar to CSS `background-image` with `background-repeat`.
9609
+ *
9610
+ * @param options - Image pattern options including the image and tile dimensions
9611
+ * @returns PDFTilingPattern resource for use with page.registerPattern()
9612
+ *
9613
+ * @example
9614
+ * ```typescript
9615
+ * // Create a repeating texture pattern
9616
+ * const texture = pdf.embedImage(textureBytes);
9617
+ * const pattern = pdf.createImagePattern({
9618
+ * image: texture,
9619
+ * width: 50, // Each tile is 50x50 points
9620
+ * height: 50,
9621
+ * });
9622
+ *
9623
+ * const patternName = page.registerPattern(pattern);
9624
+ * page.drawOperators([
9625
+ * ops.setNonStrokingColorSpace(ColorSpace.Pattern),
9626
+ * ops.setNonStrokingColorN(patternName),
9627
+ * ops.rectangle(100, 100, 300, 200),
9628
+ * ops.fill(),
9629
+ * ]);
9630
+ *
9631
+ * // Or use with PathBuilder
9632
+ * page.drawPath()
9633
+ * .rectangle(100, 100, 300, 200)
9634
+ * .fill({ pattern });
9635
+ * ```
9636
+ *
9637
+ * @example
9638
+ * ```typescript
9639
+ * // Horizontal stripes using repeat-x
9640
+ * const stripe = pdf.embedImage(stripeBytes);
9641
+ * const pattern = pdf.createImagePattern({
9642
+ * image: stripe,
9643
+ * width: 100,
9644
+ * height: 20,
9645
+ * repeat: "repeat-x",
9646
+ * });
9647
+ * ```
9648
+ */
9649
+ createImagePattern(options: ImagePatternOptions): PDFTilingPattern;
9650
+ /**
9651
+ * Create a shading pattern from a shading (gradient).
9652
+ *
9653
+ * Shading patterns wrap a gradient so it can be used as a fill or stroke color,
9654
+ * just like tiling patterns. This is the recommended way to use gradients with
9655
+ * PathBuilder and high-level drawing methods.
9656
+ *
9657
+ * @param options - Shading pattern options (shading and optional matrix)
9658
+ * @returns PDFShadingPattern resource for use with page.registerPattern()
9659
+ *
9660
+ * @example
9661
+ * ```typescript
9662
+ * // Create a gradient
9663
+ * const gradient = pdf.createAxialShading({
9664
+ * coords: [0, 0, 100, 0],
9665
+ * stops: [
9666
+ * { offset: 0, color: rgb(1, 0, 0) },
9667
+ * { offset: 1, color: rgb(0, 0, 1) },
9668
+ * ],
9669
+ * });
9670
+ *
9671
+ * // Wrap in a pattern
9672
+ * const gradientPattern = pdf.createShadingPattern({ shading: gradient });
9673
+ *
9674
+ * // Use with PathBuilder
9675
+ * page.drawPath()
9676
+ * .circle(200, 200, 50)
9677
+ * .fill({ pattern: gradientPattern });
9678
+ *
9679
+ * // Or register and use directly
9680
+ * const patternName = page.registerPattern(gradientPattern);
9681
+ * page.drawOperators([
9682
+ * ops.setNonStrokingColorSpace(ColorSpace.Pattern),
9683
+ * ops.setNonStrokingColorN(patternName),
9684
+ * ops.rectangle(100, 100, 200, 200),
9685
+ * ops.fill(),
9686
+ * ]);
9687
+ * ```
9688
+ */
9689
+ createShadingPattern(options: ShadingPatternOptions): PDFShadingPattern;
9690
+ /**
9691
+ * Create an extended graphics state (ExtGState) for advanced graphics options.
9692
+ *
9693
+ * @param options - ExtGState options including opacity and blend mode
9694
+ * @returns PDFExtGState resource for use with page.registerExtGState()
9695
+ *
9696
+ * @example
9697
+ * ```typescript
9698
+ * const gs = pdf.createExtGState({
9699
+ * fillOpacity: 0.5,
9700
+ * strokeOpacity: 0.8,
9701
+ * blendMode: "Multiply",
9702
+ * });
9703
+ * const gsName = page.registerExtGState(gs);
9704
+ * ```
9705
+ */
9706
+ createExtGState(options: ExtGStateOptions): PDFExtGState;
9707
+ /**
9708
+ * Create a Form XObject (reusable content).
9709
+ *
9710
+ * @param options - Form XObject options including bbox and operators
9711
+ * @returns PDFFormXObject resource for use with page.registerXObject()
9712
+ *
9713
+ * @example
9714
+ * ```typescript
9715
+ * const stamp = pdf.createFormXObject({
9716
+ * bbox: { x: 0, y: 0, width: 100, height: 50 },
9717
+ * operators: [
9718
+ * ops.setNonStrokingRGB(1, 0, 0),
9719
+ * ops.rectangle(0, 0, 100, 50),
9720
+ * ops.fill(),
9721
+ * ],
9722
+ * });
9723
+ * const xobjectName = page.registerXObject(stamp);
9724
+ *
9725
+ * // Use on multiple pages
9726
+ * for (const page of pdf.getPages()) {
9727
+ * page.drawOperators([
9728
+ * ops.pushGraphicsState(),
9729
+ * ops.concatMatrix(1, 0, 0, 1, 200, 700),
9730
+ * ops.paintXObject(xobjectName),
9731
+ * ops.popGraphicsState(),
9732
+ * ]);
9733
+ * }
9734
+ * ```
9735
+ */
9736
+ createFormXObject(options: FormXObjectOptions): PDFFormXObject;
9737
+ /**
9738
+ * Access the attachments API for managing file attachments.
9739
+ *
9740
+ * @example
9741
+ * ```typescript
9742
+ * // List attachments
9743
+ * const attachments = await pdf.attachments.list();
9744
+ *
9745
+ * // Add an attachment
9746
+ * await pdf.attachments.add("report.pdf", pdfBytes, {
9747
+ * description: "Annual report",
9748
+ * });
9749
+ *
9750
+ * // Get attachment data
9751
+ * const data = await pdf.attachments.get("report.pdf");
9752
+ *
9753
+ * // Remove an attachment
9754
+ * await pdf.attachments.remove("old-file.txt");
9755
+ * ```
9756
+ */
9757
+ get attachments(): PDFAttachments;
9758
+ /**
9759
+ * List all attachments in the document.
9760
+ *
9761
+ * Convenience method that delegates to `pdf.attachments.list()`.
9762
+ *
9763
+ * @returns Map of attachment name to attachment info
9764
+ */
9765
+ getAttachments(): Map<string, AttachmentInfo>;
9766
+ /**
9767
+ * Get the raw bytes of an attachment.
9768
+ *
9769
+ * Convenience method that delegates to `pdf.attachments.get()`.
9770
+ *
9771
+ * @param name The attachment name (key in the EmbeddedFiles tree)
9772
+ * @returns The attachment bytes, or null if not found
9773
+ */
9774
+ getAttachment(name: string): Uint8Array | null;
8539
9775
  /**
8540
9776
  * Check if an attachment exists.
8541
9777
  *
@@ -9301,7 +10537,7 @@ declare class Standard14Font {
9301
10537
  sizeAtWidth(text: string, width: number): number;
9302
10538
  }
9303
10539
  //#endregion
9304
- //#region src/api/drawing/text-layout.d.ts
10540
+ //#region src/drawing/text-layout.d.ts
9305
10541
  /**
9306
10542
  * A single line of laid out text.
9307
10543
  */
@@ -9367,6 +10603,757 @@ declare function layoutText(text: string, font: FontInput, fontSize: number, max
9367
10603
  */
9368
10604
  declare function layoutJustifiedLine(words: string[], font: FontInput, fontSize: number, targetWidth: number): PositionedWord[];
9369
10605
  //#endregion
10606
+ //#region src/helpers/matrix.d.ts
10607
+ /**
10608
+ * 2D transformation matrix for PDF coordinate transformations.
10609
+ *
10610
+ * PDF uses a 3x3 transformation matrix represented as [a b c d e f]
10611
+ * which corresponds to the matrix:
10612
+ *
10613
+ * | a b 0 |
10614
+ * | c d 0 |
10615
+ * | e f 1 |
10616
+ *
10617
+ * This is used for both the CTM (Current Transformation Matrix) and
10618
+ * text matrices (Tm/Tlm).
10619
+ */
10620
+ /** biome-ignore-all lint/suspicious/useAdjacentOverloadSignatures: biome is whiffing */
10621
+ declare class Matrix {
10622
+ readonly a: number;
10623
+ readonly b: number;
10624
+ readonly c: number;
10625
+ readonly d: number;
10626
+ readonly e: number;
10627
+ readonly f: number;
10628
+ constructor(a: number, b: number, c: number, d: number, e: number, f: number);
10629
+ /**
10630
+ * Create an identity matrix.
10631
+ */
10632
+ static identity(): Matrix;
10633
+ /**
10634
+ * Create a matrix from an array of 6 numbers.
10635
+ */
10636
+ static fromArray(arr: number[]): Matrix;
10637
+ /**
10638
+ * Create a translation matrix.
10639
+ */
10640
+ static translate(tx: number, ty: number): Matrix;
10641
+ /**
10642
+ * Create a scaling matrix.
10643
+ */
10644
+ static scale(sx: number, sy: number): Matrix;
10645
+ /**
10646
+ * Create a rotation matrix (angle in radians).
10647
+ */
10648
+ static rotate(angle: number): Matrix;
10649
+ /**
10650
+ * Multiply this matrix by another: this × other.
10651
+ *
10652
+ * Matrix multiplication is done as:
10653
+ * | a1 b1 0 | | a2 b2 0 |
10654
+ * | c1 d1 0 | × | c2 d2 0 |
10655
+ * | e1 f1 1 | | e2 f2 1 |
10656
+ */
10657
+ multiply(other: Matrix): Matrix;
10658
+ /**
10659
+ * Apply a translation to this matrix.
10660
+ */
10661
+ translate(tx: number, ty: number): Matrix;
10662
+ /**
10663
+ * Apply scaling to this matrix.
10664
+ */
10665
+ scale(sx: number, sy: number): Matrix;
10666
+ /**
10667
+ * Apply rotation to this matrix (angle in radians).
10668
+ */
10669
+ rotate(angle: number): Matrix;
10670
+ /**
10671
+ * Transform a point using this matrix.
10672
+ *
10673
+ * x' = a*x + c*y + e
10674
+ * y' = b*x + d*y + f
10675
+ */
10676
+ transformPoint(x: number, y: number): {
10677
+ x: number;
10678
+ y: number;
10679
+ };
10680
+ /**
10681
+ * Transform a distance (vector) using this matrix.
10682
+ * Unlike transformPoint, this doesn't include the translation component.
10683
+ *
10684
+ * dx' = a*dx + c*dy
10685
+ * dy' = b*dx + d*dy
10686
+ */
10687
+ transformDistance(dx: number, dy: number): {
10688
+ dx: number;
10689
+ dy: number;
10690
+ };
10691
+ /**
10692
+ * Get the horizontal scaling factor.
10693
+ * This is sqrt(a² + b²).
10694
+ */
10695
+ getScaleX(): number;
10696
+ /**
10697
+ * Get the vertical scaling factor.
10698
+ * This is sqrt(c² + d²).
10699
+ */
10700
+ getScaleY(): number;
10701
+ /**
10702
+ * Get the rotation angle in radians.
10703
+ */
10704
+ getRotation(): number;
10705
+ /**
10706
+ * Clone this matrix.
10707
+ */
10708
+ clone(): Matrix;
10709
+ /**
10710
+ * Check if this is approximately an identity matrix.
10711
+ */
10712
+ isIdentity(tolerance?: number): boolean;
10713
+ /**
10714
+ * Convert to array format [a, b, c, d, e, f].
10715
+ */
10716
+ toArray(): [number, number, number, number, number, number];
10717
+ toString(): string;
10718
+ }
10719
+ declare namespace operators_d_exports {
10720
+ export { beginMarkedContent, beginMarkedContentProps, beginText, clip, clipEvenOdd, closeAndStroke, closeFillAndStroke, closeFillAndStrokeEvenOdd, closePath, concatMatrix, curveTo, curveToFinal, curveToInitial, designateMarkedContentPoint, designateMarkedContentPointProps, drawXObject, endMarkedContent, endPath, endText, fill, fillAndStroke, fillAndStrokeEvenOdd, fillCompat, fillEvenOdd, lineTo, moveAndShowText, moveSetSpacingShowText, moveText, moveTextSetLeading, moveTo, nextLine, paintShading, paintXObject, popGraphicsState, pushGraphicsState, rectangle, setCharSpacing, setDashPattern, setFont, setGraphicsState, setHorizontalScale, setLeading, setLineCap, setLineJoin, setLineWidth, setMiterLimit, setNonStrokingCMYK, setNonStrokingColor, setNonStrokingColorN, setNonStrokingColorSpace, setNonStrokingGray, setNonStrokingRGB, setStrokingCMYK, setStrokingColor, setStrokingColorN, setStrokingColorSpace, setStrokingGray, setStrokingRGB, setTextMatrix, setTextRenderMode, setTextRise, setWordSpacing, showText, showTextArray, stroke };
10721
+ }
10722
+ /**
10723
+ * Save the current graphics state on the stack (q operator).
10724
+ *
10725
+ * The graphics state includes:
10726
+ * - Current transformation matrix (CTM)
10727
+ * - Clipping path
10728
+ * - Color and color space (stroke and fill)
10729
+ * - Line width, cap, join, dash pattern
10730
+ * - Text state parameters
10731
+ * - Extended graphics state (opacity, blend mode)
10732
+ *
10733
+ * **Best Practice:** Always pair with popGraphicsState(). Use push/pop to:
10734
+ * - Isolate transformations (rotation, scaling, translation)
10735
+ * - Limit clipping regions to specific content
10736
+ * - Apply temporary opacity or blend modes
10737
+ *
10738
+ * @example
10739
+ * ```typescript
10740
+ * page.drawOperators([
10741
+ * ops.pushGraphicsState(),
10742
+ * ops.concatMatrix(1, 0, 0, 1, 100, 200), // This transform...
10743
+ * ops.setNonStrokingRGB(1, 0, 0), // ...and this color...
10744
+ * ops.rectangle(0, 0, 50, 50),
10745
+ * ops.fill(),
10746
+ * ops.popGraphicsState(), // ...are now restored
10747
+ * // Back to original state
10748
+ * ]);
10749
+ * ```
10750
+ */
10751
+ declare const pushGraphicsState: () => Operator;
10752
+ /**
10753
+ * Restore the graphics state from the stack (Q operator).
10754
+ *
10755
+ * Restores all graphics parameters to the values they had when
10756
+ * pushGraphicsState() was last called. This includes CTM, colors,
10757
+ * clipping path, and extended graphics state.
10758
+ *
10759
+ * @see pushGraphicsState
10760
+ */
10761
+ declare const popGraphicsState: () => Operator;
10762
+ /**
10763
+ * Concatenate a transformation matrix to the current transformation matrix.
10764
+ *
10765
+ * Accepts either a Matrix instance or 6 individual matrix components [a, b, c, d, e, f].
10766
+ *
10767
+ * @example
10768
+ * ```typescript
10769
+ * // Using Matrix instance
10770
+ * const matrix = Matrix.identity().translate(100, 200).scale(2, 2);
10771
+ * ops.concatMatrix(matrix)
10772
+ *
10773
+ * // Using individual components
10774
+ * ops.concatMatrix(1, 0, 0, 1, 100, 200) // translate
10775
+ * ```
10776
+ */
10777
+ declare function concatMatrix(matrix: Matrix): Operator;
10778
+ declare function concatMatrix(a: number, b: number, c: number, d: number, e: number, f: number): Operator;
10779
+ /**
10780
+ * Set the line width for stroking operations.
10781
+ *
10782
+ * @param width - Line width in user space units (points)
10783
+ */
10784
+ declare const setLineWidth: (width: number) => Operator;
10785
+ /**
10786
+ * Set the line cap style for stroking operations.
10787
+ *
10788
+ * @param cap - Line cap style:
10789
+ * - 0: Butt cap (stroke ends at the endpoint)
10790
+ * - 1: Round cap (semicircle at endpoint)
10791
+ * - 2: Projecting square cap (extends half line width past endpoint)
10792
+ */
10793
+ declare const setLineCap: (cap: 0 | 1 | 2) => Operator;
10794
+ /**
10795
+ * Set the line join style for stroking operations.
10796
+ *
10797
+ * @param join - Line join style:
10798
+ * - 0: Miter join (extended outer edges meet at an angle)
10799
+ * - 1: Round join (circular arc at join)
10800
+ * - 2: Bevel join (triangle fills the gap)
10801
+ */
10802
+ declare const setLineJoin: (join: 0 | 1 | 2) => Operator;
10803
+ /**
10804
+ * Set the miter limit for line joins.
10805
+ *
10806
+ * When two line segments meet at a sharp angle and miter joins are specified,
10807
+ * the miter may extend far beyond the join point. The miter limit imposes a
10808
+ * maximum ratio of miter length to line width.
10809
+ *
10810
+ * @param limit - Miter limit ratio (minimum 1.0)
10811
+ */
10812
+ declare const setMiterLimit: (limit: number) => Operator;
10813
+ /**
10814
+ * Set the dash pattern for stroking operations.
10815
+ *
10816
+ * @param array - Array of dash and gap lengths (empty for solid line)
10817
+ * @param phase - Offset into the dash pattern to start from
10818
+ *
10819
+ * @example
10820
+ * ```typescript
10821
+ * // Dashed line: 8pt dash, 4pt gap
10822
+ * ops.setDashPattern(new PdfArray([PdfNumber.of(8), PdfNumber.of(4)]), 0)
10823
+ *
10824
+ * // Solid line (reset)
10825
+ * ops.setDashPattern(new PdfArray([]), 0)
10826
+ * ```
10827
+ */
10828
+ declare const setDashPattern: (array: PdfArray, phase: number) => Operator;
10829
+ /**
10830
+ * Set the extended graphics state from a named resource.
10831
+ *
10832
+ * Extended graphics state includes parameters like opacity, blend mode,
10833
+ * and other advanced graphics settings not in the basic graphics state.
10834
+ *
10835
+ * @param name - Resource name (e.g., "GS0"); normalized to have leading slash
10836
+ */
10837
+ declare const setGraphicsState: (name: string) => Operator;
10838
+ /**
10839
+ * Begin a new subpath at the given point.
10840
+ *
10841
+ * Moves the current point without drawing. Subsequent lineTo/curveTo
10842
+ * operations will start from this point.
10843
+ *
10844
+ * @param x - X coordinate in user space
10845
+ * @param y - Y coordinate in user space
10846
+ */
10847
+ declare const moveTo: (x: number, y: number) => Operator;
10848
+ /**
10849
+ * Append a straight line segment to the current path.
10850
+ *
10851
+ * Draws a line from the current point to (x, y) and makes (x, y)
10852
+ * the new current point.
10853
+ *
10854
+ * @param x - X coordinate of endpoint
10855
+ * @param y - Y coordinate of endpoint
10856
+ */
10857
+ declare const lineTo: (x: number, y: number) => Operator;
10858
+ /**
10859
+ * Append a cubic Bezier curve to the current path.
10860
+ *
10861
+ * The curve extends from the current point to (x3, y3), using
10862
+ * (x1, y1) and (x2, y2) as control points.
10863
+ *
10864
+ * @param x1 - X coordinate of first control point
10865
+ * @param y1 - Y coordinate of first control point
10866
+ * @param x2 - X coordinate of second control point
10867
+ * @param y2 - Y coordinate of second control point
10868
+ * @param x3 - X coordinate of endpoint
10869
+ * @param y3 - Y coordinate of endpoint
10870
+ */
10871
+ declare const curveTo: (x1: number, y1: number, x2: number, y2: number, x3: number, y3: number) => Operator;
10872
+ /**
10873
+ * Append a cubic Bezier curve using current point as first control point.
10874
+ *
10875
+ * The curve extends from the current point to (x3, y3). The first control
10876
+ * point is the current point; (x2, y2) is the second control point.
10877
+ *
10878
+ * @param x2 - X coordinate of second control point
10879
+ * @param y2 - Y coordinate of second control point
10880
+ * @param x3 - X coordinate of endpoint
10881
+ * @param y3 - Y coordinate of endpoint
10882
+ */
10883
+ declare const curveToInitial: (x2: number, y2: number, x3: number, y3: number) => Operator;
10884
+ /**
10885
+ * Append a cubic Bezier curve using endpoint as second control point.
10886
+ *
10887
+ * The curve extends from the current point to (x3, y3). Uses (x1, y1)
10888
+ * as first control point; the second control point coincides with (x3, y3).
10889
+ *
10890
+ * @param x1 - X coordinate of first control point
10891
+ * @param y1 - Y coordinate of first control point
10892
+ * @param x3 - X coordinate of endpoint
10893
+ * @param y3 - Y coordinate of endpoint
10894
+ */
10895
+ declare const curveToFinal: (x1: number, y1: number, x3: number, y3: number) => Operator;
10896
+ /**
10897
+ * Close the current subpath by appending a straight line to the start point.
10898
+ *
10899
+ * Draws a line from the current point to the starting point of the current
10900
+ * subpath (the point of the most recent moveTo).
10901
+ */
10902
+ declare const closePath: () => Operator;
10903
+ /**
10904
+ * Append a rectangle to the current path.
10905
+ *
10906
+ * Equivalent to: moveTo(x, y), lineTo(x+width, y), lineTo(x+width, y+height),
10907
+ * lineTo(x, y+height), closePath().
10908
+ *
10909
+ * @param x - X coordinate of lower-left corner
10910
+ * @param y - Y coordinate of lower-left corner
10911
+ * @param width - Width of rectangle
10912
+ * @param height - Height of rectangle
10913
+ */
10914
+ declare const rectangle: (x: number, y: number, width: number, height: number) => Operator;
10915
+ /** Stroke the current path using the current stroking color and line settings. */
10916
+ declare const stroke: () => Operator;
10917
+ /** Close the current subpath and then stroke the path. */
10918
+ declare const closeAndStroke: () => Operator;
10919
+ /**
10920
+ * Fill the current path using the non-zero winding number rule.
10921
+ *
10922
+ * Areas enclosed by the path are filled with the current non-stroking color.
10923
+ */
10924
+ declare const fill: () => Operator;
10925
+ /**
10926
+ * Fill the current path using the non-zero winding number rule.
10927
+ *
10928
+ * @deprecated Use fill() instead. This is the legacy 'F' operator which is
10929
+ * equivalent to the 'f' operator.
10930
+ */
10931
+ declare const fillCompat: () => Operator;
10932
+ /**
10933
+ * Fill the current path using the even-odd rule.
10934
+ *
10935
+ * The even-odd rule determines whether a point is inside the path by
10936
+ * counting path crossings. Points with an odd count are inside.
10937
+ */
10938
+ declare const fillEvenOdd: () => Operator;
10939
+ /** Fill and then stroke the current path (non-zero winding fill rule). */
10940
+ declare const fillAndStroke: () => Operator;
10941
+ /** Fill (even-odd rule) and then stroke the current path. */
10942
+ declare const fillAndStrokeEvenOdd: () => Operator;
10943
+ /** Close, fill (non-zero winding), and stroke the current path. */
10944
+ declare const closeFillAndStroke: () => Operator;
10945
+ /** Close, fill (even-odd), and stroke the current path. */
10946
+ declare const closeFillAndStrokeEvenOdd: () => Operator;
10947
+ /**
10948
+ * End the path without filling or stroking.
10949
+ *
10950
+ * Use this after clipping to discard the path used for the clipping region.
10951
+ */
10952
+ declare const endPath: () => Operator;
10953
+ /**
10954
+ * Intersect the current clipping path with the current path (non-zero winding rule).
10955
+ *
10956
+ * **Important:** The clip operator modifies the clipping path but does NOT consume
10957
+ * the current path. You MUST follow clip() with a path-painting operator:
10958
+ * - `endPath()` - Discard the path (most common for clipping)
10959
+ * - `fill()` - Fill the path AND use it for clipping
10960
+ * - `stroke()` - Stroke the path AND use it for clipping
10961
+ *
10962
+ * The clipping region persists until popGraphicsState() is called.
10963
+ * Always wrap clipping operations in pushGraphicsState()/popGraphicsState().
10964
+ *
10965
+ * @example
10966
+ * ```typescript
10967
+ * // Clip subsequent drawing to a rectangle
10968
+ * page.drawOperators([
10969
+ * ops.pushGraphicsState(),
10970
+ * ops.rectangle(50, 50, 100, 100),
10971
+ * ops.clip(),
10972
+ * ops.endPath(), // REQUIRED - consumes the path
10973
+ * // Now draw content that will be clipped
10974
+ * ops.paintShading(gradientName),
10975
+ * ops.popGraphicsState(), // Clipping region is restored
10976
+ * ]);
10977
+ * ```
10978
+ *
10979
+ * @see clipEvenOdd for the even-odd winding rule variant
10980
+ * @see endPath to consume the path after clipping
10981
+ */
10982
+ declare const clip: () => Operator;
10983
+ /**
10984
+ * Intersect the current clipping path with the current path (even-odd rule).
10985
+ *
10986
+ * Like clip(), but uses the even-odd rule to determine what's inside the path.
10987
+ * The even-odd rule counts path crossings - points with an odd count are inside.
10988
+ *
10989
+ * **Important:** Must be followed by a path-painting operator (fill, stroke, or endPath).
10990
+ *
10991
+ * @example
10992
+ * ```typescript
10993
+ * // Create a donut-shaped clipping region
10994
+ * page.drawOperators([
10995
+ * ops.pushGraphicsState(),
10996
+ * // Outer circle
10997
+ * ops.moveTo(150, 100), // ... circle path ops
10998
+ * // Inner circle (drawn in same direction)
10999
+ * ops.moveTo(120, 100), // ... circle path ops
11000
+ * ops.clipEvenOdd(),
11001
+ * ops.endPath(),
11002
+ * // Content here is clipped to the donut shape
11003
+ * ops.popGraphicsState(),
11004
+ * ]);
11005
+ * ```
11006
+ *
11007
+ * @see clip for the non-zero winding rule variant
11008
+ */
11009
+ declare const clipEvenOdd: () => Operator;
11010
+ /**
11011
+ * Set the character spacing (extra space between characters).
11012
+ *
11013
+ * @param spacing - Additional space in text space units (default 0)
11014
+ */
11015
+ declare const setCharSpacing: (spacing: number) => Operator;
11016
+ /**
11017
+ * Set the word spacing (extra space between words).
11018
+ *
11019
+ * Word spacing is added to each ASCII space character (0x20).
11020
+ *
11021
+ * @param spacing - Additional space in text space units (default 0)
11022
+ */
11023
+ declare const setWordSpacing: (spacing: number) => Operator;
11024
+ /**
11025
+ * Set the horizontal scaling factor for text.
11026
+ *
11027
+ * @param scale - Percentage of normal width (100 = normal)
11028
+ */
11029
+ declare const setHorizontalScale: (scale: number) => Operator;
11030
+ /**
11031
+ * Set the text leading (line spacing).
11032
+ *
11033
+ * Used by nextLine() and moveTextSetLeading() to move to the next line.
11034
+ *
11035
+ * @param leading - Vertical distance between baselines (in text space units)
11036
+ */
11037
+ declare const setLeading: (leading: number) => Operator;
11038
+ /**
11039
+ * Set the font and size for text operations.
11040
+ *
11041
+ * @param name - Font resource name (e.g., "F0"); normalized to have leading slash
11042
+ * @param size - Font size in text space units
11043
+ */
11044
+ declare const setFont: (name: string, size: number) => Operator;
11045
+ /**
11046
+ * Set the text rendering mode.
11047
+ *
11048
+ * @param mode - Rendering mode:
11049
+ * - 0: Fill text
11050
+ * - 1: Stroke text
11051
+ * - 2: Fill then stroke
11052
+ * - 3: Invisible (no fill or stroke)
11053
+ * - 4: Fill and add to clipping path
11054
+ * - 5: Stroke and add to clipping path
11055
+ * - 6: Fill, stroke, and add to clipping path
11056
+ * - 7: Add to clipping path (invisible)
11057
+ */
11058
+ declare const setTextRenderMode: (mode: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7) => Operator;
11059
+ /**
11060
+ * Set the text rise (baseline offset).
11061
+ *
11062
+ * Moves the baseline up (positive) or down (negative) relative to the
11063
+ * current text line. Used for superscripts and subscripts.
11064
+ *
11065
+ * @param rise - Vertical offset in text space units
11066
+ */
11067
+ declare const setTextRise: (rise: number) => Operator;
11068
+ /**
11069
+ * Begin a text object.
11070
+ *
11071
+ * Text operations (showText, moveText, setFont, etc.) can only be used
11072
+ * between beginText() and endText().
11073
+ */
11074
+ declare const beginText: () => Operator;
11075
+ /** End the text object and restore the text state. */
11076
+ declare const endText: () => Operator;
11077
+ /**
11078
+ * Move to the start of the next line, offset from the current line origin.
11079
+ *
11080
+ * @param tx - Horizontal offset in text space units
11081
+ * @param ty - Vertical offset in text space units
11082
+ */
11083
+ declare const moveText: (tx: number, ty: number) => Operator;
11084
+ /**
11085
+ * Move to the next line and set the leading.
11086
+ *
11087
+ * Equivalent to: setLeading(-ty), moveText(tx, ty).
11088
+ *
11089
+ * @param tx - Horizontal offset in text space units
11090
+ * @param ty - Vertical offset (negative of the leading)
11091
+ */
11092
+ declare const moveTextSetLeading: (tx: number, ty: number) => Operator;
11093
+ /**
11094
+ * Set the text matrix and text line matrix.
11095
+ *
11096
+ * Unlike concatMatrix, this replaces (not concatenates) the text matrix.
11097
+ *
11098
+ * @param a - Horizontal scaling
11099
+ * @param b - Horizontal skewing
11100
+ * @param c - Vertical skewing
11101
+ * @param d - Vertical scaling
11102
+ * @param e - Horizontal translation (text position X)
11103
+ * @param f - Vertical translation (text position Y)
11104
+ */
11105
+ declare const setTextMatrix: (a: number, b: number, c: number, d: number, e: number, f: number) => Operator;
11106
+ /**
11107
+ * Move to the start of the next line.
11108
+ *
11109
+ * Equivalent to: moveText(0, -leading), where leading is the current text leading.
11110
+ */
11111
+ declare const nextLine: () => Operator;
11112
+ /**
11113
+ * Show a text string.
11114
+ *
11115
+ * Accepts either a plain string (auto-encoded) or a PdfString instance.
11116
+ * Plain strings are encoded using PdfString.fromString() which picks
11117
+ * the optimal encoding.
11118
+ */
11119
+ declare const showText: (text: string | PdfString) => Operator;
11120
+ /**
11121
+ * Show text strings with individual position adjustments.
11122
+ *
11123
+ * The array contains strings and numbers. Numbers are horizontal adjustments
11124
+ * in thousandths of a text space unit (negative = move right).
11125
+ *
11126
+ * @param array - Array of strings and position adjustments
11127
+ *
11128
+ * @example
11129
+ * ```typescript
11130
+ * // Kern "AV" by moving V slightly left
11131
+ * ops.showTextArray(new PdfArray([
11132
+ * PdfString.fromString("A"),
11133
+ * PdfNumber.of(-50), // Move left 50/1000 of text space
11134
+ * PdfString.fromString("V"),
11135
+ * ]))
11136
+ * ```
11137
+ */
11138
+ declare const showTextArray: (array: PdfArray) => Operator;
11139
+ /**
11140
+ * Move to next line and show text.
11141
+ *
11142
+ * Accepts either a plain string (auto-encoded) or a PdfString instance.
11143
+ */
11144
+ declare const moveAndShowText: (text: string | PdfString) => Operator;
11145
+ /**
11146
+ * Move to next line, set word and character spacing, and show text.
11147
+ *
11148
+ * Accepts either a plain string (auto-encoded) or a PdfString instance.
11149
+ */
11150
+ declare const moveSetSpacingShowText: (wordSpacing: number, charSpacing: number, text: string | PdfString) => Operator;
11151
+ /**
11152
+ * Set the stroking color space.
11153
+ *
11154
+ * @param name - Color space name (e.g., "DeviceRGB", "Pattern"); normalized to have leading slash
11155
+ */
11156
+ declare const setStrokingColorSpace: (name: string) => Operator;
11157
+ /**
11158
+ * Set the non-stroking (fill) color space.
11159
+ *
11160
+ * @param name - Color space name (e.g., "DeviceRGB", "Pattern"); normalized to have leading slash
11161
+ */
11162
+ declare const setNonStrokingColorSpace: (name: string) => Operator;
11163
+ /**
11164
+ * Set the stroking color in the current color space.
11165
+ *
11166
+ * Number of components depends on the current stroking color space.
11167
+ *
11168
+ * @param components - Color component values (0-1 for most color spaces)
11169
+ */
11170
+ declare const setStrokingColor: (...components: number[]) => Operator;
11171
+ /**
11172
+ * Set stroking color with extended color space.
11173
+ *
11174
+ * String components (like pattern names) are normalized to have leading slashes.
11175
+ */
11176
+ declare const setStrokingColorN: (...components: (number | string)[]) => Operator;
11177
+ /**
11178
+ * Set the non-stroking (fill) color in the current color space.
11179
+ *
11180
+ * Number of components depends on the current non-stroking color space.
11181
+ *
11182
+ * @param components - Color component values (0-1 for most color spaces)
11183
+ */
11184
+ declare const setNonStrokingColor: (...components: number[]) => Operator;
11185
+ /**
11186
+ * Set non-stroking (fill) color with extended color space.
11187
+ *
11188
+ * String components (like pattern names) are normalized to have leading slashes.
11189
+ */
11190
+ declare const setNonStrokingColorN: (...components: (number | string)[]) => Operator;
11191
+ /**
11192
+ * Set the stroking color to a grayscale value.
11193
+ *
11194
+ * Equivalent to setStrokingColorSpace("DeviceGray"), setStrokingColor(gray).
11195
+ *
11196
+ * @param gray - Gray value (0 = black, 1 = white)
11197
+ */
11198
+ declare const setStrokingGray: (gray: number) => Operator;
11199
+ /**
11200
+ * Set the non-stroking (fill) color to a grayscale value.
11201
+ *
11202
+ * Equivalent to setNonStrokingColorSpace("DeviceGray"), setNonStrokingColor(gray).
11203
+ *
11204
+ * @param gray - Gray value (0 = black, 1 = white)
11205
+ */
11206
+ declare const setNonStrokingGray: (gray: number) => Operator;
11207
+ /**
11208
+ * Set the stroking color to an RGB value.
11209
+ *
11210
+ * Equivalent to setStrokingColorSpace("DeviceRGB"), setStrokingColor(r, g, b).
11211
+ *
11212
+ * @param r - Red component (0-1)
11213
+ * @param g - Green component (0-1)
11214
+ * @param b - Blue component (0-1)
11215
+ */
11216
+ declare const setStrokingRGB: (r: number, g: number, b: number) => Operator;
11217
+ /**
11218
+ * Set the non-stroking (fill) color to an RGB value.
11219
+ *
11220
+ * Equivalent to setNonStrokingColorSpace("DeviceRGB"), setNonStrokingColor(r, g, b).
11221
+ *
11222
+ * @param r - Red component (0-1)
11223
+ * @param g - Green component (0-1)
11224
+ * @param b - Blue component (0-1)
11225
+ */
11226
+ declare const setNonStrokingRGB: (r: number, g: number, b: number) => Operator;
11227
+ /**
11228
+ * Set the stroking color to a CMYK value.
11229
+ *
11230
+ * Equivalent to setStrokingColorSpace("DeviceCMYK"), setStrokingColor(c, m, y, k).
11231
+ *
11232
+ * @param c - Cyan component (0-1)
11233
+ * @param m - Magenta component (0-1)
11234
+ * @param y - Yellow component (0-1)
11235
+ * @param k - Black component (0-1)
11236
+ */
11237
+ declare const setStrokingCMYK: (c: number, m: number, y: number, k: number) => Operator;
11238
+ /**
11239
+ * Set the non-stroking (fill) color to a CMYK value.
11240
+ *
11241
+ * Equivalent to setNonStrokingColorSpace("DeviceCMYK"), setNonStrokingColor(c, m, y, k).
11242
+ *
11243
+ * @param c - Cyan component (0-1)
11244
+ * @param m - Magenta component (0-1)
11245
+ * @param y - Yellow component (0-1)
11246
+ * @param k - Black component (0-1)
11247
+ */
11248
+ declare const setNonStrokingCMYK: (c: number, m: number, y: number, k: number) => Operator;
11249
+ /**
11250
+ * @deprecated Use paintXObject instead. This alias exists for backwards compatibility.
11251
+ */
11252
+ declare const drawXObject: (name: string) => Operator;
11253
+ /**
11254
+ * Paint an XObject (image or Form XObject).
11255
+ *
11256
+ * XObjects are external objects that can be rendered in a content stream:
11257
+ * - **Images**: Raster graphics (JPEG, PNG, etc.)
11258
+ * - **Form XObjects**: Reusable vector content (stamps, watermarks, etc.)
11259
+ *
11260
+ * The XObject is painted at the current origin. Use concatMatrix to
11261
+ * position, scale, and rotate before painting.
11262
+ *
11263
+ * @param name - XObject resource name (e.g., "Im0", "Fm0"); normalized to have leading slash
11264
+ *
11265
+ * @example
11266
+ * ```typescript
11267
+ * // Paint an image at 100x100 size at position (200, 500)
11268
+ * page.drawOperators([
11269
+ * ops.pushGraphicsState(),
11270
+ * ops.concatMatrix(100, 0, 0, 100, 200, 500), // Scale and translate
11271
+ * ops.paintXObject(imageName),
11272
+ * ops.popGraphicsState(),
11273
+ * ]);
11274
+ *
11275
+ * // Paint a form XObject (stamp) at original size
11276
+ * page.drawOperators([
11277
+ * ops.pushGraphicsState(),
11278
+ * ops.concatMatrix(1, 0, 0, 1, 50, 700), // Just translate
11279
+ * ops.paintXObject(stampName),
11280
+ * ops.popGraphicsState(),
11281
+ * ]);
11282
+ * ```
11283
+ */
11284
+ declare const paintXObject: (name: string) => Operator;
11285
+ /**
11286
+ * Paint a shading (gradient) directly, filling the current clipping region.
11287
+ *
11288
+ * @param name - Shading resource name (e.g., "Sh0"); normalized to have leading slash
11289
+ *
11290
+ * @example
11291
+ * ```typescript
11292
+ * // Fill a rectangle with a gradient
11293
+ * page.drawOperators([
11294
+ * ops.pushGraphicsState(),
11295
+ * ops.rectangle(50, 50, 100, 100),
11296
+ * ops.clip(),
11297
+ * ops.endPath(),
11298
+ * ops.paintShading(shadingName),
11299
+ * ops.popGraphicsState(),
11300
+ * ]);
11301
+ * ```
11302
+ */
11303
+ declare const paintShading: (name: string) => Operator;
11304
+ /**
11305
+ * Designate a marked content point (no content, just a tag).
11306
+ *
11307
+ * Used for structure and accessibility information.
11308
+ *
11309
+ * @param tag - Content tag name (e.g., "Artifact", "Figure")
11310
+ */
11311
+ declare const designateMarkedContentPoint: (tag: string) => Operator;
11312
+ /**
11313
+ * Designate a marked content point with properties.
11314
+ *
11315
+ * @param tag - Content tag name
11316
+ * @param props - Property dictionary or property list name
11317
+ */
11318
+ declare const designateMarkedContentPointProps: (tag: string, props: PdfDict | string) => Operator;
11319
+ /**
11320
+ * Begin a marked content sequence.
11321
+ *
11322
+ * Content between beginMarkedContent() and endMarkedContent() is associated
11323
+ * with the given tag for structure/accessibility purposes.
11324
+ *
11325
+ * @param tag - Content tag name (e.g., "P" for paragraph, "Span")
11326
+ */
11327
+ declare const beginMarkedContent: (tag: string) => Operator;
11328
+ /**
11329
+ * Begin a marked content sequence with properties.
11330
+ *
11331
+ * @param tag - Content tag name
11332
+ * @param props - Property dictionary or property list name
11333
+ */
11334
+ declare const beginMarkedContentProps: (tag: string, props: PdfDict | string) => Operator;
11335
+ /** End the current marked content sequence. */
11336
+ declare const endMarkedContent: () => Operator;
11337
+ //#endregion
11338
+ //#region src/helpers/colorspace.d.ts
11339
+ /**
11340
+ * PDF color space constants for use with low-level drawing operators.
11341
+ *
11342
+ * These are the standard PDF color space names used with setStrokingColorSpace
11343
+ * and setNonStrokingColorSpace operators.
11344
+ */
11345
+ declare const ColorSpace: {
11346
+ /** Device Gray color space (single component: 0-1) */
11347
+ readonly DeviceGray: "DeviceGray";
11348
+ /** Device RGB color space (three components: 0-1 each) */
11349
+ readonly DeviceRGB: "DeviceRGB";
11350
+ /** Device CMYK color space (four components: 0-1 each) */
11351
+ readonly DeviceCMYK: "DeviceCMYK";
11352
+ /** Pattern color space (for tiling patterns) */
11353
+ readonly Pattern: "Pattern";
11354
+ };
11355
+ type ColorSpace = (typeof ColorSpace)[keyof typeof ColorSpace];
11356
+ //#endregion
9370
11357
  //#region src/helpers/pem.d.ts
9371
11358
  /**
9372
11359
  * PEM encoding/decoding utilities.
@@ -9428,5 +11415,5 @@ declare function isWidgetAnnotation(dict: PdfDict, registry?: ObjectRegistry): b
9428
11415
  */
9429
11416
  declare function isPopupAnnotation(dict: PdfDict, registry?: ObjectRegistry): boolean;
9430
11417
  //#endregion
9431
- export { AnnotationFlags, type AnnotationSubtype, type AuthenticationResult, type BorderStyle, type BorderStyleType, type ButtonField, type CMYK, type CaretAnnotationOptions, type CaretSymbol, CertificateChainError, type CheckboxField, type CheckboxOptions, type CheckboxSymbol, type CircleAnnotationOptions, type Color, type CopyPagesOptions, CryptoKeySigner, type Degrees, type DestinationType, type DigestAlgorithm, type DocumentMetadata, type DrawCircleOptions, type DrawEllipseOptions, type DrawFieldOptions, type DrawImageOptions, type DrawLineOptions, type DrawPageOptions, type DrawRectangleOptions, type DrawSvgPathOptions, type DrawTextOptions, type DropdownField, type DropdownOptions, type EmbedFontOptions, type EmbeddedFont, type EncryptionAlgorithmOption, type ExtractPagesOptions, type FieldOptions, type FieldType, type FieldValue, type FileAttachmentIcon, type FlattenAllOptions, type FlattenAllResult, type FlattenAnnotationsOptions, type FlattenLayersResult, type FlattenOptions, type FontInput, type FormField, type FormProperties, type FreeTextAnnotationOptions, type FreeTextJustification, GoogleKmsSigner, type Grayscale, type HighlightMode, HttpTimestampAuthority, type HttpTimestampAuthorityOptions, type InkAnnotationOptions, type KeyType, KmsSignerError, type LayerInfo, type LayoutResult, type LineAnnotationOptions, type LineCap, type LineEndingStyle, type LineJoin, type LinkAction, type LinkAnnotationOptions, type LinkDestination, type ListBoxField, type ListboxOptions, type LoadOptions, type MergeOptions, P12Signer, type PAdESLevel, PDF, PDFAnnotation, PDFCaretAnnotation, PDFCircleAnnotation, PDFEmbeddedPage, PDFFileAttachmentAnnotation, PDFForm, PDFFreeTextAnnotation, PDFHighlightAnnotation, PDFImage, PDFInkAnnotation, PDFLineAnnotation, PDFLinkAnnotation, PDFMarkupAnnotation, PDFPage, PDFPolygonAnnotation, PDFPolylineAnnotation, PDFPopupAnnotation, PDFSquareAnnotation, PDFSquigglyAnnotation, PDFStampAnnotation, PDFStrikeOutAnnotation, PDFTextAnnotation, PDFTextMarkupAnnotation, PDFUnderlineAnnotation, PDFUnknownAnnotation, PathBuilder, type PathOptions, PdfArray, PdfBool, PdfDict, PdfName, PdfNull, PdfNumber, type PdfObject, PdfRef, PdfStream, PdfString, type PemBlock, PermissionDeniedError, type PermissionOptions, type Permissions, PlaceholderError, type Point, type PolygonAnnotationOptions, type PolylineAnnotationOptions, type PopupOptions, type PositionedWord, type ProtectionOptions, type RGB, type RadioField, type RadioGroupOptions, type RadioSymbol, type Rect, type Rectangle, type RemoveAnnotationsOptions, RevocationError, type RevocationProvider, type Rotation, type RotationOrigin, type RotationOriginName, STANDARD_STAMPS, type SaveOptions, SecurityError, type SecurityInfo, type SetTitleOptions, type SignOptions, type SignResult, type SignWarning, type SignatureAlgorithm, SignatureError, type SignatureField, type SignatureFieldOptions, type Signer, SignerError, type SquareAnnotationOptions, type StampAnnotationOptions, type StampName, Standard14Font, type Standard14FontName, StandardFonts, type SubFilter, type TextAlignment, type TextAnnotationIcon, type TextAnnotationOptions, type TextAnnotationState, type TextAnnotationStateModel, type TextField, type TextFieldOptions, type TextLine, type TextMarkupAnnotationOptions, type TimestampAuthority, TimestampError, type TrappedStatus, black, blue, cmyk, createAnnotation, degrees, grayscale, green, isPopupAnnotation, isWidgetAnnotation, layoutJustifiedLine, layoutText, lineCapToNumber, lineJoinToNumber, measureText, parsePem, rectToQuadPoints, rectsToQuadPoints, red, rgb, version, white };
11418
+ export { AnnotationFlags, type AnnotationSubtype, type AuthenticationResult, type AxialCoords, type AxialShadingOptions, type BBox, type BlendMode, type BorderStyle, type BorderStyleType, type ButtonField, type CMYK, type CaretAnnotationOptions, type CaretSymbol, CertificateChainError, type CheckboxField, type CheckboxOptions, type CheckboxSymbol, type CircleAnnotationOptions, type Color, ColorSpace, type ColorStop, type CopyPagesOptions, CryptoKeySigner, type Degrees, type DestinationType, type DigestAlgorithm, type DocumentMetadata, type DrawCircleOptions, type DrawEllipseOptions, type DrawFieldOptions, type DrawImageOptions, type DrawLineOptions, type DrawPageOptions, type DrawRectangleOptions, type DrawSvgPathOptions, type DrawTextOptions, type DropdownField, type DropdownOptions, type EmbedFontOptions, type EmbeddedFont, type EncryptionAlgorithmOption, type ExtGStateOptions, type ExtractPagesOptions, type FieldOptions, type FieldType, type FieldValue, type FileAttachmentIcon, type FlattenAllOptions, type FlattenAllResult, type FlattenAnnotationsOptions, type FlattenLayersResult, type FlattenOptions, type FontInput, type FormField, type FormProperties, type FormXObjectOptions, type FreeTextAnnotationOptions, type FreeTextJustification, GoogleKmsSigner, type Grayscale, type HighlightMode, HttpTimestampAuthority, type HttpTimestampAuthorityOptions, type ImagePatternOptions, type InkAnnotationOptions, type KeyType, KmsSignerError, type LayerInfo, type LayoutResult, type LineAnnotationOptions, type LineCap, type LineEndingStyle, type LineJoin, type LinearGradientOptions, type LinkAction, type LinkAnnotationOptions, type LinkDestination, type ListBoxField, type ListboxOptions, type LoadOptions, Matrix, type MergeOptions, P12Signer, type PAdESLevel, PDF, PDFAnnotation, PDFCaretAnnotation, PDFCircleAnnotation, PDFEmbeddedPage, type PDFExtGState, PDFFileAttachmentAnnotation, PDFForm, type PDFFormXObject, PDFFreeTextAnnotation, PDFHighlightAnnotation, PDFImage, PDFInkAnnotation, PDFLineAnnotation, PDFLinkAnnotation, PDFMarkupAnnotation, PDFPage, type PDFPattern, PDFPolygonAnnotation, PDFPolylineAnnotation, PDFPopupAnnotation, type PDFShading, type PDFShadingPattern, PDFSquareAnnotation, PDFSquigglyAnnotation, PDFStampAnnotation, PDFStrikeOutAnnotation, PDFTextAnnotation, PDFTextMarkupAnnotation, type PDFTilingPattern, PDFUnderlineAnnotation, PDFUnknownAnnotation, PathBuilder, type PathOptions, type PatternMatrix, PdfArray, PdfBool, PdfDict, PdfName, PdfNull, PdfNumber, type PdfObject, PdfRef, PdfStream, PdfString, type PemBlock, PermissionDeniedError, type PermissionOptions, type Permissions, PlaceholderError, type Point, type PolygonAnnotationOptions, type PolylineAnnotationOptions, type PopupOptions, type PositionedWord, type ProtectionOptions, type RGB, type RadialCoords, type RadialShadingOptions, type RadioField, type RadioGroupOptions, type RadioSymbol, type Rect, type Rectangle, type RemoveAnnotationsOptions, RevocationError, type RevocationProvider, type Rotation, type RotationOrigin, type RotationOriginName, STANDARD_STAMPS, type SaveOptions, SecurityError, type SecurityInfo, type SetTitleOptions, type ShadingPatternOptions, type SignOptions, type SignResult, type SignWarning, type SignatureAlgorithm, SignatureError, type SignatureField, type SignatureFieldOptions, type Signer, SignerError, type SquareAnnotationOptions, type StampAnnotationOptions, type StampName, Standard14Font, type Standard14FontName, StandardFonts, type SubFilter, type TextAlignment, type TextAnnotationIcon, type TextAnnotationOptions, type TextAnnotationState, type TextAnnotationStateModel, type TextField, type TextFieldOptions, type TextLine, type TextMarkupAnnotationOptions, type TilingPatternOptions, type TimestampAuthority, TimestampError, type TrappedStatus, black, blue, cmyk, createAnnotation, degrees, grayscale, green, isPopupAnnotation, isWidgetAnnotation, layoutJustifiedLine, layoutText, lineCapToNumber, lineJoinToNumber, measureText, operators_d_exports as ops, parsePem, rectToQuadPoints, rectsToQuadPoints, red, rgb, version, white };
9432
11419
  //# sourceMappingURL=index.d.mts.map