@libpdf/core 0.2.5 → 0.2.7
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/chunk-15K8U1wQ.mjs +18 -0
- package/dist/index.d.mts +2247 -242
- package/dist/index.mjs +8780 -7068
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
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.
|
|
@@ -2571,6 +2675,8 @@ declare class EmbeddedFont extends PdfFont {
|
|
|
2571
2675
|
private _subsetTag;
|
|
2572
2676
|
/** Whether this font is used in a form field (prevents subsetting) */
|
|
2573
2677
|
private _usedInForm;
|
|
2678
|
+
/** Pre-allocated PDF reference (set by PDFFonts.embed()) */
|
|
2679
|
+
private _ref;
|
|
2574
2680
|
/** Cached descriptor */
|
|
2575
2681
|
private _descriptor;
|
|
2576
2682
|
private constructor();
|
|
@@ -2686,6 +2792,22 @@ declare class EmbeddedFont extends PdfFont {
|
|
|
2686
2792
|
* Call this before re-encoding if you want a fresh subset.
|
|
2687
2793
|
*/
|
|
2688
2794
|
resetUsage(): void;
|
|
2795
|
+
/**
|
|
2796
|
+
* Get the pre-allocated PDF reference for this font.
|
|
2797
|
+
*
|
|
2798
|
+
* Set by `PDFFonts.embed()`. At save time, the actual font objects
|
|
2799
|
+
* (Type0 dict, CIDFont, FontDescriptor, font program, ToUnicode)
|
|
2800
|
+
* are created and registered at this ref.
|
|
2801
|
+
*
|
|
2802
|
+
* @throws {Error} if the font was not embedded via `pdf.embedFont()`
|
|
2803
|
+
*/
|
|
2804
|
+
get ref(): PdfRef;
|
|
2805
|
+
/**
|
|
2806
|
+
* Set the pre-allocated PDF reference.
|
|
2807
|
+
*
|
|
2808
|
+
* @internal Called by PDFFonts.embed()
|
|
2809
|
+
*/
|
|
2810
|
+
setRef(ref: PdfRef): void;
|
|
2689
2811
|
/**
|
|
2690
2812
|
* Mark this font as used in a form field.
|
|
2691
2813
|
*
|
|
@@ -3575,221 +3697,633 @@ declare class TextField extends TerminalField {
|
|
|
3575
3697
|
setValue(value: string): void;
|
|
3576
3698
|
}
|
|
3577
3699
|
//#endregion
|
|
3578
|
-
//#region src/
|
|
3700
|
+
//#region src/svg/path-executor.d.ts
|
|
3579
3701
|
/**
|
|
3580
|
-
*
|
|
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
|
-
* ```
|
|
3702
|
+
* Options for SVG path execution.
|
|
3593
3703
|
*/
|
|
3594
|
-
|
|
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;
|
|
3704
|
+
interface SvgPathExecutorOptions {
|
|
3601
3705
|
/**
|
|
3602
|
-
*
|
|
3603
|
-
*
|
|
3604
|
-
*
|
|
3706
|
+
* Flip Y coordinates (negate Y values).
|
|
3707
|
+
*
|
|
3708
|
+
* SVG uses a top-left origin with Y increasing downward.
|
|
3709
|
+
* PDF uses a bottom-left origin with Y increasing upward.
|
|
3710
|
+
*
|
|
3711
|
+
* When true (default), Y coordinates are negated to convert
|
|
3712
|
+
* SVG paths to PDF coordinate space.
|
|
3713
|
+
*
|
|
3714
|
+
* @default true
|
|
3605
3715
|
*/
|
|
3606
|
-
|
|
3607
|
-
constructor(ref: PdfRef, width: number, height: number, scale?: number);
|
|
3716
|
+
flipY?: boolean;
|
|
3608
3717
|
/**
|
|
3609
|
-
*
|
|
3718
|
+
* Scale factor to apply to all coordinates.
|
|
3719
|
+
* @default 1
|
|
3610
3720
|
*/
|
|
3611
|
-
|
|
3721
|
+
scale?: number;
|
|
3612
3722
|
/**
|
|
3613
|
-
*
|
|
3723
|
+
* X offset to add after scaling and flipping.
|
|
3724
|
+
* @default 0
|
|
3614
3725
|
*/
|
|
3615
|
-
|
|
3726
|
+
translateX?: number;
|
|
3616
3727
|
/**
|
|
3617
|
-
*
|
|
3728
|
+
* Y offset to add after scaling and flipping.
|
|
3729
|
+
* @default 0
|
|
3618
3730
|
*/
|
|
3619
|
-
|
|
3731
|
+
translateY?: number;
|
|
3620
3732
|
}
|
|
3621
3733
|
//#endregion
|
|
3622
|
-
//#region src/
|
|
3734
|
+
//#region src/drawing/resources/types.d.ts
|
|
3623
3735
|
/**
|
|
3624
|
-
*
|
|
3625
|
-
*
|
|
3626
|
-
* These types represent text content extracted from PDF pages,
|
|
3627
|
-
* including position information for searching and highlighting.
|
|
3736
|
+
* Common types for drawing resources.
|
|
3628
3737
|
*/
|
|
3629
3738
|
/**
|
|
3630
|
-
*
|
|
3739
|
+
* Bounding box in PDF coordinate space.
|
|
3740
|
+
*
|
|
3741
|
+
* Defines a rectangle where (x, y) is the lower-left corner.
|
|
3742
|
+
* Used for patterns, Form XObjects, and clipping regions.
|
|
3631
3743
|
*/
|
|
3632
|
-
interface
|
|
3633
|
-
/** Left edge (x coordinate) */
|
|
3744
|
+
interface BBox {
|
|
3634
3745
|
x: number;
|
|
3635
|
-
/** Bottom edge (y coordinate) */
|
|
3636
3746
|
y: number;
|
|
3637
|
-
/** Width of the box */
|
|
3638
3747
|
width: number;
|
|
3639
|
-
/** Height of the box */
|
|
3640
3748
|
height: number;
|
|
3641
3749
|
}
|
|
3642
3750
|
/**
|
|
3643
|
-
*
|
|
3751
|
+
* Matrix for transforming a pattern.
|
|
3752
|
+
*
|
|
3753
|
+
* Standard PDF transformation matrix [a, b, c, d, e, f] where:
|
|
3754
|
+
* - a, d: Scale factors
|
|
3755
|
+
* - b, c: Rotation/skew factors
|
|
3756
|
+
* - e, f: Translation
|
|
3644
3757
|
*/
|
|
3645
|
-
|
|
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
|
-
}
|
|
3758
|
+
type PatternMatrix = [a: number, b: number, c: number, d: number, e: number, f: number];
|
|
3657
3759
|
/**
|
|
3658
|
-
*
|
|
3760
|
+
* PDF blend modes for compositing.
|
|
3761
|
+
*
|
|
3762
|
+
* These control how colors are combined when drawing over existing content.
|
|
3659
3763
|
*/
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
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
|
-
}
|
|
3764
|
+
type BlendMode = "Normal" | "Multiply" | "Screen" | "Overlay" | "Darken" | "Lighten" | "ColorDodge" | "ColorBurn" | "HardLight" | "SoftLight" | "Difference" | "Exclusion" | "Hue" | "Saturation" | "Color" | "Luminosity";
|
|
3765
|
+
//#endregion
|
|
3766
|
+
//#region src/drawing/resources/shading.d.ts
|
|
3672
3767
|
/**
|
|
3673
|
-
*
|
|
3768
|
+
* Axial (linear) shading coordinates: start point (x0, y0) to end point (x1, y1).
|
|
3769
|
+
*
|
|
3770
|
+
* The gradient is drawn along the line from (x0, y0) to (x1, y1).
|
|
3674
3771
|
*/
|
|
3675
|
-
|
|
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
|
-
}
|
|
3772
|
+
type AxialCoords = [x0: number, y0: number, x1: number, y1: number];
|
|
3685
3773
|
/**
|
|
3686
|
-
*
|
|
3774
|
+
* Radial shading coordinates: two circles defined by center and radius.
|
|
3775
|
+
*
|
|
3776
|
+
* - First circle: center (x0, y0), radius r0
|
|
3777
|
+
* - Second circle: center (x1, y1), radius r1
|
|
3778
|
+
*
|
|
3779
|
+
* The gradient blends between the two circles.
|
|
3687
3780
|
*/
|
|
3688
|
-
|
|
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
|
-
}
|
|
3781
|
+
type RadialCoords = [x0: number, y0: number, r0: number, x1: number, y1: number, r1: number];
|
|
3700
3782
|
/**
|
|
3701
|
-
* A
|
|
3783
|
+
* A color stop in a gradient.
|
|
3784
|
+
*
|
|
3785
|
+
* @example
|
|
3786
|
+
* ```typescript
|
|
3787
|
+
* const stops: ColorStop[] = [
|
|
3788
|
+
* { offset: 0, color: rgb(1, 0, 0) }, // Red at start
|
|
3789
|
+
* { offset: 0.5, color: rgb(1, 1, 0) }, // Yellow at midpoint
|
|
3790
|
+
* { offset: 1, color: rgb(0, 1, 0) }, // Green at end
|
|
3791
|
+
* ];
|
|
3792
|
+
* ```
|
|
3702
3793
|
*/
|
|
3703
|
-
interface
|
|
3704
|
-
/**
|
|
3705
|
-
|
|
3706
|
-
/**
|
|
3707
|
-
|
|
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[];
|
|
3794
|
+
interface ColorStop {
|
|
3795
|
+
/** Position along the gradient (0 = start, 1 = end) */
|
|
3796
|
+
offset: number;
|
|
3797
|
+
/** Color at this position */
|
|
3798
|
+
color: Color;
|
|
3712
3799
|
}
|
|
3713
3800
|
/**
|
|
3714
|
-
* Options for
|
|
3801
|
+
* Options for creating an axial (linear) shading.
|
|
3802
|
+
*
|
|
3803
|
+
* @example
|
|
3804
|
+
* ```typescript
|
|
3805
|
+
* const gradient = pdf.createAxialShading({
|
|
3806
|
+
* coords: [0, 0, 100, 0], // Horizontal gradient, 100pt wide
|
|
3807
|
+
* stops: [
|
|
3808
|
+
* { offset: 0, color: rgb(1, 0, 0) },
|
|
3809
|
+
* { offset: 1, color: rgb(0, 0, 1) },
|
|
3810
|
+
* ],
|
|
3811
|
+
* });
|
|
3812
|
+
* ```
|
|
3715
3813
|
*/
|
|
3716
|
-
interface
|
|
3814
|
+
interface AxialShadingOptions {
|
|
3717
3815
|
/**
|
|
3718
|
-
*
|
|
3719
|
-
*
|
|
3816
|
+
* Line segment defining the gradient direction: [x0, y0, x1, y1].
|
|
3817
|
+
*
|
|
3818
|
+
* - (x0, y0): Start point where offset 0 colors appear
|
|
3819
|
+
* - (x1, y1): End point where offset 1 colors appear
|
|
3720
3820
|
*/
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
/** Match whole words only (default: false) */
|
|
3732
|
-
wholeWord?: boolean;
|
|
3821
|
+
coords: AxialCoords;
|
|
3822
|
+
/** Color stops defining the gradient colors and positions */
|
|
3823
|
+
stops: ColorStop[];
|
|
3824
|
+
/**
|
|
3825
|
+
* Whether to extend the gradient beyond its bounds.
|
|
3826
|
+
*
|
|
3827
|
+
* - [true, true] (default): Extend both ends with the endpoint colors
|
|
3828
|
+
* - [false, false]: No extension, transparent beyond bounds
|
|
3829
|
+
*/
|
|
3830
|
+
extend?: [boolean, boolean];
|
|
3733
3831
|
}
|
|
3734
|
-
//#endregion
|
|
3735
|
-
//#region src/svg/path-executor.d.ts
|
|
3736
3832
|
/**
|
|
3737
|
-
* Options for
|
|
3833
|
+
* Options for creating a radial shading.
|
|
3834
|
+
*
|
|
3835
|
+
* @example
|
|
3836
|
+
* ```typescript
|
|
3837
|
+
* // Classic radial gradient: point to circle
|
|
3838
|
+
* const radial = pdf.createRadialShading({
|
|
3839
|
+
* coords: [50, 50, 0, 50, 50, 50], // From center point to 50pt radius
|
|
3840
|
+
* stops: [
|
|
3841
|
+
* { offset: 0, color: rgb(1, 1, 1) }, // White at center
|
|
3842
|
+
* { offset: 1, color: rgb(0, 0, 0) }, // Black at edge
|
|
3843
|
+
* ],
|
|
3844
|
+
* });
|
|
3845
|
+
* ```
|
|
3738
3846
|
*/
|
|
3739
|
-
interface
|
|
3847
|
+
interface RadialShadingOptions {
|
|
3740
3848
|
/**
|
|
3741
|
-
*
|
|
3849
|
+
* Two circles defining the gradient: [x0, y0, r0, x1, y1, r1].
|
|
3742
3850
|
*
|
|
3743
|
-
*
|
|
3744
|
-
*
|
|
3851
|
+
* - First circle: center (x0, y0), radius r0
|
|
3852
|
+
* - Second circle: center (x1, y1), radius r1
|
|
3745
3853
|
*
|
|
3746
|
-
*
|
|
3747
|
-
*
|
|
3854
|
+
* Common patterns:
|
|
3855
|
+
* - Point-to-circle: r0 = 0 for a classic radial gradient from center
|
|
3856
|
+
* - Circle-to-circle: Both radii > 0 for cone/spotlight effects
|
|
3857
|
+
*/
|
|
3858
|
+
coords: RadialCoords;
|
|
3859
|
+
/** Color stops defining the gradient colors and positions */
|
|
3860
|
+
stops: ColorStop[];
|
|
3861
|
+
/**
|
|
3862
|
+
* Whether to extend the gradient beyond its bounds.
|
|
3748
3863
|
*
|
|
3749
|
-
*
|
|
3864
|
+
* - [true, true] (default): Extend both ends
|
|
3865
|
+
* - [false, false]: No extension
|
|
3750
3866
|
*/
|
|
3751
|
-
|
|
3867
|
+
extend?: [boolean, boolean];
|
|
3868
|
+
}
|
|
3869
|
+
/**
|
|
3870
|
+
* Options for creating a linear gradient using CSS-style angle and length.
|
|
3871
|
+
*
|
|
3872
|
+
* This is a convenience wrapper around axial shading that uses familiar
|
|
3873
|
+
* CSS gradient conventions.
|
|
3874
|
+
*
|
|
3875
|
+
* @example
|
|
3876
|
+
* ```typescript
|
|
3877
|
+
* // Horizontal gradient (left to right)
|
|
3878
|
+
* const gradient = pdf.createLinearGradient({
|
|
3879
|
+
* angle: 90, // CSS: 0 = up, 90 = right, 180 = down, 270 = left
|
|
3880
|
+
* length: 100, // Gradient spans 100pt
|
|
3881
|
+
* stops: [
|
|
3882
|
+
* { offset: 0, color: rgb(1, 0, 0) },
|
|
3883
|
+
* { offset: 1, color: rgb(0, 0, 1) },
|
|
3884
|
+
* ],
|
|
3885
|
+
* });
|
|
3886
|
+
* ```
|
|
3887
|
+
*/
|
|
3888
|
+
interface LinearGradientOptions {
|
|
3752
3889
|
/**
|
|
3753
|
-
*
|
|
3754
|
-
*
|
|
3890
|
+
* Angle in degrees using CSS convention:
|
|
3891
|
+
* - 0: Bottom to top
|
|
3892
|
+
* - 90: Left to right
|
|
3893
|
+
* - 180: Top to bottom
|
|
3894
|
+
* - 270: Right to left
|
|
3755
3895
|
*/
|
|
3756
|
-
|
|
3896
|
+
angle: number;
|
|
3897
|
+
/** Length of the gradient in points */
|
|
3898
|
+
length: number;
|
|
3899
|
+
/** Color stops defining the gradient colors and positions */
|
|
3900
|
+
stops: ColorStop[];
|
|
3901
|
+
}
|
|
3902
|
+
/**
|
|
3903
|
+
* A shading (gradient) resource.
|
|
3904
|
+
*
|
|
3905
|
+
* Shadings define smooth color transitions (gradients) that can fill
|
|
3906
|
+
* arbitrary shapes. Two types are supported:
|
|
3907
|
+
* - **axial**: Linear gradient along a line segment
|
|
3908
|
+
* - **radial**: Circular gradient between two circles
|
|
3909
|
+
*
|
|
3910
|
+
* @example
|
|
3911
|
+
* ```typescript
|
|
3912
|
+
* const gradient = pdf.createAxialShading({
|
|
3913
|
+
* coords: [0, 0, 100, 0],
|
|
3914
|
+
* stops: [
|
|
3915
|
+
* { offset: 0, color: rgb(1, 0, 0) },
|
|
3916
|
+
* { offset: 1, color: rgb(0, 0, 1) },
|
|
3917
|
+
* ],
|
|
3918
|
+
* });
|
|
3919
|
+
*
|
|
3920
|
+
* const name = page.registerShading(gradient);
|
|
3921
|
+
* page.drawOperators([
|
|
3922
|
+
* ops.pushGraphicsState(),
|
|
3923
|
+
* ops.rectangle(50, 50, 100, 100),
|
|
3924
|
+
* ops.clip(),
|
|
3925
|
+
* ops.endPath(),
|
|
3926
|
+
* ops.paintShading(name),
|
|
3927
|
+
* ops.popGraphicsState(),
|
|
3928
|
+
* ]);
|
|
3929
|
+
* ```
|
|
3930
|
+
*/
|
|
3931
|
+
declare class PDFShading {
|
|
3932
|
+
readonly type = "shading";
|
|
3933
|
+
readonly ref: PdfRef;
|
|
3934
|
+
readonly shadingType: "axial" | "radial";
|
|
3935
|
+
constructor(ref: PdfRef, shadingType: "axial" | "radial");
|
|
3757
3936
|
/**
|
|
3758
|
-
*
|
|
3759
|
-
* @default 0
|
|
3937
|
+
* Create the PDF dictionary for an axial shading.
|
|
3760
3938
|
*/
|
|
3761
|
-
|
|
3939
|
+
static createAxialDict(options: AxialShadingOptions): PdfDict;
|
|
3762
3940
|
/**
|
|
3763
|
-
*
|
|
3764
|
-
* @default 0
|
|
3941
|
+
* Create the PDF dictionary for a radial shading.
|
|
3765
3942
|
*/
|
|
3766
|
-
|
|
3943
|
+
static createRadialDict(options: RadialShadingOptions): PdfDict;
|
|
3944
|
+
/**
|
|
3945
|
+
* Calculate axial gradient coordinates from angle and length.
|
|
3946
|
+
*
|
|
3947
|
+
* CSS angle convention: 0 = up, 90 = right, 180 = down, 270 = left
|
|
3948
|
+
*/
|
|
3949
|
+
static calculateAxialCoords(angle: number, length: number): AxialCoords;
|
|
3767
3950
|
}
|
|
3768
3951
|
//#endregion
|
|
3769
|
-
//#region src/
|
|
3770
|
-
/**
|
|
3771
|
-
* Standard 14 font names.
|
|
3772
|
-
*/
|
|
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];
|
|
3952
|
+
//#region src/drawing/resources/pattern.d.ts
|
|
3775
3953
|
/**
|
|
3776
|
-
*
|
|
3954
|
+
* Options for creating a tiling pattern.
|
|
3955
|
+
*
|
|
3956
|
+
* Tiling patterns repeat a small graphic cell to fill an area. The cell is
|
|
3957
|
+
* defined by operators that draw into the bbox, and the pattern tiles with
|
|
3958
|
+
* the specified step sizes.
|
|
3777
3959
|
*
|
|
3778
3960
|
* @example
|
|
3779
3961
|
* ```typescript
|
|
3780
|
-
*
|
|
3781
|
-
*
|
|
3962
|
+
* // Checkerboard pattern
|
|
3963
|
+
* const pattern = pdf.createTilingPattern({
|
|
3964
|
+
* bbox: { x: 0, y: 0, width: 10, height: 10 },
|
|
3965
|
+
* xStep: 10,
|
|
3966
|
+
* yStep: 10,
|
|
3967
|
+
* operators: [
|
|
3968
|
+
* ops.setNonStrokingGray(0.8),
|
|
3969
|
+
* ops.rectangle(0, 0, 5, 5),
|
|
3970
|
+
* ops.fill(),
|
|
3971
|
+
* ],
|
|
3972
|
+
* });
|
|
3782
3973
|
* ```
|
|
3783
3974
|
*/
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3975
|
+
interface TilingPatternOptions {
|
|
3976
|
+
/**
|
|
3977
|
+
* Bounding box of the pattern cell.
|
|
3978
|
+
*
|
|
3979
|
+
* Defines the coordinate space for the pattern's operators.
|
|
3980
|
+
* Usually starts at { x: 0, y: 0, width, height }.
|
|
3981
|
+
*/
|
|
3982
|
+
bbox: BBox;
|
|
3983
|
+
/**
|
|
3984
|
+
* Horizontal distance between pattern cell origins.
|
|
3985
|
+
*
|
|
3986
|
+
* Set equal to bbox width for seamless tiling, or larger for gaps.
|
|
3987
|
+
*/
|
|
3988
|
+
xStep: number;
|
|
3989
|
+
/**
|
|
3990
|
+
* Vertical distance between pattern cell origins.
|
|
3991
|
+
*
|
|
3992
|
+
* Set equal to bbox height for seamless tiling, or larger for gaps.
|
|
3993
|
+
*/
|
|
3994
|
+
yStep: number;
|
|
3995
|
+
/** Operators that draw the pattern cell content */
|
|
3996
|
+
operators: Operator[];
|
|
3997
|
+
}
|
|
3998
|
+
/**
|
|
3999
|
+
* Options for creating an image pattern.
|
|
4000
|
+
*
|
|
4001
|
+
* Image patterns tile an embedded image to fill an area, similar to
|
|
4002
|
+
* CSS `background-image` with `background-repeat: repeat`.
|
|
4003
|
+
*
|
|
4004
|
+
* @example
|
|
4005
|
+
* ```typescript
|
|
4006
|
+
* const image = pdf.embedImage(textureBytes);
|
|
4007
|
+
* const pattern = pdf.createImagePattern({
|
|
4008
|
+
* image,
|
|
4009
|
+
* width: 50, // Tile size in points
|
|
4010
|
+
* height: 50,
|
|
4011
|
+
* });
|
|
4012
|
+
*
|
|
4013
|
+
* const patternName = page.registerPattern(pattern);
|
|
4014
|
+
* page.drawOperators([
|
|
4015
|
+
* ops.setNonStrokingColorSpace(ColorSpace.Pattern),
|
|
4016
|
+
* ops.setNonStrokingColorN(patternName),
|
|
4017
|
+
* ops.rectangle(100, 100, 300, 200),
|
|
4018
|
+
* ops.fill(),
|
|
4019
|
+
* ]);
|
|
4020
|
+
* ```
|
|
4021
|
+
*/
|
|
4022
|
+
interface ImagePatternOptions {
|
|
4023
|
+
/**
|
|
4024
|
+
* The embedded image to use as the pattern tile.
|
|
4025
|
+
*
|
|
4026
|
+
* Created via `pdf.embedImage()`, `pdf.embedJpeg()`, or `pdf.embedPng()`.
|
|
4027
|
+
*/
|
|
4028
|
+
image: {
|
|
4029
|
+
ref: PdfRef;
|
|
4030
|
+
width: number;
|
|
4031
|
+
height: number;
|
|
4032
|
+
};
|
|
4033
|
+
/**
|
|
4034
|
+
* Width of each tile in points.
|
|
4035
|
+
*
|
|
4036
|
+
* If not specified, uses the image's natural width in points.
|
|
4037
|
+
*/
|
|
4038
|
+
width?: number;
|
|
4039
|
+
/**
|
|
4040
|
+
* Height of each tile in points.
|
|
4041
|
+
*
|
|
4042
|
+
* If not specified, uses the image's natural height in points.
|
|
4043
|
+
*/
|
|
4044
|
+
height?: number;
|
|
4045
|
+
}
|
|
4046
|
+
/**
|
|
4047
|
+
* Options for creating a shading pattern.
|
|
4048
|
+
*
|
|
4049
|
+
* Shading patterns wrap a gradient (shading) so it can be used as a fill or
|
|
4050
|
+
* stroke color, just like tiling patterns.
|
|
4051
|
+
*
|
|
4052
|
+
* @example
|
|
4053
|
+
* ```typescript
|
|
4054
|
+
* // Create a gradient
|
|
4055
|
+
* const gradient = pdf.createAxialShading({
|
|
4056
|
+
* coords: [0, 0, 100, 0],
|
|
4057
|
+
* stops: [
|
|
4058
|
+
* { offset: 0, color: rgb(1, 0, 0) },
|
|
4059
|
+
* { offset: 1, color: rgb(0, 0, 1) },
|
|
4060
|
+
* ],
|
|
4061
|
+
* });
|
|
4062
|
+
*
|
|
4063
|
+
* // Wrap in a pattern (optionally with transform)
|
|
4064
|
+
* const pattern = pdf.createShadingPattern({
|
|
4065
|
+
* shading: gradient,
|
|
4066
|
+
* matrix: [1, 0, 0, 1, 50, 100], // Translate by (50, 100)
|
|
4067
|
+
* });
|
|
4068
|
+
* ```
|
|
4069
|
+
*/
|
|
4070
|
+
interface ShadingPatternOptions {
|
|
4071
|
+
/**
|
|
4072
|
+
* The shading (gradient) to use.
|
|
4073
|
+
*
|
|
4074
|
+
* Created via pdf.createAxialShading() or pdf.createRadialShading().
|
|
4075
|
+
*/
|
|
4076
|
+
shading: PDFShading;
|
|
4077
|
+
/**
|
|
4078
|
+
* Optional transformation matrix for the pattern.
|
|
4079
|
+
*
|
|
4080
|
+
* Transforms the shading's coordinate space. Useful for positioning
|
|
4081
|
+
* a gradient relative to shapes that will use it.
|
|
4082
|
+
*
|
|
4083
|
+
* Default: identity matrix (no transformation)
|
|
4084
|
+
*/
|
|
4085
|
+
matrix?: PatternMatrix;
|
|
4086
|
+
}
|
|
4087
|
+
/**
|
|
4088
|
+
* A tiling pattern resource (PatternType 1).
|
|
4089
|
+
*
|
|
4090
|
+
* Tiling patterns repeat a small graphic cell to fill an area.
|
|
4091
|
+
* Useful for textures, backgrounds, and decorative fills.
|
|
4092
|
+
*
|
|
4093
|
+
* @example
|
|
4094
|
+
* ```typescript
|
|
4095
|
+
* const dots = pdf.createTilingPattern({
|
|
4096
|
+
* bbox: { x: 0, y: 0, width: 10, height: 10 },
|
|
4097
|
+
* xStep: 10,
|
|
4098
|
+
* yStep: 10,
|
|
4099
|
+
* operators: [
|
|
4100
|
+
* ops.setNonStrokingGray(0.5),
|
|
4101
|
+
* ops.moveTo(7, 5),
|
|
4102
|
+
* ops.curveTo(7, 6.1, 6.1, 7, 5, 7),
|
|
4103
|
+
* ops.curveTo(3.9, 7, 3, 6.1, 3, 5),
|
|
4104
|
+
* ops.curveTo(3, 3.9, 3.9, 3, 5, 3),
|
|
4105
|
+
* ops.curveTo(6.1, 3, 7, 3.9, 7, 5),
|
|
4106
|
+
* ops.fill(),
|
|
4107
|
+
* ],
|
|
4108
|
+
* });
|
|
4109
|
+
*
|
|
4110
|
+
* const name = page.registerPattern(dots);
|
|
4111
|
+
* ```
|
|
4112
|
+
*/
|
|
4113
|
+
declare class PDFTilingPattern {
|
|
4114
|
+
readonly type = "pattern";
|
|
4115
|
+
readonly ref: PdfRef;
|
|
4116
|
+
readonly patternType = "tiling";
|
|
4117
|
+
constructor(ref: PdfRef);
|
|
4118
|
+
/**
|
|
4119
|
+
* Create the PDF stream for a tiling pattern.
|
|
4120
|
+
*/
|
|
4121
|
+
static createStream(options: TilingPatternOptions, contentBytes: Uint8Array): PdfStream;
|
|
4122
|
+
/**
|
|
4123
|
+
* Create the PDF stream for an image pattern.
|
|
4124
|
+
*/
|
|
4125
|
+
static createImageStream(options: ImagePatternOptions): PdfStream;
|
|
4126
|
+
}
|
|
4127
|
+
/**
|
|
4128
|
+
* A shading pattern resource (PatternType 2).
|
|
4129
|
+
*
|
|
4130
|
+
* Shading patterns wrap a gradient (shading) so it can be used as a fill or
|
|
4131
|
+
* stroke color. Unlike direct shading fills via `paintShading()`, shading
|
|
4132
|
+
* patterns work with any path shape without explicit clipping.
|
|
4133
|
+
*
|
|
4134
|
+
* @example
|
|
4135
|
+
* ```typescript
|
|
4136
|
+
* const gradient = pdf.createAxialShading({
|
|
4137
|
+
* coords: [0, 0, 100, 0],
|
|
4138
|
+
* stops: [
|
|
4139
|
+
* { offset: 0, color: rgb(1, 0, 0) },
|
|
4140
|
+
* { offset: 1, color: rgb(0, 0, 1) },
|
|
4141
|
+
* ],
|
|
4142
|
+
* });
|
|
4143
|
+
*
|
|
4144
|
+
* const gradientPattern = pdf.createShadingPattern({ shading: gradient });
|
|
4145
|
+
* const name = page.registerPattern(gradientPattern);
|
|
4146
|
+
* ```
|
|
4147
|
+
*/
|
|
4148
|
+
declare class PDFShadingPattern {
|
|
4149
|
+
readonly type = "pattern";
|
|
4150
|
+
readonly ref: PdfRef;
|
|
4151
|
+
readonly patternType = "shading";
|
|
4152
|
+
readonly shading: PDFShading;
|
|
4153
|
+
constructor(ref: PdfRef, shading: PDFShading);
|
|
4154
|
+
/**
|
|
4155
|
+
* Create the PDF dictionary for a shading pattern.
|
|
4156
|
+
*/
|
|
4157
|
+
static createDict(options: ShadingPatternOptions): PdfDict;
|
|
4158
|
+
}
|
|
4159
|
+
/**
|
|
4160
|
+
* Any pattern resource (tiling or shading).
|
|
4161
|
+
*/
|
|
4162
|
+
type PDFPattern = PDFTilingPattern | PDFShadingPattern;
|
|
4163
|
+
//#endregion
|
|
4164
|
+
//#region src/drawing/resources/extgstate.d.ts
|
|
4165
|
+
/**
|
|
4166
|
+
* Options for creating extended graphics state.
|
|
4167
|
+
*/
|
|
4168
|
+
interface ExtGStateOptions {
|
|
4169
|
+
/** Fill (non-stroking) opacity (0-1) */
|
|
4170
|
+
fillOpacity?: number;
|
|
4171
|
+
/** Stroke opacity (0-1) */
|
|
4172
|
+
strokeOpacity?: number;
|
|
4173
|
+
/** Blend mode for compositing */
|
|
4174
|
+
blendMode?: BlendMode;
|
|
4175
|
+
}
|
|
4176
|
+
/**
|
|
4177
|
+
* An extended graphics state resource.
|
|
4178
|
+
*
|
|
4179
|
+
* Extended graphics state (ExtGState) provides advanced rendering options
|
|
4180
|
+
* not available in the basic graphics state:
|
|
4181
|
+
* - **Opacity**: Separate fill and stroke transparency
|
|
4182
|
+
* - **Blend modes**: Photoshop-style compositing (Multiply, Screen, etc.)
|
|
4183
|
+
*
|
|
4184
|
+
* @example
|
|
4185
|
+
* ```typescript
|
|
4186
|
+
* const semiTransparent = pdf.createExtGState({
|
|
4187
|
+
* fillOpacity: 0.5,
|
|
4188
|
+
* blendMode: "Multiply",
|
|
4189
|
+
* });
|
|
4190
|
+
*
|
|
4191
|
+
* const name = page.registerExtGState(semiTransparent);
|
|
4192
|
+
* page.drawOperators([
|
|
4193
|
+
* ops.pushGraphicsState(),
|
|
4194
|
+
* ops.setGraphicsState(name),
|
|
4195
|
+
* ops.setNonStrokingRGB(1, 0, 0),
|
|
4196
|
+
* ops.rectangle(100, 100, 50, 50),
|
|
4197
|
+
* ops.fill(),
|
|
4198
|
+
* ops.popGraphicsState(),
|
|
4199
|
+
* ]);
|
|
4200
|
+
* ```
|
|
4201
|
+
*/
|
|
4202
|
+
declare class PDFExtGState {
|
|
4203
|
+
readonly type = "extgstate";
|
|
4204
|
+
readonly ref: PdfRef;
|
|
4205
|
+
constructor(ref: PdfRef);
|
|
4206
|
+
/**
|
|
4207
|
+
* Create the PDF dictionary for an extended graphics state.
|
|
4208
|
+
*
|
|
4209
|
+
* Opacity values are clamped to the range [0, 1].
|
|
4210
|
+
*/
|
|
4211
|
+
static createDict(options: ExtGStateOptions): PdfDict;
|
|
4212
|
+
}
|
|
4213
|
+
//#endregion
|
|
4214
|
+
//#region src/drawing/resources/form-xobject.d.ts
|
|
4215
|
+
/**
|
|
4216
|
+
* Options for creating a Form XObject (reusable content).
|
|
4217
|
+
*
|
|
4218
|
+
* Form XObjects are like "stamps" - define once, use many times.
|
|
4219
|
+
* They're perfect for watermarks, headers, footers, and repeated graphics.
|
|
4220
|
+
*
|
|
4221
|
+
* @example
|
|
4222
|
+
* ```typescript
|
|
4223
|
+
* // Create a "DRAFT" watermark stamp
|
|
4224
|
+
* const draftStamp = pdf.createFormXObject({
|
|
4225
|
+
* bbox: { x: 0, y: 0, width: 200, height: 50 },
|
|
4226
|
+
* operators: [
|
|
4227
|
+
* ops.setNonStrokingRGB(0.9, 0.1, 0.1),
|
|
4228
|
+
* ops.beginText(),
|
|
4229
|
+
* ops.setFont(fontName, 36),
|
|
4230
|
+
* ops.moveText(10, 10),
|
|
4231
|
+
* ops.showText("DRAFT"),
|
|
4232
|
+
* ops.endText(),
|
|
4233
|
+
* ],
|
|
4234
|
+
* });
|
|
4235
|
+
*
|
|
4236
|
+
* // Use on every page
|
|
4237
|
+
* for (const page of pdf.getPages()) {
|
|
4238
|
+
* const name = page.registerXObject(draftStamp);
|
|
4239
|
+
* page.drawOperators([
|
|
4240
|
+
* ops.pushGraphicsState(),
|
|
4241
|
+
* ops.concatMatrix(1, 0, 0, 1, 200, 700),
|
|
4242
|
+
* ops.paintXObject(name),
|
|
4243
|
+
* ops.popGraphicsState(),
|
|
4244
|
+
* ]);
|
|
4245
|
+
* }
|
|
4246
|
+
* ```
|
|
4247
|
+
*/
|
|
4248
|
+
interface FormXObjectOptions {
|
|
4249
|
+
/**
|
|
4250
|
+
* Bounding box of the Form XObject.
|
|
4251
|
+
*
|
|
4252
|
+
* Defines the coordinate space for the form's operators.
|
|
4253
|
+
* Usually starts at { x: 0, y: 0, width, height }.
|
|
4254
|
+
*/
|
|
4255
|
+
bbox: BBox;
|
|
4256
|
+
/** Operators that draw the form content */
|
|
4257
|
+
operators: Operator[];
|
|
4258
|
+
}
|
|
4259
|
+
/**
|
|
4260
|
+
* A Form XObject (reusable content) resource.
|
|
4261
|
+
*
|
|
4262
|
+
* Form XObjects are like "stamps" - define once, use many times.
|
|
4263
|
+
* They're ideal for:
|
|
4264
|
+
* - Watermarks applied to every page
|
|
4265
|
+
* - Headers and footers
|
|
4266
|
+
* - Logos and repeated graphics
|
|
4267
|
+
* - Any content that appears multiple times
|
|
4268
|
+
*
|
|
4269
|
+
* @example
|
|
4270
|
+
* ```typescript
|
|
4271
|
+
* const logo = pdf.createFormXObject({
|
|
4272
|
+
* bbox: { x: 0, y: 0, width: 100, height: 50 },
|
|
4273
|
+
* operators: [
|
|
4274
|
+
* ops.setNonStrokingRGB(0.2, 0.4, 0.8),
|
|
4275
|
+
* ops.rectangle(0, 0, 100, 50),
|
|
4276
|
+
* ops.fill(),
|
|
4277
|
+
* ],
|
|
4278
|
+
* });
|
|
4279
|
+
*
|
|
4280
|
+
* // Use on multiple pages
|
|
4281
|
+
* for (const page of pdf.getPages()) {
|
|
4282
|
+
* const name = page.registerXObject(logo);
|
|
4283
|
+
* page.drawOperators([
|
|
4284
|
+
* ops.pushGraphicsState(),
|
|
4285
|
+
* ops.concatMatrix(1, 0, 0, 1, 50, 700),
|
|
4286
|
+
* ops.paintXObject(name),
|
|
4287
|
+
* ops.popGraphicsState(),
|
|
4288
|
+
* ]);
|
|
4289
|
+
* }
|
|
4290
|
+
* ```
|
|
4291
|
+
*/
|
|
4292
|
+
declare class PDFFormXObject {
|
|
4293
|
+
readonly type = "formxobject";
|
|
4294
|
+
readonly ref: PdfRef;
|
|
4295
|
+
readonly bbox: BBox;
|
|
4296
|
+
constructor(ref: PdfRef, bbox: BBox);
|
|
4297
|
+
/**
|
|
4298
|
+
* Create the PDF stream for a Form XObject.
|
|
4299
|
+
*/
|
|
4300
|
+
static createStream(options: FormXObjectOptions, contentBytes: Uint8Array): PdfStream;
|
|
4301
|
+
}
|
|
4302
|
+
//#endregion
|
|
4303
|
+
//#region src/fonts/standard-14.d.ts
|
|
4304
|
+
/**
|
|
4305
|
+
* Standard 14 font names.
|
|
4306
|
+
*/
|
|
4307
|
+
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"];
|
|
4308
|
+
type Standard14FontName = (typeof STANDARD_14_FONTS)[number];
|
|
4309
|
+
/**
|
|
4310
|
+
* Standard 14 fonts enum for convenient access.
|
|
4311
|
+
*
|
|
4312
|
+
* @example
|
|
4313
|
+
* ```typescript
|
|
4314
|
+
* page.drawText("Hello", { font: StandardFonts.Helvetica });
|
|
4315
|
+
* page.drawText("Bold", { font: StandardFonts.HelveticaBold });
|
|
4316
|
+
* ```
|
|
4317
|
+
*/
|
|
4318
|
+
declare const StandardFonts: {
|
|
4319
|
+
readonly Helvetica: "Helvetica";
|
|
4320
|
+
readonly HelveticaBold: "Helvetica-Bold";
|
|
4321
|
+
readonly HelveticaOblique: "Helvetica-Oblique";
|
|
4322
|
+
readonly HelveticaBoldOblique: "Helvetica-BoldOblique";
|
|
4323
|
+
readonly TimesRoman: "Times-Roman";
|
|
4324
|
+
readonly TimesBold: "Times-Bold";
|
|
4325
|
+
readonly TimesItalic: "Times-Italic";
|
|
4326
|
+
readonly TimesBoldItalic: "Times-BoldItalic";
|
|
3793
4327
|
readonly Courier: "Courier";
|
|
3794
4328
|
readonly CourierBold: "Courier-Bold";
|
|
3795
4329
|
readonly CourierOblique: "Courier-Oblique";
|
|
@@ -3798,7 +4332,7 @@ declare const StandardFonts: {
|
|
|
3798
4332
|
readonly ZapfDingbats: "ZapfDingbats";
|
|
3799
4333
|
};
|
|
3800
4334
|
//#endregion
|
|
3801
|
-
//#region src/
|
|
4335
|
+
//#region src/drawing/types.d.ts
|
|
3802
4336
|
/**
|
|
3803
4337
|
* Text alignment for multiline text.
|
|
3804
4338
|
*/
|
|
@@ -3900,11 +4434,23 @@ interface DrawRectangleOptions {
|
|
|
3900
4434
|
width: number;
|
|
3901
4435
|
/** Height in points */
|
|
3902
4436
|
height: number;
|
|
3903
|
-
/** Fill color (omit for no fill) */
|
|
4437
|
+
/** Fill color (omit for no fill, mutually exclusive with pattern) */
|
|
3904
4438
|
color?: Color;
|
|
3905
|
-
/**
|
|
4439
|
+
/**
|
|
4440
|
+
* Fill pattern (tiling or shading pattern).
|
|
4441
|
+
* Use instead of color to fill with a gradient or repeating pattern.
|
|
4442
|
+
* Mutually exclusive with color.
|
|
4443
|
+
*/
|
|
4444
|
+
pattern?: PDFPattern;
|
|
4445
|
+
/** Border/stroke color (omit for no stroke, mutually exclusive with borderPattern) */
|
|
3906
4446
|
borderColor?: Color;
|
|
3907
|
-
/**
|
|
4447
|
+
/**
|
|
4448
|
+
* Stroke pattern (tiling or shading pattern).
|
|
4449
|
+
* Use instead of borderColor to stroke with a gradient or repeating pattern.
|
|
4450
|
+
* Mutually exclusive with borderColor.
|
|
4451
|
+
*/
|
|
4452
|
+
borderPattern?: PDFPattern;
|
|
4453
|
+
/** Border width in points (default: 1 if borderColor/borderPattern set) */
|
|
3908
4454
|
borderWidth?: number;
|
|
3909
4455
|
/** Dash pattern array (e.g., [5, 3] for 5pt dash, 3pt gap) */
|
|
3910
4456
|
borderDashArray?: number[];
|
|
@@ -3956,11 +4502,23 @@ interface DrawCircleOptions {
|
|
|
3956
4502
|
y: number;
|
|
3957
4503
|
/** Circle radius in points */
|
|
3958
4504
|
radius: number;
|
|
3959
|
-
/** Fill color (omit for no fill) */
|
|
4505
|
+
/** Fill color (omit for no fill, mutually exclusive with pattern) */
|
|
3960
4506
|
color?: Color;
|
|
3961
|
-
/**
|
|
4507
|
+
/**
|
|
4508
|
+
* Fill pattern (tiling or shading pattern).
|
|
4509
|
+
* Use instead of color to fill with a gradient or repeating pattern.
|
|
4510
|
+
* Mutually exclusive with color.
|
|
4511
|
+
*/
|
|
4512
|
+
pattern?: PDFPattern;
|
|
4513
|
+
/** Border/stroke color (omit for no stroke, mutually exclusive with borderPattern) */
|
|
3962
4514
|
borderColor?: Color;
|
|
3963
|
-
/**
|
|
4515
|
+
/**
|
|
4516
|
+
* Stroke pattern (tiling or shading pattern).
|
|
4517
|
+
* Use instead of borderColor to stroke with a gradient or repeating pattern.
|
|
4518
|
+
* Mutually exclusive with borderColor.
|
|
4519
|
+
*/
|
|
4520
|
+
borderPattern?: PDFPattern;
|
|
4521
|
+
/** Border width in points (default: 1 if borderColor/borderPattern set) */
|
|
3964
4522
|
borderWidth?: number;
|
|
3965
4523
|
/** Fill opacity 0-1 (default: 1) */
|
|
3966
4524
|
opacity?: number;
|
|
@@ -3979,11 +4537,23 @@ interface DrawEllipseOptions {
|
|
|
3979
4537
|
xRadius: number;
|
|
3980
4538
|
/** Vertical radius in points */
|
|
3981
4539
|
yRadius: number;
|
|
3982
|
-
/** Fill color (omit for no fill) */
|
|
4540
|
+
/** Fill color (omit for no fill, mutually exclusive with pattern) */
|
|
3983
4541
|
color?: Color;
|
|
3984
|
-
/**
|
|
4542
|
+
/**
|
|
4543
|
+
* Fill pattern (tiling or shading pattern).
|
|
4544
|
+
* Use instead of color to fill with a gradient or repeating pattern.
|
|
4545
|
+
* Mutually exclusive with color.
|
|
4546
|
+
*/
|
|
4547
|
+
pattern?: PDFPattern;
|
|
4548
|
+
/** Border/stroke color (omit for no stroke, mutually exclusive with borderPattern) */
|
|
3985
4549
|
borderColor?: Color;
|
|
3986
|
-
/**
|
|
4550
|
+
/**
|
|
4551
|
+
* Stroke pattern (tiling or shading pattern).
|
|
4552
|
+
* Use instead of borderColor to stroke with a gradient or repeating pattern.
|
|
4553
|
+
* Mutually exclusive with borderColor.
|
|
4554
|
+
*/
|
|
4555
|
+
borderPattern?: PDFPattern;
|
|
4556
|
+
/** Border width in points (default: 1 if borderColor/borderPattern set) */
|
|
3987
4557
|
borderWidth?: number;
|
|
3988
4558
|
/** Fill opacity 0-1 (default: 1) */
|
|
3989
4559
|
opacity?: number;
|
|
@@ -4028,11 +4598,23 @@ interface DrawSvgPathOptions {
|
|
|
4028
4598
|
* @default true
|
|
4029
4599
|
*/
|
|
4030
4600
|
flipY?: boolean;
|
|
4031
|
-
/** Fill color (default: black; omit to stroke only if borderColor set) */
|
|
4601
|
+
/** Fill color (default: black; omit to stroke only if borderColor set, mutually exclusive with pattern) */
|
|
4032
4602
|
color?: Color;
|
|
4033
|
-
/**
|
|
4603
|
+
/**
|
|
4604
|
+
* Fill pattern (tiling or shading pattern).
|
|
4605
|
+
* Use instead of color to fill with a gradient or repeating pattern.
|
|
4606
|
+
* Mutually exclusive with color.
|
|
4607
|
+
*/
|
|
4608
|
+
pattern?: PDFPattern;
|
|
4609
|
+
/** Stroke color (omit for no stroke, mutually exclusive with borderPattern) */
|
|
4034
4610
|
borderColor?: Color;
|
|
4035
|
-
/**
|
|
4611
|
+
/**
|
|
4612
|
+
* Stroke pattern (tiling or shading pattern).
|
|
4613
|
+
* Use instead of borderColor to stroke with a gradient or repeating pattern.
|
|
4614
|
+
* Mutually exclusive with borderColor.
|
|
4615
|
+
*/
|
|
4616
|
+
borderPattern?: PDFPattern;
|
|
4617
|
+
/** Stroke width in points (default: 1 if borderColor/borderPattern set) */
|
|
4036
4618
|
borderWidth?: number;
|
|
4037
4619
|
/** Line cap style */
|
|
4038
4620
|
lineCap?: LineCap;
|
|
@@ -4053,13 +4635,44 @@ interface DrawSvgPathOptions {
|
|
|
4053
4635
|
}
|
|
4054
4636
|
/**
|
|
4055
4637
|
* Options for path painting.
|
|
4638
|
+
*
|
|
4639
|
+
* @example
|
|
4640
|
+
* ```typescript
|
|
4641
|
+
* // Solid color fill
|
|
4642
|
+
* page.drawPath().rectangle(0, 0, 100, 100).fill({ color: rgb(1, 0, 0) });
|
|
4643
|
+
*
|
|
4644
|
+
* // Pattern fill (tiling or shading pattern)
|
|
4645
|
+
* const gradient = pdf.createAxialShading({...});
|
|
4646
|
+
* const pattern = pdf.createShadingPattern({ shading: gradient });
|
|
4647
|
+
* page.drawPath().circle(50, 50, 30).fill({ pattern });
|
|
4648
|
+
*
|
|
4649
|
+
* // Stroke with pattern
|
|
4650
|
+
* page.drawPath().rectangle(0, 0, 100, 100).stroke({
|
|
4651
|
+
* borderPattern: pattern,
|
|
4652
|
+
* borderWidth: 5,
|
|
4653
|
+
* });
|
|
4654
|
+
* ```
|
|
4056
4655
|
*/
|
|
4057
4656
|
interface PathOptions {
|
|
4058
|
-
/** Fill color (omit for no fill) */
|
|
4657
|
+
/** Fill color (omit for no fill, mutually exclusive with pattern) */
|
|
4059
4658
|
color?: Color;
|
|
4060
|
-
/**
|
|
4659
|
+
/**
|
|
4660
|
+
* Fill pattern (tiling or shading pattern).
|
|
4661
|
+
*
|
|
4662
|
+
* Use instead of color to fill with a gradient or repeating pattern.
|
|
4663
|
+
* Mutually exclusive with color.
|
|
4664
|
+
*/
|
|
4665
|
+
pattern?: PDFPattern;
|
|
4666
|
+
/** Stroke color (omit for no stroke, mutually exclusive with borderPattern) */
|
|
4061
4667
|
borderColor?: Color;
|
|
4062
|
-
/**
|
|
4668
|
+
/**
|
|
4669
|
+
* Stroke pattern (tiling or shading pattern).
|
|
4670
|
+
*
|
|
4671
|
+
* Use instead of borderColor to stroke with a gradient or repeating pattern.
|
|
4672
|
+
* Mutually exclusive with borderColor.
|
|
4673
|
+
*/
|
|
4674
|
+
borderPattern?: PDFPattern;
|
|
4675
|
+
/** Stroke width in points (default: 1 if borderColor/borderPattern set) */
|
|
4063
4676
|
borderWidth?: number;
|
|
4064
4677
|
/** Line cap style */
|
|
4065
4678
|
lineCap?: LineCap;
|
|
@@ -4087,7 +4700,7 @@ declare function lineCapToNumber(cap: LineCap): 0 | 1 | 2;
|
|
|
4087
4700
|
*/
|
|
4088
4701
|
declare function lineJoinToNumber(join: LineJoin): 0 | 1 | 2;
|
|
4089
4702
|
//#endregion
|
|
4090
|
-
//#region src/
|
|
4703
|
+
//#region src/drawing/path-builder.d.ts
|
|
4091
4704
|
/**
|
|
4092
4705
|
* Callback type for appending content to a page.
|
|
4093
4706
|
* Accepts a string (for ASCII-only content) or raw bytes.
|
|
@@ -4095,33 +4708,66 @@ declare function lineJoinToNumber(join: LineJoin): 0 | 1 | 2;
|
|
|
4095
4708
|
type ContentAppender = (content: string | Uint8Array) => void;
|
|
4096
4709
|
/**
|
|
4097
4710
|
* Callback type for registering a graphics state and returning its name.
|
|
4711
|
+
* Returns null if no graphics state is needed (both opacities undefined).
|
|
4712
|
+
*/
|
|
4713
|
+
type GraphicsStateRegistrar = (options: {
|
|
4714
|
+
fillOpacity?: number;
|
|
4715
|
+
strokeOpacity?: number;
|
|
4716
|
+
}) => string | null;
|
|
4717
|
+
/**
|
|
4718
|
+
* Callback type for registering a shading and returning its name.
|
|
4719
|
+
*/
|
|
4720
|
+
type ShadingRegistrar = (shading: PDFShading) => string;
|
|
4721
|
+
/**
|
|
4722
|
+
* Callback type for registering a pattern and returning its name.
|
|
4098
4723
|
*/
|
|
4099
|
-
type
|
|
4724
|
+
type PatternRegistrar = (pattern: PDFPattern) => string;
|
|
4100
4725
|
/**
|
|
4101
4726
|
* PathBuilder provides a fluent interface for constructing PDF paths.
|
|
4102
4727
|
*
|
|
4103
4728
|
* @example
|
|
4104
4729
|
* ```typescript
|
|
4105
|
-
* // Triangle
|
|
4730
|
+
* // Triangle with solid color
|
|
4106
4731
|
* page.drawPath()
|
|
4107
4732
|
* .moveTo(300, 200)
|
|
4108
4733
|
* .lineTo(350, 300)
|
|
4109
4734
|
* .lineTo(250, 300)
|
|
4110
4735
|
* .close()
|
|
4111
4736
|
* .fill({ color: rgb(0, 0, 1) });
|
|
4737
|
+
*
|
|
4738
|
+
* // Rectangle with gradient fill
|
|
4739
|
+
* const gradient = pdf.createAxialShading({
|
|
4740
|
+
* coords: [0, 0, 100, 0],
|
|
4741
|
+
* stops: [
|
|
4742
|
+
* { offset: 0, color: rgb(1, 0, 0) },
|
|
4743
|
+
* { offset: 1, color: rgb(0, 0, 1) },
|
|
4744
|
+
* ],
|
|
4745
|
+
* });
|
|
4746
|
+
* const gradientPattern = pdf.createShadingPattern({ shading: gradient });
|
|
4747
|
+
* page.drawPath()
|
|
4748
|
+
* .rectangle(50, 50, 100, 100)
|
|
4749
|
+
* .fill({ pattern: gradientPattern });
|
|
4750
|
+
*
|
|
4751
|
+
* // Circle with tiling pattern fill
|
|
4752
|
+
* const pattern = pdf.createTilingPattern({...});
|
|
4753
|
+
* page.drawPath()
|
|
4754
|
+
* .circle(200, 200, 50)
|
|
4755
|
+
* .fill({ pattern });
|
|
4112
4756
|
* ```
|
|
4113
4757
|
*/
|
|
4114
4758
|
declare class PathBuilder {
|
|
4115
4759
|
private readonly pathOps;
|
|
4116
4760
|
private readonly appendContent;
|
|
4117
4761
|
private readonly registerGraphicsState;
|
|
4762
|
+
private readonly registerShading?;
|
|
4763
|
+
private readonly registerPattern?;
|
|
4118
4764
|
/** Current point for quadratic-to-cubic conversion */
|
|
4119
4765
|
private currentX;
|
|
4120
4766
|
private currentY;
|
|
4121
4767
|
/** Start point of current subpath (for close operations) */
|
|
4122
4768
|
private subpathStartX;
|
|
4123
4769
|
private subpathStartY;
|
|
4124
|
-
constructor(appendContent: ContentAppender, registerGraphicsState: GraphicsStateRegistrar);
|
|
4770
|
+
constructor(appendContent: ContentAppender, registerGraphicsState: GraphicsStateRegistrar, registerShading?: ShadingRegistrar, registerPattern?: PatternRegistrar);
|
|
4125
4771
|
/**
|
|
4126
4772
|
* Move to a point (start a new subpath).
|
|
4127
4773
|
*/
|
|
@@ -4232,38 +4878,199 @@ declare class PathBuilder {
|
|
|
4232
4878
|
* Paint the path with the given options.
|
|
4233
4879
|
*/
|
|
4234
4880
|
private paint;
|
|
4881
|
+
/**
|
|
4882
|
+
* Register a pattern and return its name, or undefined if no pattern.
|
|
4883
|
+
*/
|
|
4884
|
+
private ensurePatternRegistered;
|
|
4235
4885
|
/**
|
|
4236
4886
|
* Emit operators to the page content.
|
|
4237
4887
|
*/
|
|
4238
4888
|
private emitOps;
|
|
4239
4889
|
}
|
|
4240
4890
|
//#endregion
|
|
4241
|
-
//#region src/
|
|
4891
|
+
//#region src/images/pdf-image.d.ts
|
|
4242
4892
|
/**
|
|
4243
|
-
*
|
|
4893
|
+
* PDFImage represents an embedded image XObject.
|
|
4244
4894
|
*
|
|
4245
|
-
*
|
|
4246
|
-
*
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
*
|
|
4895
|
+
* @example
|
|
4896
|
+
* ```typescript
|
|
4897
|
+
* const image = await pdf.embedImage(jpegBytes);
|
|
4898
|
+
* console.log(`Image size: ${image.width}x${image.height}`);
|
|
4899
|
+
*
|
|
4900
|
+
* page.drawImage(image, {
|
|
4901
|
+
* x: 50,
|
|
4902
|
+
* y: 500,
|
|
4903
|
+
* width: 200,
|
|
4904
|
+
* });
|
|
4905
|
+
* ```
|
|
4250
4906
|
*/
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4907
|
+
declare class PDFImage {
|
|
4908
|
+
/** Image width in pixels */
|
|
4909
|
+
readonly width: number;
|
|
4910
|
+
/** Image height in pixels */
|
|
4911
|
+
readonly height: number;
|
|
4912
|
+
/** Reference to the image XObject in the document */
|
|
4913
|
+
readonly ref: PdfRef;
|
|
4914
|
+
/**
|
|
4915
|
+
* Scale factor to convert pixels to points.
|
|
4916
|
+
* Default is 1 (1 pixel = 1 point).
|
|
4917
|
+
* For print-quality (300 DPI), use 72/300 = 0.24.
|
|
4918
|
+
*/
|
|
4919
|
+
readonly scale: number;
|
|
4920
|
+
constructor(ref: PdfRef, width: number, height: number, scale?: number);
|
|
4921
|
+
/**
|
|
4922
|
+
* Width in points (pixels * scale).
|
|
4923
|
+
*/
|
|
4924
|
+
get widthInPoints(): number;
|
|
4925
|
+
/**
|
|
4926
|
+
* Height in points (pixels * scale).
|
|
4927
|
+
*/
|
|
4928
|
+
get heightInPoints(): number;
|
|
4929
|
+
/**
|
|
4930
|
+
* Aspect ratio (width / height).
|
|
4931
|
+
*/
|
|
4932
|
+
get aspectRatio(): number;
|
|
4254
4933
|
}
|
|
4934
|
+
//#endregion
|
|
4935
|
+
//#region src/text/types.d.ts
|
|
4255
4936
|
/**
|
|
4256
|
-
*
|
|
4937
|
+
* Types for text extraction from PDF documents.
|
|
4938
|
+
*
|
|
4939
|
+
* These types represent text content extracted from PDF pages,
|
|
4940
|
+
* including position information for searching and highlighting.
|
|
4257
4941
|
*/
|
|
4258
|
-
interface CertificateCredential {
|
|
4259
|
-
type: "certificate";
|
|
4260
|
-
certificate: Uint8Array;
|
|
4261
|
-
privateKey: Uint8Array;
|
|
4262
|
-
}
|
|
4263
4942
|
/**
|
|
4264
|
-
*
|
|
4265
|
-
|
|
4266
|
-
|
|
4943
|
+
* Rectangle in PDF coordinates (origin at bottom-left).
|
|
4944
|
+
*/
|
|
4945
|
+
interface BoundingBox {
|
|
4946
|
+
/** Left edge (x coordinate) */
|
|
4947
|
+
x: number;
|
|
4948
|
+
/** Bottom edge (y coordinate) */
|
|
4949
|
+
y: number;
|
|
4950
|
+
/** Width of the box */
|
|
4951
|
+
width: number;
|
|
4952
|
+
/** Height of the box */
|
|
4953
|
+
height: number;
|
|
4954
|
+
}
|
|
4955
|
+
/**
|
|
4956
|
+
* A single extracted character with its position and style information.
|
|
4957
|
+
*/
|
|
4958
|
+
interface ExtractedChar {
|
|
4959
|
+
/** The Unicode character(s) */
|
|
4960
|
+
char: string;
|
|
4961
|
+
/** Bounding box of the character */
|
|
4962
|
+
bbox: BoundingBox;
|
|
4963
|
+
/** Font size in points */
|
|
4964
|
+
fontSize: number;
|
|
4965
|
+
/** Font name (e.g., "Helvetica", "Arial-BoldMT") */
|
|
4966
|
+
fontName: string;
|
|
4967
|
+
/** Y coordinate of the text baseline */
|
|
4968
|
+
baseline: number;
|
|
4969
|
+
}
|
|
4970
|
+
/**
|
|
4971
|
+
* A span of text with the same font and size on the same line.
|
|
4972
|
+
*/
|
|
4973
|
+
interface TextSpan {
|
|
4974
|
+
/** The text content */
|
|
4975
|
+
text: string;
|
|
4976
|
+
/** Bounding box around the entire span */
|
|
4977
|
+
bbox: BoundingBox;
|
|
4978
|
+
/** Individual characters (for precise positioning) */
|
|
4979
|
+
chars: ExtractedChar[];
|
|
4980
|
+
/** Font size in points */
|
|
4981
|
+
fontSize: number;
|
|
4982
|
+
/** Font name */
|
|
4983
|
+
fontName: string;
|
|
4984
|
+
}
|
|
4985
|
+
/**
|
|
4986
|
+
* A line of text (multiple spans on the same baseline).
|
|
4987
|
+
*/
|
|
4988
|
+
interface TextLine$1 {
|
|
4989
|
+
/** Combined text from all spans */
|
|
4990
|
+
text: string;
|
|
4991
|
+
/** Bounding box around the entire line */
|
|
4992
|
+
bbox: BoundingBox;
|
|
4993
|
+
/** Individual spans within the line */
|
|
4994
|
+
spans: TextSpan[];
|
|
4995
|
+
/** Y coordinate of the baseline */
|
|
4996
|
+
baseline: number;
|
|
4997
|
+
}
|
|
4998
|
+
/**
|
|
4999
|
+
* Full page text extraction result.
|
|
5000
|
+
*/
|
|
5001
|
+
interface PageText {
|
|
5002
|
+
/** Page index (0-based) */
|
|
5003
|
+
pageIndex: number;
|
|
5004
|
+
/** Page width in points */
|
|
5005
|
+
width: number;
|
|
5006
|
+
/** Page height in points */
|
|
5007
|
+
height: number;
|
|
5008
|
+
/** All text lines on the page */
|
|
5009
|
+
lines: TextLine$1[];
|
|
5010
|
+
/** Plain text content (lines joined with newlines) */
|
|
5011
|
+
text: string;
|
|
5012
|
+
}
|
|
5013
|
+
/**
|
|
5014
|
+
* A search match result.
|
|
5015
|
+
*/
|
|
5016
|
+
interface TextMatch {
|
|
5017
|
+
/** The matched text */
|
|
5018
|
+
text: string;
|
|
5019
|
+
/** Bounding box around the entire match */
|
|
5020
|
+
bbox: BoundingBox;
|
|
5021
|
+
/** Page index where the match was found */
|
|
5022
|
+
pageIndex: number;
|
|
5023
|
+
/** Individual character bounding boxes (useful for multi-line matches or highlighting) */
|
|
5024
|
+
charBoxes: BoundingBox[];
|
|
5025
|
+
}
|
|
5026
|
+
/**
|
|
5027
|
+
* Options for text extraction.
|
|
5028
|
+
*/
|
|
5029
|
+
interface ExtractTextOptions {
|
|
5030
|
+
/**
|
|
5031
|
+
* Include individual character positions.
|
|
5032
|
+
* Default: true (needed for search support)
|
|
5033
|
+
*/
|
|
5034
|
+
includeChars?: boolean;
|
|
5035
|
+
}
|
|
5036
|
+
/**
|
|
5037
|
+
* Options for text search.
|
|
5038
|
+
*/
|
|
5039
|
+
interface FindTextOptions {
|
|
5040
|
+
/** Page indices to search (default: all pages) */
|
|
5041
|
+
pages?: number[];
|
|
5042
|
+
/** Case-sensitive matching (default: true) */
|
|
5043
|
+
caseSensitive?: boolean;
|
|
5044
|
+
/** Match whole words only (default: false) */
|
|
5045
|
+
wholeWord?: boolean;
|
|
5046
|
+
}
|
|
5047
|
+
//#endregion
|
|
5048
|
+
//#region src/security/credentials.d.ts
|
|
5049
|
+
/**
|
|
5050
|
+
* Credentials for decrypting PDF documents.
|
|
5051
|
+
*
|
|
5052
|
+
* Currently supports password-based authentication (Standard security handler).
|
|
5053
|
+
* Certificate-based authentication (Public Key handler) is planned for the future.
|
|
5054
|
+
*/
|
|
5055
|
+
/**
|
|
5056
|
+
* Password credential for Standard security handler.
|
|
5057
|
+
*/
|
|
5058
|
+
interface PasswordCredential {
|
|
5059
|
+
type: "password";
|
|
5060
|
+
password: string;
|
|
5061
|
+
}
|
|
5062
|
+
/**
|
|
5063
|
+
* Certificate credential for Public Key security handler (future).
|
|
5064
|
+
*/
|
|
5065
|
+
interface CertificateCredential {
|
|
5066
|
+
type: "certificate";
|
|
5067
|
+
certificate: Uint8Array;
|
|
5068
|
+
privateKey: Uint8Array;
|
|
5069
|
+
}
|
|
5070
|
+
/**
|
|
5071
|
+
* Credentials for decrypting a document.
|
|
5072
|
+
*
|
|
5073
|
+
* Can be provided as:
|
|
4267
5074
|
* - A plain string (shorthand for password credential)
|
|
4268
5075
|
* - A PasswordCredential object
|
|
4269
5076
|
* - A CertificateCredential object (future support)
|
|
@@ -5003,6 +5810,8 @@ declare class PDFPage {
|
|
|
5003
5810
|
readonly index: number;
|
|
5004
5811
|
/** Document context for registering objects */
|
|
5005
5812
|
private readonly ctx;
|
|
5813
|
+
/** Resource cache for deduplication - maps object refs to resource names */
|
|
5814
|
+
private _resourceCache;
|
|
5006
5815
|
constructor(ref: PdfRef, dict: PdfDict, index: number, ctx: PDFContext);
|
|
5007
5816
|
/**
|
|
5008
5817
|
* Get the MediaBox (page boundary).
|
|
@@ -5049,6 +5858,12 @@ declare class PDFPage {
|
|
|
5049
5858
|
* returns the width of the MediaBox instead.
|
|
5050
5859
|
*/
|
|
5051
5860
|
get height(): number;
|
|
5861
|
+
/**
|
|
5862
|
+
* Get the effective box for dimension calculations.
|
|
5863
|
+
*
|
|
5864
|
+
* Returns CropBox if it's smaller than MediaBox, otherwise MediaBox.
|
|
5865
|
+
*/
|
|
5866
|
+
private getEffectiveBox;
|
|
5052
5867
|
/**
|
|
5053
5868
|
* Whether the page is in landscape orientation.
|
|
5054
5869
|
*
|
|
@@ -5290,6 +6105,10 @@ declare class PDFPage {
|
|
|
5290
6105
|
* ```
|
|
5291
6106
|
*/
|
|
5292
6107
|
drawImage(image: PDFImage, options?: DrawImageOptions): void;
|
|
6108
|
+
/**
|
|
6109
|
+
* Compute image dimensions based on options, preserving aspect ratio when appropriate.
|
|
6110
|
+
*/
|
|
6111
|
+
private computeImageDimensions;
|
|
5293
6112
|
/**
|
|
5294
6113
|
* Start building a custom path.
|
|
5295
6114
|
*
|
|
@@ -5298,7 +6117,7 @@ declare class PDFPage {
|
|
|
5298
6117
|
*
|
|
5299
6118
|
* @example
|
|
5300
6119
|
* ```typescript
|
|
5301
|
-
* // Triangle
|
|
6120
|
+
* // Triangle with solid color
|
|
5302
6121
|
* page.drawPath()
|
|
5303
6122
|
* .moveTo(100, 100)
|
|
5304
6123
|
* .lineTo(200, 100)
|
|
@@ -5306,7 +6125,7 @@ declare class PDFPage {
|
|
|
5306
6125
|
* .close()
|
|
5307
6126
|
* .fill({ color: rgb(1, 0, 0) });
|
|
5308
6127
|
*
|
|
5309
|
-
* // Complex shape
|
|
6128
|
+
* // Complex shape with fill and stroke
|
|
5310
6129
|
* page.drawPath()
|
|
5311
6130
|
* .moveTo(50, 50)
|
|
5312
6131
|
* .curveTo(100, 100, 150, 100, 200, 50)
|
|
@@ -5316,6 +6135,22 @@ declare class PDFPage {
|
|
|
5316
6135
|
* color: rgb(0.9, 0.9, 1),
|
|
5317
6136
|
* borderColor: rgb(0, 0, 1),
|
|
5318
6137
|
* });
|
|
6138
|
+
*
|
|
6139
|
+
* // Circle with gradient fill (using shading pattern)
|
|
6140
|
+
* const gradient = pdf.createAxialShading({
|
|
6141
|
+
* coords: [0, 0, 100, 0],
|
|
6142
|
+
* stops: [{ offset: 0, color: rgb(1, 0, 0) }, { offset: 1, color: rgb(0, 0, 1) }],
|
|
6143
|
+
* });
|
|
6144
|
+
* const gradientPattern = pdf.createShadingPattern({ shading: gradient });
|
|
6145
|
+
* page.drawPath()
|
|
6146
|
+
* .circle(200, 200, 50)
|
|
6147
|
+
* .fill({ pattern: gradientPattern });
|
|
6148
|
+
*
|
|
6149
|
+
* // Rectangle with tiling pattern fill
|
|
6150
|
+
* const pattern = pdf.createTilingPattern({...});
|
|
6151
|
+
* page.drawPath()
|
|
6152
|
+
* .rectangle(50, 300, 100, 100)
|
|
6153
|
+
* .fill({ pattern });
|
|
5319
6154
|
* ```
|
|
5320
6155
|
*/
|
|
5321
6156
|
drawPath(): PathBuilder;
|
|
@@ -5362,6 +6197,206 @@ declare class PDFPage {
|
|
|
5362
6197
|
* ```
|
|
5363
6198
|
*/
|
|
5364
6199
|
drawSvgPath(pathData: string, options?: DrawSvgPathOptions): void;
|
|
6200
|
+
/**
|
|
6201
|
+
* Emit raw PDF operators to the page content stream.
|
|
6202
|
+
*
|
|
6203
|
+
* This is the low-level drawing API that gives you direct control over
|
|
6204
|
+
* PDF content stream operators. Use this when you need advanced features
|
|
6205
|
+
* like matrix transforms, graphics state stack, gradients, or patterns
|
|
6206
|
+
* that aren't available through the high-level drawing methods.
|
|
6207
|
+
*
|
|
6208
|
+
* **Important**: The caller is responsible for valid operator sequences.
|
|
6209
|
+
* Invalid sequences may produce corrupted PDFs that won't render correctly.
|
|
6210
|
+
*
|
|
6211
|
+
* @param operators - Array of operators to emit
|
|
6212
|
+
*
|
|
6213
|
+
* @example
|
|
6214
|
+
* ```typescript
|
|
6215
|
+
* import { PDF, ops } from "@libpdf/core";
|
|
6216
|
+
*
|
|
6217
|
+
* const pdf = await PDF.create();
|
|
6218
|
+
* const page = pdf.addPage();
|
|
6219
|
+
*
|
|
6220
|
+
* page.drawOperators([
|
|
6221
|
+
* ops.pushGraphicsState(),
|
|
6222
|
+
* ops.concatMatrix(1, 0, 0, 1, 100, 200), // translate
|
|
6223
|
+
* ops.setNonStrokingRGB(1, 0, 0),
|
|
6224
|
+
* ops.rectangle(0, 0, 50, 50),
|
|
6225
|
+
* ops.fill(),
|
|
6226
|
+
* ops.popGraphicsState(),
|
|
6227
|
+
* ]);
|
|
6228
|
+
* ```
|
|
6229
|
+
*/
|
|
6230
|
+
drawOperators(operators: Operator[]): void;
|
|
6231
|
+
/**
|
|
6232
|
+
* Register a font resource and return its operator name.
|
|
6233
|
+
*
|
|
6234
|
+
* The same font registered multiple times returns the same name (deduplication).
|
|
6235
|
+
*
|
|
6236
|
+
* @param font - Font to register (EmbeddedFont or Standard 14 font name)
|
|
6237
|
+
* @returns The resource name for use with operators (e.g., "F0")
|
|
6238
|
+
*
|
|
6239
|
+
* @example
|
|
6240
|
+
* ```typescript
|
|
6241
|
+
* const font = await pdf.embedFont(fontBytes);
|
|
6242
|
+
* const fontName = page.registerFont(font);
|
|
6243
|
+
*
|
|
6244
|
+
* page.drawOperators([
|
|
6245
|
+
* ops.beginText(),
|
|
6246
|
+
* ops.setFont(fontName, 12),
|
|
6247
|
+
* ops.showText("Hello"),
|
|
6248
|
+
* ops.endText(),
|
|
6249
|
+
* ]);
|
|
6250
|
+
* ```
|
|
6251
|
+
*/
|
|
6252
|
+
registerFont(font: FontInput): string;
|
|
6253
|
+
/**
|
|
6254
|
+
* Register an image resource and return its operator name.
|
|
6255
|
+
*
|
|
6256
|
+
* The same image registered multiple times returns the same name (deduplication).
|
|
6257
|
+
*
|
|
6258
|
+
* @param image - The PDFImage to register
|
|
6259
|
+
* @returns The resource name for use with paintXObject operator (e.g., "Im0")
|
|
6260
|
+
*
|
|
6261
|
+
* @example
|
|
6262
|
+
* ```typescript
|
|
6263
|
+
* const image = await pdf.embedImage(imageBytes);
|
|
6264
|
+
* const imageName = page.registerImage(image);
|
|
6265
|
+
*
|
|
6266
|
+
* page.drawOperators([
|
|
6267
|
+
* ops.pushGraphicsState(),
|
|
6268
|
+
* ops.concatMatrix(100, 0, 0, 100, 200, 500),
|
|
6269
|
+
* ops.paintXObject(imageName),
|
|
6270
|
+
* ops.popGraphicsState(),
|
|
6271
|
+
* ]);
|
|
6272
|
+
* ```
|
|
6273
|
+
*/
|
|
6274
|
+
registerImage(image: PDFImage): string;
|
|
6275
|
+
/**
|
|
6276
|
+
* Register a shading (gradient) resource and return its operator name.
|
|
6277
|
+
*
|
|
6278
|
+
* The same shading registered multiple times returns the same name (deduplication).
|
|
6279
|
+
*
|
|
6280
|
+
* @param shading - The PDFShading to register
|
|
6281
|
+
* @returns The resource name for use with paintShading operator (e.g., "Sh0")
|
|
6282
|
+
*
|
|
6283
|
+
* @example
|
|
6284
|
+
* ```typescript
|
|
6285
|
+
* const gradient = pdf.createAxialShading({
|
|
6286
|
+
* coords: [0, 0, 100, 0],
|
|
6287
|
+
* stops: [{ offset: 0, color: rgb(1, 0, 0) }, { offset: 1, color: rgb(0, 0, 1) }],
|
|
6288
|
+
* });
|
|
6289
|
+
* const shadingName = page.registerShading(gradient);
|
|
6290
|
+
*
|
|
6291
|
+
* page.drawOperators([
|
|
6292
|
+
* ops.pushGraphicsState(),
|
|
6293
|
+
* ops.rectangle(50, 50, 100, 100),
|
|
6294
|
+
* ops.clip(),
|
|
6295
|
+
* ops.endPath(),
|
|
6296
|
+
* ops.paintShading(shadingName),
|
|
6297
|
+
* ops.popGraphicsState(),
|
|
6298
|
+
* ]);
|
|
6299
|
+
* ```
|
|
6300
|
+
*/
|
|
6301
|
+
registerShading(shading: PDFShading): string;
|
|
6302
|
+
/**
|
|
6303
|
+
* Register a pattern resource and return its operator name.
|
|
6304
|
+
*
|
|
6305
|
+
* The same pattern registered multiple times returns the same name (deduplication).
|
|
6306
|
+
*
|
|
6307
|
+
* @param pattern - The PDFPattern to register
|
|
6308
|
+
* @returns The resource name for use with setNonStrokingColorN operator (e.g., "P0")
|
|
6309
|
+
*
|
|
6310
|
+
* @example
|
|
6311
|
+
* ```typescript
|
|
6312
|
+
* // Create a checkerboard pattern
|
|
6313
|
+
* const pattern = pdf.createTilingPattern({
|
|
6314
|
+
* bbox: { x: 0, y: 0, width: 10, height: 10 },
|
|
6315
|
+
* xStep: 10,
|
|
6316
|
+
* yStep: 10,
|
|
6317
|
+
* operators: [
|
|
6318
|
+
* ops.setNonStrokingGray(0.8),
|
|
6319
|
+
* ops.rectangle(0, 0, 5, 5),
|
|
6320
|
+
* ops.fill(),
|
|
6321
|
+
* ],
|
|
6322
|
+
* });
|
|
6323
|
+
* const patternName = page.registerPattern(pattern);
|
|
6324
|
+
*
|
|
6325
|
+
* // Fill a rectangle with the pattern
|
|
6326
|
+
* page.drawOperators([
|
|
6327
|
+
* ops.setNonStrokingColorSpace(ColorSpace.Pattern),
|
|
6328
|
+
* ops.setNonStrokingColorN(patternName),
|
|
6329
|
+
* ops.rectangle(100, 100, 200, 200),
|
|
6330
|
+
* ops.fill(),
|
|
6331
|
+
* ]);
|
|
6332
|
+
* ```
|
|
6333
|
+
*/
|
|
6334
|
+
registerPattern(pattern: PDFPattern): string;
|
|
6335
|
+
/**
|
|
6336
|
+
* Register an extended graphics state resource and return its operator name.
|
|
6337
|
+
*
|
|
6338
|
+
* The same ExtGState registered multiple times returns the same name (deduplication).
|
|
6339
|
+
*
|
|
6340
|
+
* @param state - The PDFExtGState to register
|
|
6341
|
+
* @returns The resource name for use with setGraphicsState operator (e.g., "GS0")
|
|
6342
|
+
*
|
|
6343
|
+
* @example
|
|
6344
|
+
* ```typescript
|
|
6345
|
+
* const gs = pdf.createExtGState({
|
|
6346
|
+
* fillOpacity: 0.5,
|
|
6347
|
+
* strokeOpacity: 0.8,
|
|
6348
|
+
* blendMode: "Multiply",
|
|
6349
|
+
* });
|
|
6350
|
+
* const gsName = page.registerExtGState(gs);
|
|
6351
|
+
*
|
|
6352
|
+
* page.drawOperators([
|
|
6353
|
+
* ops.pushGraphicsState(),
|
|
6354
|
+
* ops.setGraphicsState(gsName),
|
|
6355
|
+
* ops.setNonStrokingRGB(1, 0, 0),
|
|
6356
|
+
* ops.rectangle(100, 100, 50, 50),
|
|
6357
|
+
* ops.fill(),
|
|
6358
|
+
* ops.popGraphicsState(),
|
|
6359
|
+
* ]);
|
|
6360
|
+
* ```
|
|
6361
|
+
*/
|
|
6362
|
+
registerExtGState(state: PDFExtGState): string;
|
|
6363
|
+
/**
|
|
6364
|
+
* Register a Form XObject resource and return its operator name.
|
|
6365
|
+
*
|
|
6366
|
+
* The same XObject registered multiple times returns the same name (deduplication).
|
|
6367
|
+
*
|
|
6368
|
+
* @param xobject - The PDFFormXObject or PDFEmbeddedPage to register
|
|
6369
|
+
* @returns The resource name for use with paintXObject operator (e.g., "Fm0")
|
|
6370
|
+
*
|
|
6371
|
+
* @example
|
|
6372
|
+
* ```typescript
|
|
6373
|
+
* // Create a reusable stamp
|
|
6374
|
+
* const stamp = pdf.createFormXObject({
|
|
6375
|
+
* bbox: { x: 0, y: 0, width: 100, height: 50 },
|
|
6376
|
+
* operators: [
|
|
6377
|
+
* ops.setNonStrokingRGB(1, 0, 0),
|
|
6378
|
+
* ops.rectangle(0, 0, 100, 50),
|
|
6379
|
+
* ops.fill(),
|
|
6380
|
+
* ops.beginText(),
|
|
6381
|
+
* ops.setFont(fontName, 12),
|
|
6382
|
+
* ops.setNonStrokingGray(1),
|
|
6383
|
+
* ops.moveText(10, 18),
|
|
6384
|
+
* ops.showText("STAMP"),
|
|
6385
|
+
* ops.endText(),
|
|
6386
|
+
* ],
|
|
6387
|
+
* });
|
|
6388
|
+
* const xobjectName = page.registerXObject(stamp);
|
|
6389
|
+
*
|
|
6390
|
+
* // Use the stamp at different positions
|
|
6391
|
+
* page.drawOperators([
|
|
6392
|
+
* ops.pushGraphicsState(),
|
|
6393
|
+
* ops.concatMatrix(1, 0, 0, 1, 200, 700),
|
|
6394
|
+
* ops.paintXObject(xobjectName),
|
|
6395
|
+
* ops.popGraphicsState(),
|
|
6396
|
+
* ]);
|
|
6397
|
+
* ```
|
|
6398
|
+
*/
|
|
6399
|
+
registerXObject(xobject: PDFFormXObject | PDFEmbeddedPage): string;
|
|
5365
6400
|
/** Cached annotations for this page */
|
|
5366
6401
|
private _annotationCache;
|
|
5367
6402
|
/**
|
|
@@ -5635,19 +6670,21 @@ declare class PDFPage {
|
|
|
5635
6670
|
* Returns the name assigned to the XObject.
|
|
5636
6671
|
*/
|
|
5637
6672
|
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
6673
|
/**
|
|
5644
6674
|
* Generate a unique name not already in the dictionary.
|
|
5645
6675
|
*/
|
|
5646
6676
|
private generateUniqueName;
|
|
5647
6677
|
/**
|
|
5648
|
-
*
|
|
6678
|
+
* Register a resource reference in a resource subdictionary.
|
|
6679
|
+
*
|
|
6680
|
+
* Handles deduplication via cache and existing entry scanning.
|
|
6681
|
+
*
|
|
6682
|
+
* @param ref - The object reference to register
|
|
6683
|
+
* @param resourceType - The resource subdictionary key (e.g., "Font", "XObject")
|
|
6684
|
+
* @param prefix - The name prefix (e.g., "F", "Im", "Sh")
|
|
6685
|
+
* @returns The resource name for use in operators
|
|
5649
6686
|
*/
|
|
5650
|
-
private
|
|
6687
|
+
private registerResource;
|
|
5651
6688
|
/**
|
|
5652
6689
|
* Create and register a content stream.
|
|
5653
6690
|
*
|
|
@@ -5674,17 +6711,20 @@ declare class PDFPage {
|
|
|
5674
6711
|
*/
|
|
5675
6712
|
private getBox;
|
|
5676
6713
|
/**
|
|
5677
|
-
*
|
|
5678
|
-
*
|
|
6714
|
+
* Create and register a graphics state, returning its resource name.
|
|
6715
|
+
*
|
|
6716
|
+
* This is an internal helper for high-level drawing methods.
|
|
6717
|
+
* For the public low-level API, use `pdf.createExtGState()` + `page.registerExtGState()`.
|
|
5679
6718
|
*/
|
|
5680
|
-
private
|
|
6719
|
+
private registerGraphicsState;
|
|
5681
6720
|
/**
|
|
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).
|
|
6721
|
+
* Append operators to the page content stream (foreground).
|
|
5686
6722
|
*/
|
|
5687
6723
|
private appendOperators;
|
|
6724
|
+
/**
|
|
6725
|
+
* Prepend operators to the page content stream (background).
|
|
6726
|
+
*/
|
|
6727
|
+
private prependOperators;
|
|
5688
6728
|
/**
|
|
5689
6729
|
* Add a font resource to the page and return its name.
|
|
5690
6730
|
*/
|
|
@@ -8499,51 +9539,265 @@ declare class PDF {
|
|
|
8499
9539
|
*/
|
|
8500
9540
|
embedPng(bytes: Uint8Array): PDFImage;
|
|
8501
9541
|
/**
|
|
8502
|
-
*
|
|
9542
|
+
* Create an axial (linear) shading with explicit coordinates.
|
|
9543
|
+
*
|
|
9544
|
+
* @param options - Shading options including coords and color stops
|
|
9545
|
+
* @returns PDFShading resource for use with page.registerShading()
|
|
8503
9546
|
*
|
|
8504
9547
|
* @example
|
|
8505
9548
|
* ```typescript
|
|
8506
|
-
*
|
|
8507
|
-
*
|
|
8508
|
-
*
|
|
8509
|
-
*
|
|
8510
|
-
*
|
|
8511
|
-
*
|
|
9549
|
+
* const gradient = pdf.createAxialShading({
|
|
9550
|
+
* coords: [0, 0, 100, 0], // x0, y0, x1, y1
|
|
9551
|
+
* stops: [
|
|
9552
|
+
* { offset: 0, color: rgb(1, 0, 0) },
|
|
9553
|
+
* { offset: 0.5, color: rgb(0, 1, 0) },
|
|
9554
|
+
* { offset: 1, color: rgb(0, 0, 1) },
|
|
9555
|
+
* ],
|
|
8512
9556
|
* });
|
|
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");
|
|
9557
|
+
* const shadingName = page.registerShading(gradient);
|
|
8519
9558
|
* ```
|
|
8520
9559
|
*/
|
|
8521
|
-
|
|
9560
|
+
createAxialShading(options: AxialShadingOptions): PDFShading;
|
|
8522
9561
|
/**
|
|
8523
|
-
*
|
|
9562
|
+
* Create a radial shading with explicit coordinates.
|
|
8524
9563
|
*
|
|
8525
|
-
*
|
|
9564
|
+
* @param options - Shading options including coords and color stops
|
|
9565
|
+
* @returns PDFShading resource for use with page.registerShading()
|
|
8526
9566
|
*
|
|
8527
|
-
* @
|
|
9567
|
+
* @example
|
|
9568
|
+
* ```typescript
|
|
9569
|
+
* const radial = pdf.createRadialShading({
|
|
9570
|
+
* coords: [50, 50, 0, 50, 50, 50], // x0, y0, r0, x1, y1, r1
|
|
9571
|
+
* stops: [
|
|
9572
|
+
* { offset: 0, color: rgb(1, 1, 1) },
|
|
9573
|
+
* { offset: 1, color: rgb(0, 0, 0) },
|
|
9574
|
+
* ],
|
|
9575
|
+
* });
|
|
9576
|
+
* const shadingName = page.registerShading(radial);
|
|
9577
|
+
* ```
|
|
8528
9578
|
*/
|
|
8529
|
-
|
|
9579
|
+
createRadialShading(options: RadialShadingOptions): PDFShading;
|
|
8530
9580
|
/**
|
|
8531
|
-
*
|
|
9581
|
+
* Create a linear gradient using angle and length (CSS-style).
|
|
8532
9582
|
*
|
|
8533
|
-
*
|
|
9583
|
+
* @param options - Gradient options including angle, length, and color stops
|
|
9584
|
+
* @returns PDFShading resource for use with page.registerShading()
|
|
8534
9585
|
*
|
|
8535
|
-
* @
|
|
8536
|
-
*
|
|
9586
|
+
* @example
|
|
9587
|
+
* ```typescript
|
|
9588
|
+
* const gradient = pdf.createLinearGradient({
|
|
9589
|
+
* angle: 90, // CSS convention: 0 = up, 90 = right, 180 = down, 270 = left
|
|
9590
|
+
* length: 100,
|
|
9591
|
+
* stops: [
|
|
9592
|
+
* { offset: 0, color: rgb(1, 0, 0) },
|
|
9593
|
+
* { offset: 1, color: rgb(0, 0, 1) },
|
|
9594
|
+
* ],
|
|
9595
|
+
* });
|
|
9596
|
+
* const shadingName = page.registerShading(gradient);
|
|
9597
|
+
* ```
|
|
8537
9598
|
*/
|
|
8538
|
-
|
|
9599
|
+
createLinearGradient(options: LinearGradientOptions): PDFShading;
|
|
8539
9600
|
/**
|
|
8540
|
-
*
|
|
9601
|
+
* Create a tiling pattern.
|
|
8541
9602
|
*
|
|
8542
|
-
*
|
|
9603
|
+
* @param options - Pattern options including bbox, step sizes, and operators
|
|
9604
|
+
* @returns PDFPattern resource for use with page.registerPattern()
|
|
8543
9605
|
*
|
|
8544
|
-
* @
|
|
8545
|
-
*
|
|
8546
|
-
|
|
9606
|
+
* @example
|
|
9607
|
+
* ```typescript
|
|
9608
|
+
* const pattern = pdf.createTilingPattern({
|
|
9609
|
+
* bbox: { x: 0, y: 0, width: 10, height: 10 },
|
|
9610
|
+
* xStep: 10,
|
|
9611
|
+
* yStep: 10,
|
|
9612
|
+
* operators: [
|
|
9613
|
+
* ops.setNonStrokingRGB(0.8, 0.8, 0.8),
|
|
9614
|
+
* ops.rectangle(0, 0, 5, 5),
|
|
9615
|
+
* ops.fill(),
|
|
9616
|
+
* ],
|
|
9617
|
+
* });
|
|
9618
|
+
* const patternName = page.registerPattern(pattern);
|
|
9619
|
+
* ```
|
|
9620
|
+
*/
|
|
9621
|
+
createTilingPattern(options: TilingPatternOptions): PDFTilingPattern;
|
|
9622
|
+
/**
|
|
9623
|
+
* Create an image pattern for filling shapes with a tiled image.
|
|
9624
|
+
*
|
|
9625
|
+
* This is a convenience method that creates a tiling pattern containing
|
|
9626
|
+
* an embedded image. Similar to CSS `background-image` with `background-repeat`.
|
|
9627
|
+
*
|
|
9628
|
+
* @param options - Image pattern options including the image and tile dimensions
|
|
9629
|
+
* @returns PDFTilingPattern resource for use with page.registerPattern()
|
|
9630
|
+
*
|
|
9631
|
+
* @example
|
|
9632
|
+
* ```typescript
|
|
9633
|
+
* // Create a repeating texture pattern
|
|
9634
|
+
* const texture = pdf.embedImage(textureBytes);
|
|
9635
|
+
* const pattern = pdf.createImagePattern({
|
|
9636
|
+
* image: texture,
|
|
9637
|
+
* width: 50, // Each tile is 50x50 points
|
|
9638
|
+
* height: 50,
|
|
9639
|
+
* });
|
|
9640
|
+
*
|
|
9641
|
+
* const patternName = page.registerPattern(pattern);
|
|
9642
|
+
* page.drawOperators([
|
|
9643
|
+
* ops.setNonStrokingColorSpace(ColorSpace.Pattern),
|
|
9644
|
+
* ops.setNonStrokingColorN(patternName),
|
|
9645
|
+
* ops.rectangle(100, 100, 300, 200),
|
|
9646
|
+
* ops.fill(),
|
|
9647
|
+
* ]);
|
|
9648
|
+
*
|
|
9649
|
+
* // Or use with PathBuilder
|
|
9650
|
+
* page.drawPath()
|
|
9651
|
+
* .rectangle(100, 100, 300, 200)
|
|
9652
|
+
* .fill({ pattern });
|
|
9653
|
+
* ```
|
|
9654
|
+
*
|
|
9655
|
+
* @example
|
|
9656
|
+
* ```typescript
|
|
9657
|
+
* // Horizontal stripes using repeat-x
|
|
9658
|
+
* const stripe = pdf.embedImage(stripeBytes);
|
|
9659
|
+
* const pattern = pdf.createImagePattern({
|
|
9660
|
+
* image: stripe,
|
|
9661
|
+
* width: 100,
|
|
9662
|
+
* height: 20,
|
|
9663
|
+
* repeat: "repeat-x",
|
|
9664
|
+
* });
|
|
9665
|
+
* ```
|
|
9666
|
+
*/
|
|
9667
|
+
createImagePattern(options: ImagePatternOptions): PDFTilingPattern;
|
|
9668
|
+
/**
|
|
9669
|
+
* Create a shading pattern from a shading (gradient).
|
|
9670
|
+
*
|
|
9671
|
+
* Shading patterns wrap a gradient so it can be used as a fill or stroke color,
|
|
9672
|
+
* just like tiling patterns. This is the recommended way to use gradients with
|
|
9673
|
+
* PathBuilder and high-level drawing methods.
|
|
9674
|
+
*
|
|
9675
|
+
* @param options - Shading pattern options (shading and optional matrix)
|
|
9676
|
+
* @returns PDFShadingPattern resource for use with page.registerPattern()
|
|
9677
|
+
*
|
|
9678
|
+
* @example
|
|
9679
|
+
* ```typescript
|
|
9680
|
+
* // Create a gradient
|
|
9681
|
+
* const gradient = pdf.createAxialShading({
|
|
9682
|
+
* coords: [0, 0, 100, 0],
|
|
9683
|
+
* stops: [
|
|
9684
|
+
* { offset: 0, color: rgb(1, 0, 0) },
|
|
9685
|
+
* { offset: 1, color: rgb(0, 0, 1) },
|
|
9686
|
+
* ],
|
|
9687
|
+
* });
|
|
9688
|
+
*
|
|
9689
|
+
* // Wrap in a pattern
|
|
9690
|
+
* const gradientPattern = pdf.createShadingPattern({ shading: gradient });
|
|
9691
|
+
*
|
|
9692
|
+
* // Use with PathBuilder
|
|
9693
|
+
* page.drawPath()
|
|
9694
|
+
* .circle(200, 200, 50)
|
|
9695
|
+
* .fill({ pattern: gradientPattern });
|
|
9696
|
+
*
|
|
9697
|
+
* // Or register and use directly
|
|
9698
|
+
* const patternName = page.registerPattern(gradientPattern);
|
|
9699
|
+
* page.drawOperators([
|
|
9700
|
+
* ops.setNonStrokingColorSpace(ColorSpace.Pattern),
|
|
9701
|
+
* ops.setNonStrokingColorN(patternName),
|
|
9702
|
+
* ops.rectangle(100, 100, 200, 200),
|
|
9703
|
+
* ops.fill(),
|
|
9704
|
+
* ]);
|
|
9705
|
+
* ```
|
|
9706
|
+
*/
|
|
9707
|
+
createShadingPattern(options: ShadingPatternOptions): PDFShadingPattern;
|
|
9708
|
+
/**
|
|
9709
|
+
* Create an extended graphics state (ExtGState) for advanced graphics options.
|
|
9710
|
+
*
|
|
9711
|
+
* @param options - ExtGState options including opacity and blend mode
|
|
9712
|
+
* @returns PDFExtGState resource for use with page.registerExtGState()
|
|
9713
|
+
*
|
|
9714
|
+
* @example
|
|
9715
|
+
* ```typescript
|
|
9716
|
+
* const gs = pdf.createExtGState({
|
|
9717
|
+
* fillOpacity: 0.5,
|
|
9718
|
+
* strokeOpacity: 0.8,
|
|
9719
|
+
* blendMode: "Multiply",
|
|
9720
|
+
* });
|
|
9721
|
+
* const gsName = page.registerExtGState(gs);
|
|
9722
|
+
* ```
|
|
9723
|
+
*/
|
|
9724
|
+
createExtGState(options: ExtGStateOptions): PDFExtGState;
|
|
9725
|
+
/**
|
|
9726
|
+
* Create a Form XObject (reusable content).
|
|
9727
|
+
*
|
|
9728
|
+
* @param options - Form XObject options including bbox and operators
|
|
9729
|
+
* @returns PDFFormXObject resource for use with page.registerXObject()
|
|
9730
|
+
*
|
|
9731
|
+
* @example
|
|
9732
|
+
* ```typescript
|
|
9733
|
+
* const stamp = pdf.createFormXObject({
|
|
9734
|
+
* bbox: { x: 0, y: 0, width: 100, height: 50 },
|
|
9735
|
+
* operators: [
|
|
9736
|
+
* ops.setNonStrokingRGB(1, 0, 0),
|
|
9737
|
+
* ops.rectangle(0, 0, 100, 50),
|
|
9738
|
+
* ops.fill(),
|
|
9739
|
+
* ],
|
|
9740
|
+
* });
|
|
9741
|
+
* const xobjectName = page.registerXObject(stamp);
|
|
9742
|
+
*
|
|
9743
|
+
* // Use on multiple pages
|
|
9744
|
+
* for (const page of pdf.getPages()) {
|
|
9745
|
+
* page.drawOperators([
|
|
9746
|
+
* ops.pushGraphicsState(),
|
|
9747
|
+
* ops.concatMatrix(1, 0, 0, 1, 200, 700),
|
|
9748
|
+
* ops.paintXObject(xobjectName),
|
|
9749
|
+
* ops.popGraphicsState(),
|
|
9750
|
+
* ]);
|
|
9751
|
+
* }
|
|
9752
|
+
* ```
|
|
9753
|
+
*/
|
|
9754
|
+
createFormXObject(options: FormXObjectOptions): PDFFormXObject;
|
|
9755
|
+
/**
|
|
9756
|
+
* Access the attachments API for managing file attachments.
|
|
9757
|
+
*
|
|
9758
|
+
* @example
|
|
9759
|
+
* ```typescript
|
|
9760
|
+
* // List attachments
|
|
9761
|
+
* const attachments = await pdf.attachments.list();
|
|
9762
|
+
*
|
|
9763
|
+
* // Add an attachment
|
|
9764
|
+
* await pdf.attachments.add("report.pdf", pdfBytes, {
|
|
9765
|
+
* description: "Annual report",
|
|
9766
|
+
* });
|
|
9767
|
+
*
|
|
9768
|
+
* // Get attachment data
|
|
9769
|
+
* const data = await pdf.attachments.get("report.pdf");
|
|
9770
|
+
*
|
|
9771
|
+
* // Remove an attachment
|
|
9772
|
+
* await pdf.attachments.remove("old-file.txt");
|
|
9773
|
+
* ```
|
|
9774
|
+
*/
|
|
9775
|
+
get attachments(): PDFAttachments;
|
|
9776
|
+
/**
|
|
9777
|
+
* List all attachments in the document.
|
|
9778
|
+
*
|
|
9779
|
+
* Convenience method that delegates to `pdf.attachments.list()`.
|
|
9780
|
+
*
|
|
9781
|
+
* @returns Map of attachment name to attachment info
|
|
9782
|
+
*/
|
|
9783
|
+
getAttachments(): Map<string, AttachmentInfo>;
|
|
9784
|
+
/**
|
|
9785
|
+
* Get the raw bytes of an attachment.
|
|
9786
|
+
*
|
|
9787
|
+
* Convenience method that delegates to `pdf.attachments.get()`.
|
|
9788
|
+
*
|
|
9789
|
+
* @param name The attachment name (key in the EmbeddedFiles tree)
|
|
9790
|
+
* @returns The attachment bytes, or null if not found
|
|
9791
|
+
*/
|
|
9792
|
+
getAttachment(name: string): Uint8Array | null;
|
|
9793
|
+
/**
|
|
9794
|
+
* Check if an attachment exists.
|
|
9795
|
+
*
|
|
9796
|
+
* Convenience method that delegates to `pdf.attachments.has()`.
|
|
9797
|
+
*
|
|
9798
|
+
* @param name The attachment name
|
|
9799
|
+
* @returns True if the attachment exists
|
|
9800
|
+
*/
|
|
8547
9801
|
hasAttachment(name: string): boolean;
|
|
8548
9802
|
/**
|
|
8549
9803
|
* Add a file attachment to the document.
|
|
@@ -9301,7 +10555,7 @@ declare class Standard14Font {
|
|
|
9301
10555
|
sizeAtWidth(text: string, width: number): number;
|
|
9302
10556
|
}
|
|
9303
10557
|
//#endregion
|
|
9304
|
-
//#region src/
|
|
10558
|
+
//#region src/drawing/text-layout.d.ts
|
|
9305
10559
|
/**
|
|
9306
10560
|
* A single line of laid out text.
|
|
9307
10561
|
*/
|
|
@@ -9367,6 +10621,757 @@ declare function layoutText(text: string, font: FontInput, fontSize: number, max
|
|
|
9367
10621
|
*/
|
|
9368
10622
|
declare function layoutJustifiedLine(words: string[], font: FontInput, fontSize: number, targetWidth: number): PositionedWord[];
|
|
9369
10623
|
//#endregion
|
|
10624
|
+
//#region src/helpers/matrix.d.ts
|
|
10625
|
+
/**
|
|
10626
|
+
* 2D transformation matrix for PDF coordinate transformations.
|
|
10627
|
+
*
|
|
10628
|
+
* PDF uses a 3x3 transformation matrix represented as [a b c d e f]
|
|
10629
|
+
* which corresponds to the matrix:
|
|
10630
|
+
*
|
|
10631
|
+
* | a b 0 |
|
|
10632
|
+
* | c d 0 |
|
|
10633
|
+
* | e f 1 |
|
|
10634
|
+
*
|
|
10635
|
+
* This is used for both the CTM (Current Transformation Matrix) and
|
|
10636
|
+
* text matrices (Tm/Tlm).
|
|
10637
|
+
*/
|
|
10638
|
+
/** biome-ignore-all lint/suspicious/useAdjacentOverloadSignatures: biome is whiffing */
|
|
10639
|
+
declare class Matrix {
|
|
10640
|
+
readonly a: number;
|
|
10641
|
+
readonly b: number;
|
|
10642
|
+
readonly c: number;
|
|
10643
|
+
readonly d: number;
|
|
10644
|
+
readonly e: number;
|
|
10645
|
+
readonly f: number;
|
|
10646
|
+
constructor(a: number, b: number, c: number, d: number, e: number, f: number);
|
|
10647
|
+
/**
|
|
10648
|
+
* Create an identity matrix.
|
|
10649
|
+
*/
|
|
10650
|
+
static identity(): Matrix;
|
|
10651
|
+
/**
|
|
10652
|
+
* Create a matrix from an array of 6 numbers.
|
|
10653
|
+
*/
|
|
10654
|
+
static fromArray(arr: number[]): Matrix;
|
|
10655
|
+
/**
|
|
10656
|
+
* Create a translation matrix.
|
|
10657
|
+
*/
|
|
10658
|
+
static translate(tx: number, ty: number): Matrix;
|
|
10659
|
+
/**
|
|
10660
|
+
* Create a scaling matrix.
|
|
10661
|
+
*/
|
|
10662
|
+
static scale(sx: number, sy: number): Matrix;
|
|
10663
|
+
/**
|
|
10664
|
+
* Create a rotation matrix (angle in radians).
|
|
10665
|
+
*/
|
|
10666
|
+
static rotate(angle: number): Matrix;
|
|
10667
|
+
/**
|
|
10668
|
+
* Multiply this matrix by another: this × other.
|
|
10669
|
+
*
|
|
10670
|
+
* Matrix multiplication is done as:
|
|
10671
|
+
* | a1 b1 0 | | a2 b2 0 |
|
|
10672
|
+
* | c1 d1 0 | × | c2 d2 0 |
|
|
10673
|
+
* | e1 f1 1 | | e2 f2 1 |
|
|
10674
|
+
*/
|
|
10675
|
+
multiply(other: Matrix): Matrix;
|
|
10676
|
+
/**
|
|
10677
|
+
* Apply a translation to this matrix.
|
|
10678
|
+
*/
|
|
10679
|
+
translate(tx: number, ty: number): Matrix;
|
|
10680
|
+
/**
|
|
10681
|
+
* Apply scaling to this matrix.
|
|
10682
|
+
*/
|
|
10683
|
+
scale(sx: number, sy: number): Matrix;
|
|
10684
|
+
/**
|
|
10685
|
+
* Apply rotation to this matrix (angle in radians).
|
|
10686
|
+
*/
|
|
10687
|
+
rotate(angle: number): Matrix;
|
|
10688
|
+
/**
|
|
10689
|
+
* Transform a point using this matrix.
|
|
10690
|
+
*
|
|
10691
|
+
* x' = a*x + c*y + e
|
|
10692
|
+
* y' = b*x + d*y + f
|
|
10693
|
+
*/
|
|
10694
|
+
transformPoint(x: number, y: number): {
|
|
10695
|
+
x: number;
|
|
10696
|
+
y: number;
|
|
10697
|
+
};
|
|
10698
|
+
/**
|
|
10699
|
+
* Transform a distance (vector) using this matrix.
|
|
10700
|
+
* Unlike transformPoint, this doesn't include the translation component.
|
|
10701
|
+
*
|
|
10702
|
+
* dx' = a*dx + c*dy
|
|
10703
|
+
* dy' = b*dx + d*dy
|
|
10704
|
+
*/
|
|
10705
|
+
transformDistance(dx: number, dy: number): {
|
|
10706
|
+
dx: number;
|
|
10707
|
+
dy: number;
|
|
10708
|
+
};
|
|
10709
|
+
/**
|
|
10710
|
+
* Get the horizontal scaling factor.
|
|
10711
|
+
* This is sqrt(a² + b²).
|
|
10712
|
+
*/
|
|
10713
|
+
getScaleX(): number;
|
|
10714
|
+
/**
|
|
10715
|
+
* Get the vertical scaling factor.
|
|
10716
|
+
* This is sqrt(c² + d²).
|
|
10717
|
+
*/
|
|
10718
|
+
getScaleY(): number;
|
|
10719
|
+
/**
|
|
10720
|
+
* Get the rotation angle in radians.
|
|
10721
|
+
*/
|
|
10722
|
+
getRotation(): number;
|
|
10723
|
+
/**
|
|
10724
|
+
* Clone this matrix.
|
|
10725
|
+
*/
|
|
10726
|
+
clone(): Matrix;
|
|
10727
|
+
/**
|
|
10728
|
+
* Check if this is approximately an identity matrix.
|
|
10729
|
+
*/
|
|
10730
|
+
isIdentity(tolerance?: number): boolean;
|
|
10731
|
+
/**
|
|
10732
|
+
* Convert to array format [a, b, c, d, e, f].
|
|
10733
|
+
*/
|
|
10734
|
+
toArray(): [number, number, number, number, number, number];
|
|
10735
|
+
toString(): string;
|
|
10736
|
+
}
|
|
10737
|
+
declare namespace operators_d_exports {
|
|
10738
|
+
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 };
|
|
10739
|
+
}
|
|
10740
|
+
/**
|
|
10741
|
+
* Save the current graphics state on the stack (q operator).
|
|
10742
|
+
*
|
|
10743
|
+
* The graphics state includes:
|
|
10744
|
+
* - Current transformation matrix (CTM)
|
|
10745
|
+
* - Clipping path
|
|
10746
|
+
* - Color and color space (stroke and fill)
|
|
10747
|
+
* - Line width, cap, join, dash pattern
|
|
10748
|
+
* - Text state parameters
|
|
10749
|
+
* - Extended graphics state (opacity, blend mode)
|
|
10750
|
+
*
|
|
10751
|
+
* **Best Practice:** Always pair with popGraphicsState(). Use push/pop to:
|
|
10752
|
+
* - Isolate transformations (rotation, scaling, translation)
|
|
10753
|
+
* - Limit clipping regions to specific content
|
|
10754
|
+
* - Apply temporary opacity or blend modes
|
|
10755
|
+
*
|
|
10756
|
+
* @example
|
|
10757
|
+
* ```typescript
|
|
10758
|
+
* page.drawOperators([
|
|
10759
|
+
* ops.pushGraphicsState(),
|
|
10760
|
+
* ops.concatMatrix(1, 0, 0, 1, 100, 200), // This transform...
|
|
10761
|
+
* ops.setNonStrokingRGB(1, 0, 0), // ...and this color...
|
|
10762
|
+
* ops.rectangle(0, 0, 50, 50),
|
|
10763
|
+
* ops.fill(),
|
|
10764
|
+
* ops.popGraphicsState(), // ...are now restored
|
|
10765
|
+
* // Back to original state
|
|
10766
|
+
* ]);
|
|
10767
|
+
* ```
|
|
10768
|
+
*/
|
|
10769
|
+
declare const pushGraphicsState: () => Operator;
|
|
10770
|
+
/**
|
|
10771
|
+
* Restore the graphics state from the stack (Q operator).
|
|
10772
|
+
*
|
|
10773
|
+
* Restores all graphics parameters to the values they had when
|
|
10774
|
+
* pushGraphicsState() was last called. This includes CTM, colors,
|
|
10775
|
+
* clipping path, and extended graphics state.
|
|
10776
|
+
*
|
|
10777
|
+
* @see pushGraphicsState
|
|
10778
|
+
*/
|
|
10779
|
+
declare const popGraphicsState: () => Operator;
|
|
10780
|
+
/**
|
|
10781
|
+
* Concatenate a transformation matrix to the current transformation matrix.
|
|
10782
|
+
*
|
|
10783
|
+
* Accepts either a Matrix instance or 6 individual matrix components [a, b, c, d, e, f].
|
|
10784
|
+
*
|
|
10785
|
+
* @example
|
|
10786
|
+
* ```typescript
|
|
10787
|
+
* // Using Matrix instance
|
|
10788
|
+
* const matrix = Matrix.identity().translate(100, 200).scale(2, 2);
|
|
10789
|
+
* ops.concatMatrix(matrix)
|
|
10790
|
+
*
|
|
10791
|
+
* // Using individual components
|
|
10792
|
+
* ops.concatMatrix(1, 0, 0, 1, 100, 200) // translate
|
|
10793
|
+
* ```
|
|
10794
|
+
*/
|
|
10795
|
+
declare function concatMatrix(matrix: Matrix): Operator;
|
|
10796
|
+
declare function concatMatrix(a: number, b: number, c: number, d: number, e: number, f: number): Operator;
|
|
10797
|
+
/**
|
|
10798
|
+
* Set the line width for stroking operations.
|
|
10799
|
+
*
|
|
10800
|
+
* @param width - Line width in user space units (points)
|
|
10801
|
+
*/
|
|
10802
|
+
declare const setLineWidth: (width: number) => Operator;
|
|
10803
|
+
/**
|
|
10804
|
+
* Set the line cap style for stroking operations.
|
|
10805
|
+
*
|
|
10806
|
+
* @param cap - Line cap style:
|
|
10807
|
+
* - 0: Butt cap (stroke ends at the endpoint)
|
|
10808
|
+
* - 1: Round cap (semicircle at endpoint)
|
|
10809
|
+
* - 2: Projecting square cap (extends half line width past endpoint)
|
|
10810
|
+
*/
|
|
10811
|
+
declare const setLineCap: (cap: 0 | 1 | 2) => Operator;
|
|
10812
|
+
/**
|
|
10813
|
+
* Set the line join style for stroking operations.
|
|
10814
|
+
*
|
|
10815
|
+
* @param join - Line join style:
|
|
10816
|
+
* - 0: Miter join (extended outer edges meet at an angle)
|
|
10817
|
+
* - 1: Round join (circular arc at join)
|
|
10818
|
+
* - 2: Bevel join (triangle fills the gap)
|
|
10819
|
+
*/
|
|
10820
|
+
declare const setLineJoin: (join: 0 | 1 | 2) => Operator;
|
|
10821
|
+
/**
|
|
10822
|
+
* Set the miter limit for line joins.
|
|
10823
|
+
*
|
|
10824
|
+
* When two line segments meet at a sharp angle and miter joins are specified,
|
|
10825
|
+
* the miter may extend far beyond the join point. The miter limit imposes a
|
|
10826
|
+
* maximum ratio of miter length to line width.
|
|
10827
|
+
*
|
|
10828
|
+
* @param limit - Miter limit ratio (minimum 1.0)
|
|
10829
|
+
*/
|
|
10830
|
+
declare const setMiterLimit: (limit: number) => Operator;
|
|
10831
|
+
/**
|
|
10832
|
+
* Set the dash pattern for stroking operations.
|
|
10833
|
+
*
|
|
10834
|
+
* @param array - Array of dash and gap lengths (empty for solid line)
|
|
10835
|
+
* @param phase - Offset into the dash pattern to start from
|
|
10836
|
+
*
|
|
10837
|
+
* @example
|
|
10838
|
+
* ```typescript
|
|
10839
|
+
* // Dashed line: 8pt dash, 4pt gap
|
|
10840
|
+
* ops.setDashPattern(new PdfArray([PdfNumber.of(8), PdfNumber.of(4)]), 0)
|
|
10841
|
+
*
|
|
10842
|
+
* // Solid line (reset)
|
|
10843
|
+
* ops.setDashPattern(new PdfArray([]), 0)
|
|
10844
|
+
* ```
|
|
10845
|
+
*/
|
|
10846
|
+
declare const setDashPattern: (array: PdfArray, phase: number) => Operator;
|
|
10847
|
+
/**
|
|
10848
|
+
* Set the extended graphics state from a named resource.
|
|
10849
|
+
*
|
|
10850
|
+
* Extended graphics state includes parameters like opacity, blend mode,
|
|
10851
|
+
* and other advanced graphics settings not in the basic graphics state.
|
|
10852
|
+
*
|
|
10853
|
+
* @param name - Resource name (e.g., "GS0"); normalized to have leading slash
|
|
10854
|
+
*/
|
|
10855
|
+
declare const setGraphicsState: (name: string) => Operator;
|
|
10856
|
+
/**
|
|
10857
|
+
* Begin a new subpath at the given point.
|
|
10858
|
+
*
|
|
10859
|
+
* Moves the current point without drawing. Subsequent lineTo/curveTo
|
|
10860
|
+
* operations will start from this point.
|
|
10861
|
+
*
|
|
10862
|
+
* @param x - X coordinate in user space
|
|
10863
|
+
* @param y - Y coordinate in user space
|
|
10864
|
+
*/
|
|
10865
|
+
declare const moveTo: (x: number, y: number) => Operator;
|
|
10866
|
+
/**
|
|
10867
|
+
* Append a straight line segment to the current path.
|
|
10868
|
+
*
|
|
10869
|
+
* Draws a line from the current point to (x, y) and makes (x, y)
|
|
10870
|
+
* the new current point.
|
|
10871
|
+
*
|
|
10872
|
+
* @param x - X coordinate of endpoint
|
|
10873
|
+
* @param y - Y coordinate of endpoint
|
|
10874
|
+
*/
|
|
10875
|
+
declare const lineTo: (x: number, y: number) => Operator;
|
|
10876
|
+
/**
|
|
10877
|
+
* Append a cubic Bezier curve to the current path.
|
|
10878
|
+
*
|
|
10879
|
+
* The curve extends from the current point to (x3, y3), using
|
|
10880
|
+
* (x1, y1) and (x2, y2) as control points.
|
|
10881
|
+
*
|
|
10882
|
+
* @param x1 - X coordinate of first control point
|
|
10883
|
+
* @param y1 - Y coordinate of first control point
|
|
10884
|
+
* @param x2 - X coordinate of second control point
|
|
10885
|
+
* @param y2 - Y coordinate of second control point
|
|
10886
|
+
* @param x3 - X coordinate of endpoint
|
|
10887
|
+
* @param y3 - Y coordinate of endpoint
|
|
10888
|
+
*/
|
|
10889
|
+
declare const curveTo: (x1: number, y1: number, x2: number, y2: number, x3: number, y3: number) => Operator;
|
|
10890
|
+
/**
|
|
10891
|
+
* Append a cubic Bezier curve using current point as first control point.
|
|
10892
|
+
*
|
|
10893
|
+
* The curve extends from the current point to (x3, y3). The first control
|
|
10894
|
+
* point is the current point; (x2, y2) is the second control point.
|
|
10895
|
+
*
|
|
10896
|
+
* @param x2 - X coordinate of second control point
|
|
10897
|
+
* @param y2 - Y coordinate of second control point
|
|
10898
|
+
* @param x3 - X coordinate of endpoint
|
|
10899
|
+
* @param y3 - Y coordinate of endpoint
|
|
10900
|
+
*/
|
|
10901
|
+
declare const curveToInitial: (x2: number, y2: number, x3: number, y3: number) => Operator;
|
|
10902
|
+
/**
|
|
10903
|
+
* Append a cubic Bezier curve using endpoint as second control point.
|
|
10904
|
+
*
|
|
10905
|
+
* The curve extends from the current point to (x3, y3). Uses (x1, y1)
|
|
10906
|
+
* as first control point; the second control point coincides with (x3, y3).
|
|
10907
|
+
*
|
|
10908
|
+
* @param x1 - X coordinate of first control point
|
|
10909
|
+
* @param y1 - Y coordinate of first control point
|
|
10910
|
+
* @param x3 - X coordinate of endpoint
|
|
10911
|
+
* @param y3 - Y coordinate of endpoint
|
|
10912
|
+
*/
|
|
10913
|
+
declare const curveToFinal: (x1: number, y1: number, x3: number, y3: number) => Operator;
|
|
10914
|
+
/**
|
|
10915
|
+
* Close the current subpath by appending a straight line to the start point.
|
|
10916
|
+
*
|
|
10917
|
+
* Draws a line from the current point to the starting point of the current
|
|
10918
|
+
* subpath (the point of the most recent moveTo).
|
|
10919
|
+
*/
|
|
10920
|
+
declare const closePath: () => Operator;
|
|
10921
|
+
/**
|
|
10922
|
+
* Append a rectangle to the current path.
|
|
10923
|
+
*
|
|
10924
|
+
* Equivalent to: moveTo(x, y), lineTo(x+width, y), lineTo(x+width, y+height),
|
|
10925
|
+
* lineTo(x, y+height), closePath().
|
|
10926
|
+
*
|
|
10927
|
+
* @param x - X coordinate of lower-left corner
|
|
10928
|
+
* @param y - Y coordinate of lower-left corner
|
|
10929
|
+
* @param width - Width of rectangle
|
|
10930
|
+
* @param height - Height of rectangle
|
|
10931
|
+
*/
|
|
10932
|
+
declare const rectangle: (x: number, y: number, width: number, height: number) => Operator;
|
|
10933
|
+
/** Stroke the current path using the current stroking color and line settings. */
|
|
10934
|
+
declare const stroke: () => Operator;
|
|
10935
|
+
/** Close the current subpath and then stroke the path. */
|
|
10936
|
+
declare const closeAndStroke: () => Operator;
|
|
10937
|
+
/**
|
|
10938
|
+
* Fill the current path using the non-zero winding number rule.
|
|
10939
|
+
*
|
|
10940
|
+
* Areas enclosed by the path are filled with the current non-stroking color.
|
|
10941
|
+
*/
|
|
10942
|
+
declare const fill: () => Operator;
|
|
10943
|
+
/**
|
|
10944
|
+
* Fill the current path using the non-zero winding number rule.
|
|
10945
|
+
*
|
|
10946
|
+
* @deprecated Use fill() instead. This is the legacy 'F' operator which is
|
|
10947
|
+
* equivalent to the 'f' operator.
|
|
10948
|
+
*/
|
|
10949
|
+
declare const fillCompat: () => Operator;
|
|
10950
|
+
/**
|
|
10951
|
+
* Fill the current path using the even-odd rule.
|
|
10952
|
+
*
|
|
10953
|
+
* The even-odd rule determines whether a point is inside the path by
|
|
10954
|
+
* counting path crossings. Points with an odd count are inside.
|
|
10955
|
+
*/
|
|
10956
|
+
declare const fillEvenOdd: () => Operator;
|
|
10957
|
+
/** Fill and then stroke the current path (non-zero winding fill rule). */
|
|
10958
|
+
declare const fillAndStroke: () => Operator;
|
|
10959
|
+
/** Fill (even-odd rule) and then stroke the current path. */
|
|
10960
|
+
declare const fillAndStrokeEvenOdd: () => Operator;
|
|
10961
|
+
/** Close, fill (non-zero winding), and stroke the current path. */
|
|
10962
|
+
declare const closeFillAndStroke: () => Operator;
|
|
10963
|
+
/** Close, fill (even-odd), and stroke the current path. */
|
|
10964
|
+
declare const closeFillAndStrokeEvenOdd: () => Operator;
|
|
10965
|
+
/**
|
|
10966
|
+
* End the path without filling or stroking.
|
|
10967
|
+
*
|
|
10968
|
+
* Use this after clipping to discard the path used for the clipping region.
|
|
10969
|
+
*/
|
|
10970
|
+
declare const endPath: () => Operator;
|
|
10971
|
+
/**
|
|
10972
|
+
* Intersect the current clipping path with the current path (non-zero winding rule).
|
|
10973
|
+
*
|
|
10974
|
+
* **Important:** The clip operator modifies the clipping path but does NOT consume
|
|
10975
|
+
* the current path. You MUST follow clip() with a path-painting operator:
|
|
10976
|
+
* - `endPath()` - Discard the path (most common for clipping)
|
|
10977
|
+
* - `fill()` - Fill the path AND use it for clipping
|
|
10978
|
+
* - `stroke()` - Stroke the path AND use it for clipping
|
|
10979
|
+
*
|
|
10980
|
+
* The clipping region persists until popGraphicsState() is called.
|
|
10981
|
+
* Always wrap clipping operations in pushGraphicsState()/popGraphicsState().
|
|
10982
|
+
*
|
|
10983
|
+
* @example
|
|
10984
|
+
* ```typescript
|
|
10985
|
+
* // Clip subsequent drawing to a rectangle
|
|
10986
|
+
* page.drawOperators([
|
|
10987
|
+
* ops.pushGraphicsState(),
|
|
10988
|
+
* ops.rectangle(50, 50, 100, 100),
|
|
10989
|
+
* ops.clip(),
|
|
10990
|
+
* ops.endPath(), // REQUIRED - consumes the path
|
|
10991
|
+
* // Now draw content that will be clipped
|
|
10992
|
+
* ops.paintShading(gradientName),
|
|
10993
|
+
* ops.popGraphicsState(), // Clipping region is restored
|
|
10994
|
+
* ]);
|
|
10995
|
+
* ```
|
|
10996
|
+
*
|
|
10997
|
+
* @see clipEvenOdd for the even-odd winding rule variant
|
|
10998
|
+
* @see endPath to consume the path after clipping
|
|
10999
|
+
*/
|
|
11000
|
+
declare const clip: () => Operator;
|
|
11001
|
+
/**
|
|
11002
|
+
* Intersect the current clipping path with the current path (even-odd rule).
|
|
11003
|
+
*
|
|
11004
|
+
* Like clip(), but uses the even-odd rule to determine what's inside the path.
|
|
11005
|
+
* The even-odd rule counts path crossings - points with an odd count are inside.
|
|
11006
|
+
*
|
|
11007
|
+
* **Important:** Must be followed by a path-painting operator (fill, stroke, or endPath).
|
|
11008
|
+
*
|
|
11009
|
+
* @example
|
|
11010
|
+
* ```typescript
|
|
11011
|
+
* // Create a donut-shaped clipping region
|
|
11012
|
+
* page.drawOperators([
|
|
11013
|
+
* ops.pushGraphicsState(),
|
|
11014
|
+
* // Outer circle
|
|
11015
|
+
* ops.moveTo(150, 100), // ... circle path ops
|
|
11016
|
+
* // Inner circle (drawn in same direction)
|
|
11017
|
+
* ops.moveTo(120, 100), // ... circle path ops
|
|
11018
|
+
* ops.clipEvenOdd(),
|
|
11019
|
+
* ops.endPath(),
|
|
11020
|
+
* // Content here is clipped to the donut shape
|
|
11021
|
+
* ops.popGraphicsState(),
|
|
11022
|
+
* ]);
|
|
11023
|
+
* ```
|
|
11024
|
+
*
|
|
11025
|
+
* @see clip for the non-zero winding rule variant
|
|
11026
|
+
*/
|
|
11027
|
+
declare const clipEvenOdd: () => Operator;
|
|
11028
|
+
/**
|
|
11029
|
+
* Set the character spacing (extra space between characters).
|
|
11030
|
+
*
|
|
11031
|
+
* @param spacing - Additional space in text space units (default 0)
|
|
11032
|
+
*/
|
|
11033
|
+
declare const setCharSpacing: (spacing: number) => Operator;
|
|
11034
|
+
/**
|
|
11035
|
+
* Set the word spacing (extra space between words).
|
|
11036
|
+
*
|
|
11037
|
+
* Word spacing is added to each ASCII space character (0x20).
|
|
11038
|
+
*
|
|
11039
|
+
* @param spacing - Additional space in text space units (default 0)
|
|
11040
|
+
*/
|
|
11041
|
+
declare const setWordSpacing: (spacing: number) => Operator;
|
|
11042
|
+
/**
|
|
11043
|
+
* Set the horizontal scaling factor for text.
|
|
11044
|
+
*
|
|
11045
|
+
* @param scale - Percentage of normal width (100 = normal)
|
|
11046
|
+
*/
|
|
11047
|
+
declare const setHorizontalScale: (scale: number) => Operator;
|
|
11048
|
+
/**
|
|
11049
|
+
* Set the text leading (line spacing).
|
|
11050
|
+
*
|
|
11051
|
+
* Used by nextLine() and moveTextSetLeading() to move to the next line.
|
|
11052
|
+
*
|
|
11053
|
+
* @param leading - Vertical distance between baselines (in text space units)
|
|
11054
|
+
*/
|
|
11055
|
+
declare const setLeading: (leading: number) => Operator;
|
|
11056
|
+
/**
|
|
11057
|
+
* Set the font and size for text operations.
|
|
11058
|
+
*
|
|
11059
|
+
* @param name - Font resource name (e.g., "F0"); normalized to have leading slash
|
|
11060
|
+
* @param size - Font size in text space units
|
|
11061
|
+
*/
|
|
11062
|
+
declare const setFont: (name: string, size: number) => Operator;
|
|
11063
|
+
/**
|
|
11064
|
+
* Set the text rendering mode.
|
|
11065
|
+
*
|
|
11066
|
+
* @param mode - Rendering mode:
|
|
11067
|
+
* - 0: Fill text
|
|
11068
|
+
* - 1: Stroke text
|
|
11069
|
+
* - 2: Fill then stroke
|
|
11070
|
+
* - 3: Invisible (no fill or stroke)
|
|
11071
|
+
* - 4: Fill and add to clipping path
|
|
11072
|
+
* - 5: Stroke and add to clipping path
|
|
11073
|
+
* - 6: Fill, stroke, and add to clipping path
|
|
11074
|
+
* - 7: Add to clipping path (invisible)
|
|
11075
|
+
*/
|
|
11076
|
+
declare const setTextRenderMode: (mode: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7) => Operator;
|
|
11077
|
+
/**
|
|
11078
|
+
* Set the text rise (baseline offset).
|
|
11079
|
+
*
|
|
11080
|
+
* Moves the baseline up (positive) or down (negative) relative to the
|
|
11081
|
+
* current text line. Used for superscripts and subscripts.
|
|
11082
|
+
*
|
|
11083
|
+
* @param rise - Vertical offset in text space units
|
|
11084
|
+
*/
|
|
11085
|
+
declare const setTextRise: (rise: number) => Operator;
|
|
11086
|
+
/**
|
|
11087
|
+
* Begin a text object.
|
|
11088
|
+
*
|
|
11089
|
+
* Text operations (showText, moveText, setFont, etc.) can only be used
|
|
11090
|
+
* between beginText() and endText().
|
|
11091
|
+
*/
|
|
11092
|
+
declare const beginText: () => Operator;
|
|
11093
|
+
/** End the text object and restore the text state. */
|
|
11094
|
+
declare const endText: () => Operator;
|
|
11095
|
+
/**
|
|
11096
|
+
* Move to the start of the next line, offset from the current line origin.
|
|
11097
|
+
*
|
|
11098
|
+
* @param tx - Horizontal offset in text space units
|
|
11099
|
+
* @param ty - Vertical offset in text space units
|
|
11100
|
+
*/
|
|
11101
|
+
declare const moveText: (tx: number, ty: number) => Operator;
|
|
11102
|
+
/**
|
|
11103
|
+
* Move to the next line and set the leading.
|
|
11104
|
+
*
|
|
11105
|
+
* Equivalent to: setLeading(-ty), moveText(tx, ty).
|
|
11106
|
+
*
|
|
11107
|
+
* @param tx - Horizontal offset in text space units
|
|
11108
|
+
* @param ty - Vertical offset (negative of the leading)
|
|
11109
|
+
*/
|
|
11110
|
+
declare const moveTextSetLeading: (tx: number, ty: number) => Operator;
|
|
11111
|
+
/**
|
|
11112
|
+
* Set the text matrix and text line matrix.
|
|
11113
|
+
*
|
|
11114
|
+
* Unlike concatMatrix, this replaces (not concatenates) the text matrix.
|
|
11115
|
+
*
|
|
11116
|
+
* @param a - Horizontal scaling
|
|
11117
|
+
* @param b - Horizontal skewing
|
|
11118
|
+
* @param c - Vertical skewing
|
|
11119
|
+
* @param d - Vertical scaling
|
|
11120
|
+
* @param e - Horizontal translation (text position X)
|
|
11121
|
+
* @param f - Vertical translation (text position Y)
|
|
11122
|
+
*/
|
|
11123
|
+
declare const setTextMatrix: (a: number, b: number, c: number, d: number, e: number, f: number) => Operator;
|
|
11124
|
+
/**
|
|
11125
|
+
* Move to the start of the next line.
|
|
11126
|
+
*
|
|
11127
|
+
* Equivalent to: moveText(0, -leading), where leading is the current text leading.
|
|
11128
|
+
*/
|
|
11129
|
+
declare const nextLine: () => Operator;
|
|
11130
|
+
/**
|
|
11131
|
+
* Show a text string.
|
|
11132
|
+
*
|
|
11133
|
+
* Accepts either a plain string (auto-encoded) or a PdfString instance.
|
|
11134
|
+
* Plain strings are encoded using PdfString.fromString() which picks
|
|
11135
|
+
* the optimal encoding.
|
|
11136
|
+
*/
|
|
11137
|
+
declare const showText: (text: string | PdfString) => Operator;
|
|
11138
|
+
/**
|
|
11139
|
+
* Show text strings with individual position adjustments.
|
|
11140
|
+
*
|
|
11141
|
+
* The array contains strings and numbers. Numbers are horizontal adjustments
|
|
11142
|
+
* in thousandths of a text space unit (negative = move right).
|
|
11143
|
+
*
|
|
11144
|
+
* @param array - Array of strings and position adjustments
|
|
11145
|
+
*
|
|
11146
|
+
* @example
|
|
11147
|
+
* ```typescript
|
|
11148
|
+
* // Kern "AV" by moving V slightly left
|
|
11149
|
+
* ops.showTextArray(new PdfArray([
|
|
11150
|
+
* PdfString.fromString("A"),
|
|
11151
|
+
* PdfNumber.of(-50), // Move left 50/1000 of text space
|
|
11152
|
+
* PdfString.fromString("V"),
|
|
11153
|
+
* ]))
|
|
11154
|
+
* ```
|
|
11155
|
+
*/
|
|
11156
|
+
declare const showTextArray: (array: PdfArray) => Operator;
|
|
11157
|
+
/**
|
|
11158
|
+
* Move to next line and show text.
|
|
11159
|
+
*
|
|
11160
|
+
* Accepts either a plain string (auto-encoded) or a PdfString instance.
|
|
11161
|
+
*/
|
|
11162
|
+
declare const moveAndShowText: (text: string | PdfString) => Operator;
|
|
11163
|
+
/**
|
|
11164
|
+
* Move to next line, set word and character spacing, and show text.
|
|
11165
|
+
*
|
|
11166
|
+
* Accepts either a plain string (auto-encoded) or a PdfString instance.
|
|
11167
|
+
*/
|
|
11168
|
+
declare const moveSetSpacingShowText: (wordSpacing: number, charSpacing: number, text: string | PdfString) => Operator;
|
|
11169
|
+
/**
|
|
11170
|
+
* Set the stroking color space.
|
|
11171
|
+
*
|
|
11172
|
+
* @param name - Color space name (e.g., "DeviceRGB", "Pattern"); normalized to have leading slash
|
|
11173
|
+
*/
|
|
11174
|
+
declare const setStrokingColorSpace: (name: string) => Operator;
|
|
11175
|
+
/**
|
|
11176
|
+
* Set the non-stroking (fill) color space.
|
|
11177
|
+
*
|
|
11178
|
+
* @param name - Color space name (e.g., "DeviceRGB", "Pattern"); normalized to have leading slash
|
|
11179
|
+
*/
|
|
11180
|
+
declare const setNonStrokingColorSpace: (name: string) => Operator;
|
|
11181
|
+
/**
|
|
11182
|
+
* Set the stroking color in the current color space.
|
|
11183
|
+
*
|
|
11184
|
+
* Number of components depends on the current stroking color space.
|
|
11185
|
+
*
|
|
11186
|
+
* @param components - Color component values (0-1 for most color spaces)
|
|
11187
|
+
*/
|
|
11188
|
+
declare const setStrokingColor: (...components: number[]) => Operator;
|
|
11189
|
+
/**
|
|
11190
|
+
* Set stroking color with extended color space.
|
|
11191
|
+
*
|
|
11192
|
+
* String components (like pattern names) are normalized to have leading slashes.
|
|
11193
|
+
*/
|
|
11194
|
+
declare const setStrokingColorN: (...components: (number | string)[]) => Operator;
|
|
11195
|
+
/**
|
|
11196
|
+
* Set the non-stroking (fill) color in the current color space.
|
|
11197
|
+
*
|
|
11198
|
+
* Number of components depends on the current non-stroking color space.
|
|
11199
|
+
*
|
|
11200
|
+
* @param components - Color component values (0-1 for most color spaces)
|
|
11201
|
+
*/
|
|
11202
|
+
declare const setNonStrokingColor: (...components: number[]) => Operator;
|
|
11203
|
+
/**
|
|
11204
|
+
* Set non-stroking (fill) color with extended color space.
|
|
11205
|
+
*
|
|
11206
|
+
* String components (like pattern names) are normalized to have leading slashes.
|
|
11207
|
+
*/
|
|
11208
|
+
declare const setNonStrokingColorN: (...components: (number | string)[]) => Operator;
|
|
11209
|
+
/**
|
|
11210
|
+
* Set the stroking color to a grayscale value.
|
|
11211
|
+
*
|
|
11212
|
+
* Equivalent to setStrokingColorSpace("DeviceGray"), setStrokingColor(gray).
|
|
11213
|
+
*
|
|
11214
|
+
* @param gray - Gray value (0 = black, 1 = white)
|
|
11215
|
+
*/
|
|
11216
|
+
declare const setStrokingGray: (gray: number) => Operator;
|
|
11217
|
+
/**
|
|
11218
|
+
* Set the non-stroking (fill) color to a grayscale value.
|
|
11219
|
+
*
|
|
11220
|
+
* Equivalent to setNonStrokingColorSpace("DeviceGray"), setNonStrokingColor(gray).
|
|
11221
|
+
*
|
|
11222
|
+
* @param gray - Gray value (0 = black, 1 = white)
|
|
11223
|
+
*/
|
|
11224
|
+
declare const setNonStrokingGray: (gray: number) => Operator;
|
|
11225
|
+
/**
|
|
11226
|
+
* Set the stroking color to an RGB value.
|
|
11227
|
+
*
|
|
11228
|
+
* Equivalent to setStrokingColorSpace("DeviceRGB"), setStrokingColor(r, g, b).
|
|
11229
|
+
*
|
|
11230
|
+
* @param r - Red component (0-1)
|
|
11231
|
+
* @param g - Green component (0-1)
|
|
11232
|
+
* @param b - Blue component (0-1)
|
|
11233
|
+
*/
|
|
11234
|
+
declare const setStrokingRGB: (r: number, g: number, b: number) => Operator;
|
|
11235
|
+
/**
|
|
11236
|
+
* Set the non-stroking (fill) color to an RGB value.
|
|
11237
|
+
*
|
|
11238
|
+
* Equivalent to setNonStrokingColorSpace("DeviceRGB"), setNonStrokingColor(r, g, b).
|
|
11239
|
+
*
|
|
11240
|
+
* @param r - Red component (0-1)
|
|
11241
|
+
* @param g - Green component (0-1)
|
|
11242
|
+
* @param b - Blue component (0-1)
|
|
11243
|
+
*/
|
|
11244
|
+
declare const setNonStrokingRGB: (r: number, g: number, b: number) => Operator;
|
|
11245
|
+
/**
|
|
11246
|
+
* Set the stroking color to a CMYK value.
|
|
11247
|
+
*
|
|
11248
|
+
* Equivalent to setStrokingColorSpace("DeviceCMYK"), setStrokingColor(c, m, y, k).
|
|
11249
|
+
*
|
|
11250
|
+
* @param c - Cyan component (0-1)
|
|
11251
|
+
* @param m - Magenta component (0-1)
|
|
11252
|
+
* @param y - Yellow component (0-1)
|
|
11253
|
+
* @param k - Black component (0-1)
|
|
11254
|
+
*/
|
|
11255
|
+
declare const setStrokingCMYK: (c: number, m: number, y: number, k: number) => Operator;
|
|
11256
|
+
/**
|
|
11257
|
+
* Set the non-stroking (fill) color to a CMYK value.
|
|
11258
|
+
*
|
|
11259
|
+
* Equivalent to setNonStrokingColorSpace("DeviceCMYK"), setNonStrokingColor(c, m, y, k).
|
|
11260
|
+
*
|
|
11261
|
+
* @param c - Cyan component (0-1)
|
|
11262
|
+
* @param m - Magenta component (0-1)
|
|
11263
|
+
* @param y - Yellow component (0-1)
|
|
11264
|
+
* @param k - Black component (0-1)
|
|
11265
|
+
*/
|
|
11266
|
+
declare const setNonStrokingCMYK: (c: number, m: number, y: number, k: number) => Operator;
|
|
11267
|
+
/**
|
|
11268
|
+
* @deprecated Use paintXObject instead. This alias exists for backwards compatibility.
|
|
11269
|
+
*/
|
|
11270
|
+
declare const drawXObject: (name: string) => Operator;
|
|
11271
|
+
/**
|
|
11272
|
+
* Paint an XObject (image or Form XObject).
|
|
11273
|
+
*
|
|
11274
|
+
* XObjects are external objects that can be rendered in a content stream:
|
|
11275
|
+
* - **Images**: Raster graphics (JPEG, PNG, etc.)
|
|
11276
|
+
* - **Form XObjects**: Reusable vector content (stamps, watermarks, etc.)
|
|
11277
|
+
*
|
|
11278
|
+
* The XObject is painted at the current origin. Use concatMatrix to
|
|
11279
|
+
* position, scale, and rotate before painting.
|
|
11280
|
+
*
|
|
11281
|
+
* @param name - XObject resource name (e.g., "Im0", "Fm0"); normalized to have leading slash
|
|
11282
|
+
*
|
|
11283
|
+
* @example
|
|
11284
|
+
* ```typescript
|
|
11285
|
+
* // Paint an image at 100x100 size at position (200, 500)
|
|
11286
|
+
* page.drawOperators([
|
|
11287
|
+
* ops.pushGraphicsState(),
|
|
11288
|
+
* ops.concatMatrix(100, 0, 0, 100, 200, 500), // Scale and translate
|
|
11289
|
+
* ops.paintXObject(imageName),
|
|
11290
|
+
* ops.popGraphicsState(),
|
|
11291
|
+
* ]);
|
|
11292
|
+
*
|
|
11293
|
+
* // Paint a form XObject (stamp) at original size
|
|
11294
|
+
* page.drawOperators([
|
|
11295
|
+
* ops.pushGraphicsState(),
|
|
11296
|
+
* ops.concatMatrix(1, 0, 0, 1, 50, 700), // Just translate
|
|
11297
|
+
* ops.paintXObject(stampName),
|
|
11298
|
+
* ops.popGraphicsState(),
|
|
11299
|
+
* ]);
|
|
11300
|
+
* ```
|
|
11301
|
+
*/
|
|
11302
|
+
declare const paintXObject: (name: string) => Operator;
|
|
11303
|
+
/**
|
|
11304
|
+
* Paint a shading (gradient) directly, filling the current clipping region.
|
|
11305
|
+
*
|
|
11306
|
+
* @param name - Shading resource name (e.g., "Sh0"); normalized to have leading slash
|
|
11307
|
+
*
|
|
11308
|
+
* @example
|
|
11309
|
+
* ```typescript
|
|
11310
|
+
* // Fill a rectangle with a gradient
|
|
11311
|
+
* page.drawOperators([
|
|
11312
|
+
* ops.pushGraphicsState(),
|
|
11313
|
+
* ops.rectangle(50, 50, 100, 100),
|
|
11314
|
+
* ops.clip(),
|
|
11315
|
+
* ops.endPath(),
|
|
11316
|
+
* ops.paintShading(shadingName),
|
|
11317
|
+
* ops.popGraphicsState(),
|
|
11318
|
+
* ]);
|
|
11319
|
+
* ```
|
|
11320
|
+
*/
|
|
11321
|
+
declare const paintShading: (name: string) => Operator;
|
|
11322
|
+
/**
|
|
11323
|
+
* Designate a marked content point (no content, just a tag).
|
|
11324
|
+
*
|
|
11325
|
+
* Used for structure and accessibility information.
|
|
11326
|
+
*
|
|
11327
|
+
* @param tag - Content tag name (e.g., "Artifact", "Figure")
|
|
11328
|
+
*/
|
|
11329
|
+
declare const designateMarkedContentPoint: (tag: string) => Operator;
|
|
11330
|
+
/**
|
|
11331
|
+
* Designate a marked content point with properties.
|
|
11332
|
+
*
|
|
11333
|
+
* @param tag - Content tag name
|
|
11334
|
+
* @param props - Property dictionary or property list name
|
|
11335
|
+
*/
|
|
11336
|
+
declare const designateMarkedContentPointProps: (tag: string, props: PdfDict | string) => Operator;
|
|
11337
|
+
/**
|
|
11338
|
+
* Begin a marked content sequence.
|
|
11339
|
+
*
|
|
11340
|
+
* Content between beginMarkedContent() and endMarkedContent() is associated
|
|
11341
|
+
* with the given tag for structure/accessibility purposes.
|
|
11342
|
+
*
|
|
11343
|
+
* @param tag - Content tag name (e.g., "P" for paragraph, "Span")
|
|
11344
|
+
*/
|
|
11345
|
+
declare const beginMarkedContent: (tag: string) => Operator;
|
|
11346
|
+
/**
|
|
11347
|
+
* Begin a marked content sequence with properties.
|
|
11348
|
+
*
|
|
11349
|
+
* @param tag - Content tag name
|
|
11350
|
+
* @param props - Property dictionary or property list name
|
|
11351
|
+
*/
|
|
11352
|
+
declare const beginMarkedContentProps: (tag: string, props: PdfDict | string) => Operator;
|
|
11353
|
+
/** End the current marked content sequence. */
|
|
11354
|
+
declare const endMarkedContent: () => Operator;
|
|
11355
|
+
//#endregion
|
|
11356
|
+
//#region src/helpers/colorspace.d.ts
|
|
11357
|
+
/**
|
|
11358
|
+
* PDF color space constants for use with low-level drawing operators.
|
|
11359
|
+
*
|
|
11360
|
+
* These are the standard PDF color space names used with setStrokingColorSpace
|
|
11361
|
+
* and setNonStrokingColorSpace operators.
|
|
11362
|
+
*/
|
|
11363
|
+
declare const ColorSpace: {
|
|
11364
|
+
/** Device Gray color space (single component: 0-1) */
|
|
11365
|
+
readonly DeviceGray: "DeviceGray";
|
|
11366
|
+
/** Device RGB color space (three components: 0-1 each) */
|
|
11367
|
+
readonly DeviceRGB: "DeviceRGB";
|
|
11368
|
+
/** Device CMYK color space (four components: 0-1 each) */
|
|
11369
|
+
readonly DeviceCMYK: "DeviceCMYK";
|
|
11370
|
+
/** Pattern color space (for tiling patterns) */
|
|
11371
|
+
readonly Pattern: "Pattern";
|
|
11372
|
+
};
|
|
11373
|
+
type ColorSpace = (typeof ColorSpace)[keyof typeof ColorSpace];
|
|
11374
|
+
//#endregion
|
|
9370
11375
|
//#region src/helpers/pem.d.ts
|
|
9371
11376
|
/**
|
|
9372
11377
|
* PEM encoding/decoding utilities.
|
|
@@ -9428,5 +11433,5 @@ declare function isWidgetAnnotation(dict: PdfDict, registry?: ObjectRegistry): b
|
|
|
9428
11433
|
*/
|
|
9429
11434
|
declare function isPopupAnnotation(dict: PdfDict, registry?: ObjectRegistry): boolean;
|
|
9430
11435
|
//#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 };
|
|
11436
|
+
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
11437
|
//# sourceMappingURL=index.d.mts.map
|