@qrcommunication/gigapdf-lib 0.68.0 → 0.69.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/CHANGELOG.md +18 -0
- package/dist/index.cjs +43 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1567,6 +1567,30 @@ declare class GigaPdfDoc {
|
|
|
1567
1567
|
* user space. PNG alpha is honoured; `opacity` (0..1) sets an overall alpha.
|
|
1568
1568
|
*/
|
|
1569
1569
|
addImage(page: number, data: Uint8Array, x: number, y: number, w: number, h: number, opacity?: number): boolean;
|
|
1570
|
+
/**
|
|
1571
|
+
* Stamp an **image watermark** across pages from raw image bytes. Accepts the
|
|
1572
|
+
* same five formats the engine decodes — **PNG, JPEG, WebP, GIF, AVIF**. The
|
|
1573
|
+
* image is embedded **once** and referenced on every target page.
|
|
1574
|
+
*
|
|
1575
|
+
* `opts.pages` is a list of 1-based page numbers; omit it (or pass `[]`) to
|
|
1576
|
+
* stamp every page. `opts.anchor` positions the image (`'center'` default, or a
|
|
1577
|
+
* corner) and `opts.offsetX`/`offsetY` nudge it (in points; in `tile` mode they
|
|
1578
|
+
* become the gaps between tiles). `opts.width`/`height` set the target size in
|
|
1579
|
+
* points (height keeps the source aspect ratio when omitted). `opts.rotationDeg`
|
|
1580
|
+
* rotates about the image centre and `opts.opacity` (0–1) sets the alpha.
|
|
1581
|
+
* Returns `false` if the image can't be decoded.
|
|
1582
|
+
*/
|
|
1583
|
+
addImageWatermark(data: Uint8Array, opts?: {
|
|
1584
|
+
pages?: number[];
|
|
1585
|
+
anchor?: 'center' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
1586
|
+
offsetX?: number;
|
|
1587
|
+
offsetY?: number;
|
|
1588
|
+
width?: number;
|
|
1589
|
+
height?: number;
|
|
1590
|
+
rotationDeg?: number;
|
|
1591
|
+
opacity?: number;
|
|
1592
|
+
tile?: boolean;
|
|
1593
|
+
}): boolean;
|
|
1570
1594
|
/**
|
|
1571
1595
|
* Draw SVG markup on a page as **native vector paths** (crisp at any zoom, not
|
|
1572
1596
|
* rasterized), fitting its `viewBox` into the box `(x, y, w, h)` in PDF points
|
package/dist/index.d.ts
CHANGED
|
@@ -1567,6 +1567,30 @@ declare class GigaPdfDoc {
|
|
|
1567
1567
|
* user space. PNG alpha is honoured; `opacity` (0..1) sets an overall alpha.
|
|
1568
1568
|
*/
|
|
1569
1569
|
addImage(page: number, data: Uint8Array, x: number, y: number, w: number, h: number, opacity?: number): boolean;
|
|
1570
|
+
/**
|
|
1571
|
+
* Stamp an **image watermark** across pages from raw image bytes. Accepts the
|
|
1572
|
+
* same five formats the engine decodes — **PNG, JPEG, WebP, GIF, AVIF**. The
|
|
1573
|
+
* image is embedded **once** and referenced on every target page.
|
|
1574
|
+
*
|
|
1575
|
+
* `opts.pages` is a list of 1-based page numbers; omit it (or pass `[]`) to
|
|
1576
|
+
* stamp every page. `opts.anchor` positions the image (`'center'` default, or a
|
|
1577
|
+
* corner) and `opts.offsetX`/`offsetY` nudge it (in points; in `tile` mode they
|
|
1578
|
+
* become the gaps between tiles). `opts.width`/`height` set the target size in
|
|
1579
|
+
* points (height keeps the source aspect ratio when omitted). `opts.rotationDeg`
|
|
1580
|
+
* rotates about the image centre and `opts.opacity` (0–1) sets the alpha.
|
|
1581
|
+
* Returns `false` if the image can't be decoded.
|
|
1582
|
+
*/
|
|
1583
|
+
addImageWatermark(data: Uint8Array, opts?: {
|
|
1584
|
+
pages?: number[];
|
|
1585
|
+
anchor?: 'center' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
1586
|
+
offsetX?: number;
|
|
1587
|
+
offsetY?: number;
|
|
1588
|
+
width?: number;
|
|
1589
|
+
height?: number;
|
|
1590
|
+
rotationDeg?: number;
|
|
1591
|
+
opacity?: number;
|
|
1592
|
+
tile?: boolean;
|
|
1593
|
+
}): boolean;
|
|
1570
1594
|
/**
|
|
1571
1595
|
* Draw SVG markup on a page as **native vector paths** (crisp at any zoom, not
|
|
1572
1596
|
* rasterized), fitting its `viewBox` into the box `(x, y, w, h)` in PDF points
|
package/dist/index.js
CHANGED
|
@@ -1214,6 +1214,49 @@ var GigaPdfDoc = class {
|
|
|
1214
1214
|
(p, l) => this.ex().gp_add_image(this.h, page, p, l, x, y, w, h, opacity)
|
|
1215
1215
|
) === 0;
|
|
1216
1216
|
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Stamp an **image watermark** across pages from raw image bytes. Accepts the
|
|
1219
|
+
* same five formats the engine decodes — **PNG, JPEG, WebP, GIF, AVIF**. The
|
|
1220
|
+
* image is embedded **once** and referenced on every target page.
|
|
1221
|
+
*
|
|
1222
|
+
* `opts.pages` is a list of 1-based page numbers; omit it (or pass `[]`) to
|
|
1223
|
+
* stamp every page. `opts.anchor` positions the image (`'center'` default, or a
|
|
1224
|
+
* corner) and `opts.offsetX`/`offsetY` nudge it (in points; in `tile` mode they
|
|
1225
|
+
* become the gaps between tiles). `opts.width`/`height` set the target size in
|
|
1226
|
+
* points (height keeps the source aspect ratio when omitted). `opts.rotationDeg`
|
|
1227
|
+
* rotates about the image centre and `opts.opacity` (0–1) sets the alpha.
|
|
1228
|
+
* Returns `false` if the image can't be decoded.
|
|
1229
|
+
*/
|
|
1230
|
+
addImageWatermark(data, opts = {}) {
|
|
1231
|
+
const anchorTag = {
|
|
1232
|
+
center: 0,
|
|
1233
|
+
"top-left": 1,
|
|
1234
|
+
"top-right": 2,
|
|
1235
|
+
"bottom-left": 3,
|
|
1236
|
+
"bottom-right": 4
|
|
1237
|
+
}[opts.anchor ?? "center"];
|
|
1238
|
+
const pages = opts.pages ?? [];
|
|
1239
|
+
const call = (pp, pc) => this.g._withBytes(
|
|
1240
|
+
data,
|
|
1241
|
+
(p, l) => this.ex().gp_add_image_watermark(
|
|
1242
|
+
this.h,
|
|
1243
|
+
p,
|
|
1244
|
+
l,
|
|
1245
|
+
pp,
|
|
1246
|
+
pc,
|
|
1247
|
+
anchorTag,
|
|
1248
|
+
opts.offsetX ?? 0,
|
|
1249
|
+
opts.offsetY ?? 0,
|
|
1250
|
+
opts.width ?? 0,
|
|
1251
|
+
opts.height ?? 0,
|
|
1252
|
+
opts.rotationDeg ?? 0,
|
|
1253
|
+
opts.opacity ?? 0.25,
|
|
1254
|
+
opts.tile ? 1 : 0
|
|
1255
|
+
)
|
|
1256
|
+
);
|
|
1257
|
+
const rc = pages.length === 0 ? call(0, 0) : this.g._withU32(pages, (pp, pc) => call(pp, pc));
|
|
1258
|
+
return rc === 0;
|
|
1259
|
+
}
|
|
1217
1260
|
/**
|
|
1218
1261
|
* Draw SVG markup on a page as **native vector paths** (crisp at any zoom, not
|
|
1219
1262
|
* rasterized), fitting its `viewBox` into the box `(x, y, w, h)` in PDF points
|