modern-pdf-lib 0.12.0 → 0.13.0
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/README.md +7 -5
- package/dist/{fflateAdapter-cT4YeY_h.cjs → fflateAdapter-AHC_S3cb.cjs} +1 -1
- package/dist/{fflateAdapter-D2mv_ttM.mjs → fflateAdapter-DX0VqT5k.mjs} +1 -1
- package/dist/{fontSubset-ClyTXlhY.mjs → fontSubset-ZpLoOZ2e.mjs} +1 -1
- package/dist/{fontSubset-BxsF9Tu5.cjs → fontSubset-pFc8Dueu.cjs} +1 -1
- package/dist/index.cjs +19696 -96
- package/dist/index.d.cts +393 -10
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +393 -10
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +19601 -8
- package/dist/{libdeflateWasm-QVHmuzw-.mjs → libdeflateWasm-DlHgU5oy.mjs} +2 -2
- package/dist/{libdeflateWasm-to2bG6NG.cjs → libdeflateWasm-OkNoqBnO.cjs} +2 -2
- package/dist/{loader-D9LTYmrX.mjs → loader-CQfoGFp9.mjs} +4 -3
- package/dist/{loader-mwt5wRJz.cjs → loader-_fqS-TmT.cjs} +4 -3
- package/dist/{pdfPage-JiCJLV3x.mjs → pdfPage-B7vA518n.mjs} +644 -216
- package/dist/{pdfPage-BMGFx7Xd.cjs → pdfPage-BebMv6fN.cjs} +672 -214
- package/dist/{pngEmbed-D4Uig1LV.mjs → pngEmbed-DTOqgEUC.mjs} +2 -2
- package/dist/{pngEmbed-BogDTEfL.cjs → pngEmbed-OYyOe_W0.cjs} +2 -2
- package/package.json +2 -2
- package/dist/documentMerge-F1EwwhJP.mjs +0 -19081
- package/dist/documentMerge-SGckZBSb.cjs +0 -19608
package/dist/index.d.cts
CHANGED
|
@@ -1264,7 +1264,7 @@ interface RedactionOptions {
|
|
|
1264
1264
|
b: number;
|
|
1265
1265
|
} | undefined;
|
|
1266
1266
|
}
|
|
1267
|
-
/**
|
|
1267
|
+
/** Redaction mark stored on a page. */
|
|
1268
1268
|
interface RedactionMark {
|
|
1269
1269
|
rect: [number, number, number, number];
|
|
1270
1270
|
overlayText?: string | undefined;
|
|
@@ -1407,6 +1407,182 @@ interface EmbedPageOptions {
|
|
|
1407
1407
|
*/
|
|
1408
1408
|
declare function embedPageAsFormXObject(page: PdfPage, sourceRegistry: PdfObjectRegistry, targetRegistry: PdfObjectRegistry, xObjectName: string, options?: EmbedPageOptions): EmbeddedPdfPage;
|
|
1409
1409
|
//#endregion
|
|
1410
|
+
//#region src/core/patterns.d.ts
|
|
1411
|
+
/**
|
|
1412
|
+
* A colour stop in a gradient, specifying the position (0..1) and colour.
|
|
1413
|
+
*/
|
|
1414
|
+
interface ColorStop {
|
|
1415
|
+
readonly offset: number;
|
|
1416
|
+
readonly color: Color;
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Options for creating a linear gradient (axial shading, ShadingType 2).
|
|
1420
|
+
*/
|
|
1421
|
+
interface LinearGradientOptions {
|
|
1422
|
+
/** Start X coordinate. */
|
|
1423
|
+
readonly x1: number;
|
|
1424
|
+
/** Start Y coordinate. */
|
|
1425
|
+
readonly y1: number;
|
|
1426
|
+
/** End X coordinate. */
|
|
1427
|
+
readonly x2: number;
|
|
1428
|
+
/** End Y coordinate. */
|
|
1429
|
+
readonly y2: number;
|
|
1430
|
+
/**
|
|
1431
|
+
* Colour stops. Each element is either a bare {@link Color} (positions
|
|
1432
|
+
* are distributed evenly) or a {@link ColorStop} with an explicit offset.
|
|
1433
|
+
*/
|
|
1434
|
+
readonly stops: readonly (Color | ColorStop)[];
|
|
1435
|
+
/**
|
|
1436
|
+
* Whether to extend the gradient beyond the start and end points.
|
|
1437
|
+
* Default: `true`.
|
|
1438
|
+
*/
|
|
1439
|
+
readonly extend?: boolean;
|
|
1440
|
+
}
|
|
1441
|
+
/**
|
|
1442
|
+
* Options for creating a radial gradient (radial shading, ShadingType 3).
|
|
1443
|
+
*/
|
|
1444
|
+
interface RadialGradientOptions {
|
|
1445
|
+
/** Centre X of the start circle. */
|
|
1446
|
+
readonly x0: number;
|
|
1447
|
+
/** Centre Y of the start circle. */
|
|
1448
|
+
readonly y0: number;
|
|
1449
|
+
/** Radius of the start circle. */
|
|
1450
|
+
readonly r0: number;
|
|
1451
|
+
/** Centre X of the end circle. */
|
|
1452
|
+
readonly x1: number;
|
|
1453
|
+
/** Centre Y of the end circle. */
|
|
1454
|
+
readonly y1: number;
|
|
1455
|
+
/** Radius of the end circle. */
|
|
1456
|
+
readonly r1: number;
|
|
1457
|
+
/**
|
|
1458
|
+
* Colour stops (same semantics as {@link LinearGradientOptions.stops}).
|
|
1459
|
+
*/
|
|
1460
|
+
readonly stops: readonly (Color | ColorStop)[];
|
|
1461
|
+
/**
|
|
1462
|
+
* Whether to extend the gradient beyond the start and end circles.
|
|
1463
|
+
* Default: `true`.
|
|
1464
|
+
*/
|
|
1465
|
+
readonly extend?: boolean;
|
|
1466
|
+
}
|
|
1467
|
+
/**
|
|
1468
|
+
* Options for creating a tiling pattern (PatternType 1).
|
|
1469
|
+
*/
|
|
1470
|
+
interface TilingPatternOptions {
|
|
1471
|
+
/** Width of one tile in user-space units. */
|
|
1472
|
+
readonly width: number;
|
|
1473
|
+
/** Height of one tile in user-space units. */
|
|
1474
|
+
readonly height: number;
|
|
1475
|
+
/**
|
|
1476
|
+
* Paint type.
|
|
1477
|
+
* - `1` (default) — coloured: the pattern's content stream specifies
|
|
1478
|
+
* its own colours.
|
|
1479
|
+
* - `2` — uncoloured: colours are supplied when the pattern is painted.
|
|
1480
|
+
*/
|
|
1481
|
+
readonly paintType?: 1 | 2;
|
|
1482
|
+
/**
|
|
1483
|
+
* Tiling type.
|
|
1484
|
+
* - `1` (default) — constant spacing.
|
|
1485
|
+
* - `2` — no distortion.
|
|
1486
|
+
* - `3` — constant spacing and faster tiling.
|
|
1487
|
+
*/
|
|
1488
|
+
readonly tilingType?: 1 | 2 | 3;
|
|
1489
|
+
/** Raw PDF content-stream operators that paint one tile. */
|
|
1490
|
+
readonly ops: string;
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Descriptor for a gradient fill (linear or radial).
|
|
1494
|
+
* This is a lightweight value object — actual PDF objects are created
|
|
1495
|
+
* when {@link buildGradientObjects} is called.
|
|
1496
|
+
*/
|
|
1497
|
+
interface GradientFill {
|
|
1498
|
+
readonly kind: 'gradient';
|
|
1499
|
+
readonly shadingType: 2 | 3;
|
|
1500
|
+
readonly coords: readonly number[];
|
|
1501
|
+
readonly normalizedStops: readonly NormalizedStop[];
|
|
1502
|
+
readonly extend: boolean;
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Descriptor for a radial gradient fill.
|
|
1506
|
+
* Structurally identical to {@link GradientFill} but with `shadingType: 3`.
|
|
1507
|
+
*/
|
|
1508
|
+
type RadialGradientFill = GradientFill & {
|
|
1509
|
+
readonly shadingType: 3;
|
|
1510
|
+
};
|
|
1511
|
+
/**
|
|
1512
|
+
* Descriptor for a tiling pattern fill.
|
|
1513
|
+
* This is a lightweight value object — actual PDF objects are created
|
|
1514
|
+
* when {@link buildPatternObjects} is called.
|
|
1515
|
+
*/
|
|
1516
|
+
interface PatternFill {
|
|
1517
|
+
readonly kind: 'pattern';
|
|
1518
|
+
readonly width: number;
|
|
1519
|
+
readonly height: number;
|
|
1520
|
+
readonly paintType: 1 | 2;
|
|
1521
|
+
readonly tilingType: 1 | 2 | 3;
|
|
1522
|
+
readonly ops: string;
|
|
1523
|
+
}
|
|
1524
|
+
/** A normalised colour stop with explicit offset and RGB values. */
|
|
1525
|
+
interface NormalizedStop {
|
|
1526
|
+
readonly offset: number;
|
|
1527
|
+
readonly r: number;
|
|
1528
|
+
readonly g: number;
|
|
1529
|
+
readonly b: number;
|
|
1530
|
+
}
|
|
1531
|
+
/**
|
|
1532
|
+
* Create a linear (axial) gradient descriptor.
|
|
1533
|
+
*
|
|
1534
|
+
* The gradient runs from `(x1, y1)` to `(x2, y2)` through the given
|
|
1535
|
+
* colour stops. By default the gradient extends beyond its endpoints.
|
|
1536
|
+
*
|
|
1537
|
+
* @param options Gradient parameters.
|
|
1538
|
+
* @returns A {@link GradientFill} descriptor.
|
|
1539
|
+
*/
|
|
1540
|
+
declare function linearGradient(options: LinearGradientOptions): GradientFill;
|
|
1541
|
+
/**
|
|
1542
|
+
* Create a radial gradient descriptor.
|
|
1543
|
+
*
|
|
1544
|
+
* The gradient interpolates between two circles: the start circle at
|
|
1545
|
+
* `(x0, y0)` with radius `r0` and the end circle at `(x1, y1)` with
|
|
1546
|
+
* radius `r1`.
|
|
1547
|
+
*
|
|
1548
|
+
* @param options Gradient parameters.
|
|
1549
|
+
* @returns A {@link GradientFill} descriptor (with `shadingType: 3`).
|
|
1550
|
+
*/
|
|
1551
|
+
declare function radialGradient(options: RadialGradientOptions): GradientFill;
|
|
1552
|
+
/**
|
|
1553
|
+
* Create a tiling pattern descriptor.
|
|
1554
|
+
*
|
|
1555
|
+
* @param options Pattern parameters including the tile content stream.
|
|
1556
|
+
* @returns A {@link PatternFill} descriptor.
|
|
1557
|
+
*/
|
|
1558
|
+
declare function tilingPattern(options: TilingPatternOptions): PatternFill;
|
|
1559
|
+
/**
|
|
1560
|
+
* Materialise a {@link GradientFill} descriptor into actual PDF objects
|
|
1561
|
+
* in the given registry.
|
|
1562
|
+
*
|
|
1563
|
+
* @param gradient The gradient descriptor.
|
|
1564
|
+
* @param registry The document's object registry.
|
|
1565
|
+
* @returns An object with the pattern's indirect reference and a unique
|
|
1566
|
+
* resource name.
|
|
1567
|
+
*/
|
|
1568
|
+
declare function buildGradientObjects(gradient: GradientFill, registry: PdfObjectRegistry): {
|
|
1569
|
+
patternRef: PdfRef;
|
|
1570
|
+
patternName: string;
|
|
1571
|
+
};
|
|
1572
|
+
/**
|
|
1573
|
+
* Materialise a {@link PatternFill} descriptor into actual PDF objects
|
|
1574
|
+
* in the given registry.
|
|
1575
|
+
*
|
|
1576
|
+
* @param pattern The tiling pattern descriptor.
|
|
1577
|
+
* @param registry The document's object registry.
|
|
1578
|
+
* @returns An object with the pattern's indirect reference and a unique
|
|
1579
|
+
* resource name.
|
|
1580
|
+
*/
|
|
1581
|
+
declare function buildPatternObjects(pattern: PatternFill, registry: PdfObjectRegistry): {
|
|
1582
|
+
patternRef: PdfRef;
|
|
1583
|
+
patternName: string;
|
|
1584
|
+
};
|
|
1585
|
+
//#endregion
|
|
1410
1586
|
//#region src/core/pdfPage.d.ts
|
|
1411
1587
|
/** Pre-defined page sizes as `[width, height]` tuples in PDF points. */
|
|
1412
1588
|
declare const PageSizes: {
|
|
@@ -1803,6 +1979,59 @@ interface ImageRef {
|
|
|
1803
1979
|
height: number;
|
|
1804
1980
|
};
|
|
1805
1981
|
}
|
|
1982
|
+
/**
|
|
1983
|
+
* Options for transparency groups.
|
|
1984
|
+
*
|
|
1985
|
+
* Transparency groups allow a set of drawing operations to be composited
|
|
1986
|
+
* as a single unit before being blended with the page content.
|
|
1987
|
+
*/
|
|
1988
|
+
interface TransparencyGroupOptions {
|
|
1989
|
+
/**
|
|
1990
|
+
* When `true`, the group is composited against a fully transparent
|
|
1991
|
+
* backdrop rather than the existing page content. Default: `true`.
|
|
1992
|
+
*/
|
|
1993
|
+
isolated?: boolean;
|
|
1994
|
+
/**
|
|
1995
|
+
* When `true`, earlier objects in the group are knocked out (replaced)
|
|
1996
|
+
* by later objects, rather than composited on top. Default: `false`.
|
|
1997
|
+
*/
|
|
1998
|
+
knockout?: boolean;
|
|
1999
|
+
/**
|
|
2000
|
+
* Color space for the transparency group. Default: `'DeviceRGB'`.
|
|
2001
|
+
*/
|
|
2002
|
+
colorSpace?: 'DeviceRGB' | 'DeviceCMYK' | 'DeviceGray';
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Builder interface for constructing soft mask content.
|
|
2006
|
+
*
|
|
2007
|
+
* All drawing is in grayscale: `1` = fully opaque, `0` = fully transparent.
|
|
2008
|
+
*/
|
|
2009
|
+
interface SoftMaskBuilder {
|
|
2010
|
+
/**
|
|
2011
|
+
* Draw a filled rectangle at the given position with the specified
|
|
2012
|
+
* grayscale value (`0` = black/transparent, `1` = white/opaque).
|
|
2013
|
+
*/
|
|
2014
|
+
drawRectangle(x: number, y: number, width: number, height: number, gray: number): void;
|
|
2015
|
+
/**
|
|
2016
|
+
* Draw a filled circle at the given center with the specified radius
|
|
2017
|
+
* and grayscale value.
|
|
2018
|
+
*/
|
|
2019
|
+
drawCircle(cx: number, cy: number, radius: number, gray: number): void;
|
|
2020
|
+
/**
|
|
2021
|
+
* Append raw PDF content-stream operators to the mask.
|
|
2022
|
+
*/
|
|
2023
|
+
pushRawOperators(ops: string): void;
|
|
2024
|
+
}
|
|
2025
|
+
/**
|
|
2026
|
+
* Opaque reference to a soft mask Form XObject.
|
|
2027
|
+
*
|
|
2028
|
+
* Created by {@link PdfDocument.createSoftMask} and consumed by
|
|
2029
|
+
* {@link PdfPage.applySoftMask}.
|
|
2030
|
+
*/
|
|
2031
|
+
interface SoftMaskRef {
|
|
2032
|
+
readonly _tag: 'softMask';
|
|
2033
|
+
readonly ref: PdfRef;
|
|
2034
|
+
}
|
|
1806
2035
|
/**
|
|
1807
2036
|
* A single page in a PDF document.
|
|
1808
2037
|
*
|
|
@@ -1831,10 +2060,25 @@ declare class PdfPage {
|
|
|
1831
2060
|
* Used for opacity and other graphics state parameters.
|
|
1832
2061
|
*/
|
|
1833
2062
|
private readonly extGStates;
|
|
2063
|
+
/**
|
|
2064
|
+
* Pattern resources referenced by this page.
|
|
2065
|
+
* Maps a resource name (e.g. `Pat5`) to its indirect reference.
|
|
2066
|
+
* Used for gradient fills and tiling patterns.
|
|
2067
|
+
*/
|
|
2068
|
+
private readonly patterns;
|
|
1834
2069
|
/**
|
|
1835
2070
|
* Counter for ExtGState resource names (`GS1`, `GS2`, ...).
|
|
1836
2071
|
*/
|
|
1837
2072
|
private extGStateCounter;
|
|
2073
|
+
/**
|
|
2074
|
+
* Counter for transparency group XObject resource names (`TG1`, `TG2`, ...).
|
|
2075
|
+
*/
|
|
2076
|
+
private transparencyGroupCounter;
|
|
2077
|
+
/**
|
|
2078
|
+
* Stack of transparency group state. Each entry records the ops length
|
|
2079
|
+
* at the time `beginTransparencyGroup()` was called, plus the options.
|
|
2080
|
+
*/
|
|
2081
|
+
private readonly transparencyGroupStack;
|
|
1838
2082
|
/**
|
|
1839
2083
|
* Cache mapping composite keys (opacity + blend mode) to their ExtGState
|
|
1840
2084
|
* resource names, so the same combination reuses the same graphics state
|
|
@@ -1957,6 +2201,8 @@ declare class PdfPage {
|
|
|
1957
2201
|
registerXObject(name: string, ref: PdfRef): void;
|
|
1958
2202
|
/** @internal Register an ExtGState resource on this page. */
|
|
1959
2203
|
registerExtGState(name: string, ref: PdfRef): void;
|
|
2204
|
+
/** @internal Register a Pattern resource on this page. */
|
|
2205
|
+
registerPattern(name: string, ref: PdfRef): void;
|
|
1960
2206
|
/**
|
|
1961
2207
|
* Set the default font used by {@link drawText} when the `font` option
|
|
1962
2208
|
* is not provided.
|
|
@@ -2360,6 +2606,37 @@ declare class PdfPage {
|
|
|
2360
2606
|
* @param options Drawing options (position, scale, colours).
|
|
2361
2607
|
*/
|
|
2362
2608
|
drawSvgPath(pathData: string, options?: DrawSvgPathOptions): void;
|
|
2609
|
+
/**
|
|
2610
|
+
* Draw a gradient fill (linear or radial) clipped to a rectangle.
|
|
2611
|
+
*
|
|
2612
|
+
* The gradient is registered as a `/Pattern` resource on this page
|
|
2613
|
+
* and painted within the specified rectangular region.
|
|
2614
|
+
*
|
|
2615
|
+
* @param gradient A gradient descriptor from {@link linearGradient}
|
|
2616
|
+
* or {@link radialGradient}.
|
|
2617
|
+
* @param rect The rectangle to fill.
|
|
2618
|
+
*/
|
|
2619
|
+
drawGradient(gradient: GradientFill, rect: {
|
|
2620
|
+
x: number;
|
|
2621
|
+
y: number;
|
|
2622
|
+
width: number;
|
|
2623
|
+
height: number;
|
|
2624
|
+
}): void;
|
|
2625
|
+
/**
|
|
2626
|
+
* Draw a tiling pattern fill clipped to a rectangle.
|
|
2627
|
+
*
|
|
2628
|
+
* The pattern is registered as a `/Pattern` resource on this page
|
|
2629
|
+
* and painted within the specified rectangular region.
|
|
2630
|
+
*
|
|
2631
|
+
* @param pattern A pattern descriptor from {@link tilingPattern}.
|
|
2632
|
+
* @param rect The rectangle to fill.
|
|
2633
|
+
*/
|
|
2634
|
+
drawPattern(pattern: PatternFill, rect: {
|
|
2635
|
+
x: number;
|
|
2636
|
+
y: number;
|
|
2637
|
+
width: number;
|
|
2638
|
+
height: number;
|
|
2639
|
+
}): void;
|
|
2363
2640
|
/**
|
|
2364
2641
|
* Begin layer-specific content.
|
|
2365
2642
|
*
|
|
@@ -2376,6 +2653,64 @@ declare class PdfPage {
|
|
|
2376
2653
|
* Must be preceded by a call to {@link beginLayer}.
|
|
2377
2654
|
*/
|
|
2378
2655
|
endLayer(): void;
|
|
2656
|
+
/**
|
|
2657
|
+
* Begin a transparency group. All drawing operations until
|
|
2658
|
+
* {@link endTransparencyGroup} will be captured and composited as a
|
|
2659
|
+
* single Form XObject with a `/Group` transparency dictionary.
|
|
2660
|
+
*
|
|
2661
|
+
* Transparency groups enable isolated and knockout compositing effects
|
|
2662
|
+
* that are not possible with simple opacity settings.
|
|
2663
|
+
*
|
|
2664
|
+
* Groups can be nested — each call must be paired with a matching
|
|
2665
|
+
* {@link endTransparencyGroup}.
|
|
2666
|
+
*
|
|
2667
|
+
* @param options Isolation, knockout, and color-space settings.
|
|
2668
|
+
*
|
|
2669
|
+
* @example
|
|
2670
|
+
* ```ts
|
|
2671
|
+
* page.beginTransparencyGroup({ isolated: true });
|
|
2672
|
+
* page.drawRectangle({ x: 50, y: 50, width: 100, height: 100, opacity: 0.5 });
|
|
2673
|
+
* page.drawCircle({ x: 100, y: 100, size: 60, opacity: 0.5 });
|
|
2674
|
+
* page.endTransparencyGroup();
|
|
2675
|
+
* ```
|
|
2676
|
+
*/
|
|
2677
|
+
beginTransparencyGroup(options?: TransparencyGroupOptions): void;
|
|
2678
|
+
/**
|
|
2679
|
+
* End the current transparency group and composite it onto the page
|
|
2680
|
+
* as a Form XObject.
|
|
2681
|
+
*
|
|
2682
|
+
* @throws {Error} If there is no matching {@link beginTransparencyGroup}.
|
|
2683
|
+
*/
|
|
2684
|
+
endTransparencyGroup(): void;
|
|
2685
|
+
/**
|
|
2686
|
+
* Apply a soft mask (luminosity-based) for subsequent drawing operations.
|
|
2687
|
+
*
|
|
2688
|
+
* White regions in the mask are fully opaque; black regions are fully
|
|
2689
|
+
* transparent. The mask stays active until {@link clearSoftMask} is
|
|
2690
|
+
* called or the graphics state is restored.
|
|
2691
|
+
*
|
|
2692
|
+
* @param mask A soft mask reference created by
|
|
2693
|
+
* {@link PdfDocument.createSoftMask}.
|
|
2694
|
+
*
|
|
2695
|
+
* @example
|
|
2696
|
+
* ```ts
|
|
2697
|
+
* const mask = doc.createSoftMask(200, 200, (b) => {
|
|
2698
|
+
* b.drawRectangle(0, 0, 200, 200, 1); // white = opaque
|
|
2699
|
+
* b.drawCircle(100, 100, 80, 0); // black = transparent
|
|
2700
|
+
* });
|
|
2701
|
+
* page.applySoftMask(mask);
|
|
2702
|
+
* page.drawImage(image, { x: 50, y: 50, width: 200, height: 200 });
|
|
2703
|
+
* page.clearSoftMask();
|
|
2704
|
+
* ```
|
|
2705
|
+
*/
|
|
2706
|
+
applySoftMask(mask: SoftMaskRef): void;
|
|
2707
|
+
/**
|
|
2708
|
+
* Clear the current soft mask, resetting to no masking.
|
|
2709
|
+
*
|
|
2710
|
+
* This emits an ExtGState with `/SMask /None`, which removes any
|
|
2711
|
+
* previously applied soft mask for subsequent drawing operations.
|
|
2712
|
+
*/
|
|
2713
|
+
clearSoftMask(): void;
|
|
2379
2714
|
/**
|
|
2380
2715
|
* Mark a rectangular region on this page for redaction.
|
|
2381
2716
|
*
|
|
@@ -2693,7 +3028,7 @@ interface LoadPdfOptions {
|
|
|
2693
3028
|
* string.
|
|
2694
3029
|
*
|
|
2695
3030
|
* This is the primary entry point for parsing existing PDFs. It creates
|
|
2696
|
-
* a
|
|
3031
|
+
* a `PdfDocumentParser`, runs the full parse pipeline, and returns
|
|
2697
3032
|
* a populated {@link PdfDocument}.
|
|
2698
3033
|
*
|
|
2699
3034
|
* @param data The PDF data as a `Uint8Array`, `ArrayBuffer`, or a
|
|
@@ -4393,12 +4728,6 @@ declare class PdfDocument {
|
|
|
4393
4728
|
* @internal
|
|
4394
4729
|
*/
|
|
4395
4730
|
private embedCffFont;
|
|
4396
|
-
/**
|
|
4397
|
-
* Build a /ToUnicode CMap from the font's cmap table.
|
|
4398
|
-
* Maps glyph IDs (used as CIDs with Identity-H) to Unicode codepoints.
|
|
4399
|
-
* @internal
|
|
4400
|
-
*/
|
|
4401
|
-
private buildToUnicodeCmap;
|
|
4402
4731
|
/**
|
|
4403
4732
|
* Embed a PNG image.
|
|
4404
4733
|
*
|
|
@@ -4809,6 +5138,37 @@ declare class PdfDocument {
|
|
|
4809
5138
|
* @param options Watermark appearance options.
|
|
4810
5139
|
*/
|
|
4811
5140
|
addWatermark(options: WatermarkOptions): void;
|
|
5141
|
+
/**
|
|
5142
|
+
* Create a soft mask Form XObject that can be used with
|
|
5143
|
+
* {@link PdfPage.applySoftMask}.
|
|
5144
|
+
*
|
|
5145
|
+
* The builder callback receives a {@link SoftMaskBuilder} with methods
|
|
5146
|
+
* for generating grayscale content where white (`1`) represents fully
|
|
5147
|
+
* opaque regions and black (`0`) represents fully transparent regions.
|
|
5148
|
+
*
|
|
5149
|
+
* The returned {@link SoftMaskRef} is passed to
|
|
5150
|
+
* {@link PdfPage.applySoftMask} to activate the mask for subsequent
|
|
5151
|
+
* drawing operations on that page.
|
|
5152
|
+
*
|
|
5153
|
+
* @param width Width of the mask in points.
|
|
5154
|
+
* @param height Height of the mask in points.
|
|
5155
|
+
* @param builder Callback that draws the mask content.
|
|
5156
|
+
* @returns A reference to the soft mask Form XObject.
|
|
5157
|
+
*
|
|
5158
|
+
* @example
|
|
5159
|
+
* ```ts
|
|
5160
|
+
* const mask = doc.createSoftMask(200, 200, (b) => {
|
|
5161
|
+
* // White background = fully opaque
|
|
5162
|
+
* b.drawRectangle(0, 0, 200, 200, 1);
|
|
5163
|
+
* // Black circle = fully transparent hole
|
|
5164
|
+
* b.drawCircle(100, 100, 80, 0);
|
|
5165
|
+
* });
|
|
5166
|
+
* page.applySoftMask(mask);
|
|
5167
|
+
* page.drawRectangle({ x: 50, y: 50, width: 200, height: 200, color: rgb(1, 0, 0) });
|
|
5168
|
+
* page.clearSoftMask();
|
|
5169
|
+
* ```
|
|
5170
|
+
*/
|
|
5171
|
+
createSoftMask(width: number, height: number, builder: (ops: SoftMaskBuilder) => void): SoftMaskRef;
|
|
4812
5172
|
/**
|
|
4813
5173
|
* Apply all pending redactions across all pages.
|
|
4814
5174
|
*
|
|
@@ -5466,7 +5826,7 @@ interface SubsetCmap {
|
|
|
5466
5826
|
* Tracks which glyphs have been used so that subsetting can be
|
|
5467
5827
|
* performed at save time, and provides text measurement methods.
|
|
5468
5828
|
*
|
|
5469
|
-
* Create via
|
|
5829
|
+
* Create via `PdfDocument.embedFont()`.
|
|
5470
5830
|
*/
|
|
5471
5831
|
declare class EmbeddedFont {
|
|
5472
5832
|
/** The raw font file bytes. */
|
|
@@ -7254,6 +7614,29 @@ declare function extractTextWithPositions(operators: ContentStreamOperator[], re
|
|
|
7254
7614
|
*/
|
|
7255
7615
|
declare function decodeStream(data: Uint8Array, filters: string | string[], decodeParms?: PdfDict | PdfDict[] | null): Uint8Array;
|
|
7256
7616
|
//#endregion
|
|
7617
|
+
//#region src/parser/parseError.d.ts
|
|
7618
|
+
/**
|
|
7619
|
+
* @module parser/parseError
|
|
7620
|
+
* Structured error class for PDF parsing failures.
|
|
7621
|
+
* @packageDocumentation
|
|
7622
|
+
*/
|
|
7623
|
+
declare class PdfParseError extends Error {
|
|
7624
|
+
readonly name = "PdfParseError";
|
|
7625
|
+
readonly offset: number;
|
|
7626
|
+
readonly expected: string;
|
|
7627
|
+
readonly actual: string;
|
|
7628
|
+
readonly hexContext: string;
|
|
7629
|
+
constructor(options: {
|
|
7630
|
+
message: string;
|
|
7631
|
+
offset: number;
|
|
7632
|
+
expected?: string | undefined;
|
|
7633
|
+
actual?: string | undefined;
|
|
7634
|
+
data?: Uint8Array | undefined;
|
|
7635
|
+
cause?: Error | undefined;
|
|
7636
|
+
});
|
|
7637
|
+
}
|
|
7638
|
+
declare function formatHexContext(data: Uint8Array, offset: number, windowSize?: number): string;
|
|
7639
|
+
//#endregion
|
|
7257
7640
|
//#region src/signature/byteRange.d.ts
|
|
7258
7641
|
/**
|
|
7259
7642
|
* @module signature/byteRange
|
|
@@ -7900,5 +8283,5 @@ interface InitWasmOptions {
|
|
|
7900
8283
|
*/
|
|
7901
8284
|
declare function initWasm(options?: string | URL | InitWasmOptions): Promise<void>;
|
|
7902
8285
|
//#endregion
|
|
7903
|
-
export { type AccessibilityIssue, type Angle, AnnotationFlags, type AnnotationOptions, type AnnotationType, type AppearanceProviderFor, BlendMode, type ButtonAppearanceOptions, type ByteRangeResult, type ByteWriter, type CatalogOptions, ChangeTracker, type CheckboxAppearanceOptions, type CmykColor, type Color, CombedTextLayoutError, type ComputeFontSizeOptions, type ContentStreamOperator, type CropBox, type Degrees, type DocumentMetadata, type DocumentStructure, type DrawCircleOptions, type DrawEllipseOptions, type DrawImageOptions, type DrawLineOptions, type DrawPageOptions, type DrawRectangleOptions, type DrawSquareOptions, type DrawSvgPathOptions, type DrawTextOptions, type DropdownAppearanceOptions, type EmbedFontOptions, type EmbedPageOptions, type EmbeddedFile, EmbeddedFont, type EmbeddedPdfPage, type EncryptAlgorithm, type EncryptDictValues, type EncryptOptions, EncryptedPdfError, ExceededMaxLengthError, FieldAlreadyExistsError, FieldExistsAsNonTerminalError, FieldFlags, type FieldType, type FontMetrics, FontNotEmbeddedError, type FontRef, ForeignPageError, type FreeTextAlignment, type GrayscaleColor, ImageAlignment, type ImageRef, type IncrementalSaveResult, InitWasmOptions, InvalidFieldNamePartError, type LayoutCombedOptions, type LayoutMultilineOptions, type LayoutMultilineResult, type LayoutSinglelineOptions, type LayoutSinglelineResult, LineCapStyle, type LineEndingStyle, LineJoinStyle, type LinearizationOptions, type LinkHighlightMode, type ListboxAppearanceOptions, type LoadPdfOptions, type MarkedContentScope, MissingOnValueCheckError, NoSuchFieldError, type Operand, type OutlineDestination, type OutlineItemOptions, PDFOperator, type PageEntry, type PageRange, type PageSize, PageSizes, ParseSpeeds, type PdfAIssue, type PdfALevel, type PdfAValidationResult, PdfAnnotation, PdfArray, PdfBool, PdfButtonField, PdfCheckboxField, PdfCircleAnnotation, PdfDict, PdfDocument, PdfDropdownField, PdfEncryptionHandler, PdfField, PdfForm, PdfFreeTextAnnotation, PdfHighlightAnnotation, PdfInkAnnotation, PdfLayer, PdfLayerManager, PdfLineAnnotation, PdfLinkAnnotation, PdfListboxField, PdfName, PdfNull, PdfNumber, type PdfObject, PdfObjectRegistry, PdfOutlineItem, PdfOutlineTree, PdfPage, type PdfPermissionFlags, PdfPolyLineAnnotation, PdfPolygonAnnotation, PdfRadioGroup, PdfRedactAnnotation, PdfRef, type PdfSaveOptions, PdfSignatureField, type PdfSignatureInfo, PdfSquareAnnotation, PdfSquigglyAnnotation, PdfStampAnnotation, PdfStream, PdfStreamWriter, PdfStrikeOutAnnotation, PdfString, PdfStructureElement, PdfStructureTree, PdfTextAnnotation, PdfTextField, PdfUnderlineAnnotation, PdfViewerPreferences, PdfWriter, type Radians, type RadioAppearanceOptions, type RedactionOptions, type RefResolver, type RegistryEntry, RemovePageFromEmptyDocumentError, type RgbColor, RichTextFieldReadError, type SetTitleOptions, type SignOptions, type SignatureAppearanceOptions, type SignatureOptions, type SignatureVerificationResult, type SignerInfo, type StandardFontName, StandardFonts, type StandardStampName, type StructureElementOptions, type StructureType, type SvgDrawCommand, type SvgElement, type SvgRenderOptions, TextAlignment, type TextAnnotationIcon, type TextAppearanceOptions, type TextItem, TextRenderingMode, type TimestampResult, UnexpectedFieldTypeError, type ViewerPreferences, type WatermarkOptions, type WidgetAnnotationHost, addWatermark, addWatermarkToPage, aesDecryptCBC, aesEncryptCBC, annotationFromDict, applyFillColor, applyRedactions, applyStrokeColor, asNumber, asPDFName, asPDFNumber, attachFile, base64Decode, base64Encode, beginArtifact, beginArtifactWithType, beginLayerContent, beginMarkedContent, beginMarkedContentSequence, beginMarkedContentWithProperties, beginText, buildAnnotationDict, buildCatalog, buildDocumentStructure, buildEmbeddedFilesNameTree, buildInfoDict, buildPageTree, buildPkcs7Signature, buildTimestampRequest, buildViewerPreferencesDict, buildXmpMetadata, checkAccessibility, circlePath, clipEvenOdd, clip as clipOp, closeAndStroke, closeFillAndStroke, closeFillEvenOddAndStroke, closePath as closePathOp, cmyk, colorToComponents, componentsToColor, computeFileEncryptionKey, computeFontSize, computeSignatureHash, concatMatrix, concatMatrix as concatTransformationMatrix, copyPages, createAnnotation, createMarkedContentScope, createPdf, createXmpStream, cropPage, curveToFinal, curveToInitial, curveTo as curveToOp, decodePermissions, decodeStream, degrees, degreesToRadians, drawImageWithMatrix, drawImageXObject, drawXObject as drawObject, drawXObject, drawSvgOnPage, ellipsePath, embedPageAsFormXObject, embedSignature, encodeContextTag, encodeInteger, encodeLength, encodeOID, encodeOctetString, encodePermissions, encodePrintableString, encodeSequence, encodeSet, encodeUTCTime, encodeUtf8String, endArtifact, endLayerContent, endMarkedContent, endPath as endPathOp, endText, enforcePdfA, extractMetrics, extractText, extractTextWithPositions, fillAndStroke as fillAndStrokeOp, fillEvenOdd, fillEvenOddAndStroke, fill as fillOp, findSignatures, formatPdfDate, generateButtonAppearance, generateCheckboxAppearance, generateCircleAppearance, generateDropdownAppearance, generateFreeTextAppearance, generateHighlightAppearance, generateInkAppearance, generateLineAppearance, generateListboxAppearance, generateRadioAppearance, generateSignatureAppearance, generateSquareAppearance, generateSquigglyAppearance, generateStrikeOutAppearance, generateTextAppearance, generateUnderlineAppearance, getAttachments, getPageSize, getRedactionMarks, getSignatures, grayscale, initWasm, insertPage, isAccessible, isLinearized, isOpenTypeCFF, isTrueType, layoutCombedText, layoutMultilineText, layoutSinglelineText, lineTo as lineToOp, linearizePdf, loadPdf, markForRedaction, md5, mergePdfs, movePage, moveText as moveTextOp, moveTextSetLeading, moveTo as moveToOp, nextLine as nextLineOp, parseContentStream, parseSvg, parseSvgColor, parseSvgPath, parseSvgTransform, parseTimestampResponse, parseViewerPreferences, parseXmpMetadata, restoreState as popGraphicsState, restoreState, prepareForSigning, saveState as pushGraphicsState, saveState, radians, radiansToDegrees, rc4, rectangle as rectangleOp, removePage, removePages, requestTimestamp, resizePage, reversePages, rgb, rotateAllPages, rotate as rotateOp, rotatePage, rotationMatrix, saveDocumentIncremental, saveIncremental, scale as scaleOp, serializePdf, setCharacterSpacing as setCharacterSpacingOp, setCharacterSpacing as setCharacterSqueeze, setColorSpace, setDashPattern as setDashPatternOp, setFillColor, setFillColorCmyk, setFillColorGray, setFillColorRgb, setFillingColor, setFlatness, setFont as setFontAndSize, setFont as setFontOp, setFontSize as setFontSizeOp, setGraphicsState as setGraphicsStateOp, setLeading as setLeadingOp, setLeading as setLineHeight, setLineCap as setLineCapOp, setLineJoin as setLineJoinOp, setLineWidth as setLineWidthOp, setMiterLimit, setStrokeColor, setStrokeColorCmyk, setStrokeColorGray, setStrokeColorRgb, setStrokeColorSpace, setStrokingColor, setTextMatrix as setTextMatrixOp, setTextRenderingMode as setTextRenderingModeOp, setTextRise as setTextRiseOp, setWordSpacing as setWordSpacingOp, sha256, sha384, sha512, showTextArray, showTextHex, showTextNextLine, showText as showTextOp, showTextWithSpacing, signPdf, skew as skewOp, splitPdf, stroke as strokeOp, summarizeIssues, svgToPdfOperators, translate as translateOp, validatePdfA, verifyOwnerPassword, verifySignature, verifySignatures, verifyUserPassword, wrapInMarkedContent };
|
|
8286
|
+
export { type AccessibilityIssue, type Angle, AnnotationFlags, type AnnotationOptions, type AnnotationType, type AppearanceProviderFor, BlendMode, type ButtonAppearanceOptions, type ByteRangeResult, type ByteWriter, type CIDFontData, type CIDSystemInfoData, type CatalogOptions, ChangeTracker, type CheckboxAppearanceOptions, type CmykColor, type Color, type ColorStop, CombedTextLayoutError, type ComputeFontSizeOptions, type ContentStreamOperator, type CropBox, type Degrees, type DocumentMetadata, type DocumentStructure, type DrawCircleOptions, type DrawEllipseOptions, type DrawImageOptions, type DrawLineOptions, type DrawPageOptions, type DrawRectangleOptions, type DrawSquareOptions, type DrawSvgPathOptions, type DrawTextOptions, type DropdownAppearanceOptions, type EmbedFontOptions, type EmbedPageOptions, type EmbeddedFile, EmbeddedFont, type EmbeddedPdfPage, type EncryptAlgorithm, type EncryptDictValues, type EncryptOptions, EncryptedPdfError, ExceededMaxLengthError, FieldAlreadyExistsError, FieldExistsAsNonTerminalError, FieldFlags, type FieldType, type FontDescriptorData, type FontEmbeddingResult, type FontMetrics, FontNotEmbeddedError, type FontRef, ForeignPageError, type FreeTextAlignment, type GradientFill, type GrayscaleColor, ImageAlignment, type ImageRef, type IncrementalSaveResult, InitWasmOptions, InvalidFieldNamePartError, type LayoutCombedOptions, type LayoutMultilineOptions, type LayoutMultilineResult, type LayoutSinglelineOptions, type LayoutSinglelineResult, LineCapStyle, type LineEndingStyle, LineJoinStyle, type LinearGradientOptions, type LinearizationOptions, type LinkHighlightMode, type ListboxAppearanceOptions, type LoadPdfOptions, type MarkedContentScope, MissingOnValueCheckError, NoSuchFieldError, type NormalizedStop, type Operand, type OutlineDestination, type OutlineItemOptions, PDFOperator, type PageEntry, type PageRange, type PageSize, PageSizes, ParseSpeeds, type PatternFill, type PdfAIssue, type PdfALevel, type PdfAValidationResult, PdfAnnotation, PdfArray, PdfBool, PdfButtonField, PdfCheckboxField, PdfCircleAnnotation, PdfDict, PdfDocument, PdfDropdownField, PdfEncryptionHandler, PdfField, PdfForm, PdfFreeTextAnnotation, PdfHighlightAnnotation, PdfInkAnnotation, PdfLayer, PdfLayerManager, PdfLineAnnotation, PdfLinkAnnotation, PdfListboxField, PdfName, PdfNull, PdfNumber, type PdfObject, PdfObjectRegistry, PdfOutlineItem, PdfOutlineTree, PdfPage, PdfParseError, type PdfPermissionFlags, PdfPolyLineAnnotation, PdfPolygonAnnotation, PdfRadioGroup, PdfRedactAnnotation, PdfRef, type PdfSaveOptions, PdfSignatureField, type PdfSignatureInfo, PdfSquareAnnotation, PdfSquigglyAnnotation, PdfStampAnnotation, PdfStream, PdfStreamWriter, PdfStrikeOutAnnotation, PdfString, PdfStructureElement, PdfStructureTree, PdfTextAnnotation, PdfTextField, PdfUnderlineAnnotation, PdfViewerPreferences, PdfWriter, type RadialGradientFill, type RadialGradientOptions, type Radians, type RadioAppearanceOptions, type RedactionMark, type RedactionOptions, type RefResolver, type RegistryEntry, RemovePageFromEmptyDocumentError, type RgbColor, RichTextFieldReadError, type SetTitleOptions, type SignOptions, type SignatureAppearanceOptions, type SignatureOptions, type SignatureVerificationResult, type SignerInfo, type SoftMaskBuilder, type SoftMaskRef, type StandardFontName, StandardFonts, type StandardStampName, type StructureElementOptions, type StructureType, type SubsetCmap, type SubsetResult, type SvgDrawCommand, type SvgElement, type SvgRenderOptions, TextAlignment, type TextAnnotationIcon, type TextAppearanceOptions, type TextExtractionOptions, type TextItem, TextRenderingMode, type TilingPatternOptions, type TimestampResult, type TransparencyGroupOptions, type Type0FontData, UnexpectedFieldTypeError, type ViewerPreferences, type WatermarkOptions, type WidgetAnnotationHost, type WidthEntry, addWatermark, addWatermarkToPage, aesDecryptCBC, aesEncryptCBC, annotationFromDict, applyFillColor, applyRedactions, applyStrokeColor, asNumber, asPDFName, asPDFNumber, attachFile, base64Decode, base64Encode, beginArtifact, beginArtifactWithType, beginLayerContent, beginMarkedContent, beginMarkedContentSequence, beginMarkedContentWithProperties, beginText, buildAnnotationDict, buildCatalog, buildDocumentStructure, buildEmbeddedFilesNameTree, buildGradientObjects, buildInfoDict, buildPageTree, buildPatternObjects, buildPkcs7Signature, buildTimestampRequest, buildViewerPreferencesDict, buildXmpMetadata, checkAccessibility, circlePath, clipEvenOdd, clip as clipOp, closeAndStroke, closeFillAndStroke, closeFillEvenOddAndStroke, closePath as closePathOp, cmyk, colorToComponents, componentsToColor, computeFileEncryptionKey, computeFontSize, computeSignatureHash, concatMatrix, concatMatrix as concatTransformationMatrix, copyPages, createAnnotation, createMarkedContentScope, createPdf, createXmpStream, cropPage, curveToFinal, curveToInitial, curveTo as curveToOp, decodePermissions, decodeStream, degrees, degreesToRadians, drawImageWithMatrix, drawImageXObject, drawXObject as drawObject, drawXObject, drawSvgOnPage, ellipsePath, embedPageAsFormXObject, embedSignature, encodeContextTag, encodeInteger, encodeLength, encodeOID, encodeOctetString, encodePermissions, encodePrintableString, encodeSequence, encodeSet, encodeUTCTime, encodeUtf8String, endArtifact, endLayerContent, endMarkedContent, endPath as endPathOp, endText, enforcePdfA, extractMetrics, extractText, extractTextWithPositions, fillAndStroke as fillAndStrokeOp, fillEvenOdd, fillEvenOddAndStroke, fill as fillOp, findSignatures, formatHexContext, formatPdfDate, generateButtonAppearance, generateCheckboxAppearance, generateCircleAppearance, generateDropdownAppearance, generateFreeTextAppearance, generateHighlightAppearance, generateInkAppearance, generateLineAppearance, generateListboxAppearance, generateRadioAppearance, generateSignatureAppearance, generateSquareAppearance, generateSquigglyAppearance, generateStrikeOutAppearance, generateTextAppearance, generateUnderlineAppearance, getAttachments, getPageSize, getRedactionMarks, getSignatures, grayscale, initWasm, insertPage, isAccessible, isLinearized, isOpenTypeCFF, isTrueType, layoutCombedText, layoutMultilineText, layoutSinglelineText, lineTo as lineToOp, linearGradient, linearizePdf, loadPdf, markForRedaction, md5, mergePdfs, movePage, moveText as moveTextOp, moveTextSetLeading, moveTo as moveToOp, nextLine as nextLineOp, parseContentStream, parseSvg, parseSvgColor, parseSvgPath, parseSvgTransform, parseTimestampResponse, parseViewerPreferences, parseXmpMetadata, restoreState as popGraphicsState, restoreState, prepareForSigning, saveState as pushGraphicsState, saveState, radialGradient, radians, radiansToDegrees, rc4, rectangle as rectangleOp, removePage, removePages, requestTimestamp, resizePage, reversePages, rgb, rotateAllPages, rotate as rotateOp, rotatePage, rotationMatrix, saveDocumentIncremental, saveIncremental, scale as scaleOp, serializePdf, setCharacterSpacing as setCharacterSpacingOp, setCharacterSpacing as setCharacterSqueeze, setColorSpace, setDashPattern as setDashPatternOp, setFillColor, setFillColorCmyk, setFillColorGray, setFillColorRgb, setFillingColor, setFlatness, setFont as setFontAndSize, setFont as setFontOp, setFontSize as setFontSizeOp, setGraphicsState as setGraphicsStateOp, setLeading as setLeadingOp, setLeading as setLineHeight, setLineCap as setLineCapOp, setLineJoin as setLineJoinOp, setLineWidth as setLineWidthOp, setMiterLimit, setStrokeColor, setStrokeColorCmyk, setStrokeColorGray, setStrokeColorRgb, setStrokeColorSpace, setStrokingColor, setTextMatrix as setTextMatrixOp, setTextRenderingMode as setTextRenderingModeOp, setTextRise as setTextRiseOp, setWordSpacing as setWordSpacingOp, sha256, sha384, sha512, showTextArray, showTextHex, showTextNextLine, showText as showTextOp, showTextWithSpacing, signPdf, skew as skewOp, splitPdf, stroke as strokeOp, summarizeIssues, svgToPdfOperators, tilingPattern, translate as translateOp, validatePdfA, verifyOwnerPassword, verifySignature, verifySignatures, verifyUserPassword, wrapInMarkedContent };
|
|
7904
8287
|
//# sourceMappingURL=index.d.cts.map
|