@qrcommunication/gigapdf-lib 0.57.0 → 0.58.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 +49 -0
- package/README.md +6 -2
- package/dist/index.cjs +47 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -4
- package/dist/index.d.ts +36 -4
- package/dist/index.js +47 -4
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1043,10 +1043,11 @@ declare class GigaPdfDoc {
|
|
|
1043
1043
|
* in `0..=1`; `dash` is the PDF dash array (`[]` = solid). Returns `false` if
|
|
1044
1044
|
* the element is not a path (or the page/index doesn't exist).
|
|
1045
1045
|
*
|
|
1046
|
-
* Opacity
|
|
1047
|
-
*
|
|
1048
|
-
*
|
|
1049
|
-
*
|
|
1046
|
+
* Opacity: `fillAlpha`/`strokeAlpha` (`0..=1`) are fully supported — an
|
|
1047
|
+
* `/ExtGState` carrying `/ca`/`/CA` is registered on the page and a `/<gs> gs`
|
|
1048
|
+
* is injected into the path's `q … Q` wrap, so the alpha applies to that path
|
|
1049
|
+
* run only. (For non-path elements such as images, use
|
|
1050
|
+
* {@link setElementOpacity}.)
|
|
1050
1051
|
*/
|
|
1051
1052
|
setPathStyle(page: number, index: number, style: {
|
|
1052
1053
|
fill?: [number, number, number];
|
|
@@ -1056,6 +1057,26 @@ declare class GigaPdfDoc {
|
|
|
1056
1057
|
strokeAlpha?: number;
|
|
1057
1058
|
dash?: number[];
|
|
1058
1059
|
}): boolean;
|
|
1060
|
+
/**
|
|
1061
|
+
* Set a constant opacity on element `index` on `page` — text, image **or**
|
|
1062
|
+
* shape — by registering an `/ExtGState` (`/ca` = `/CA` = `fillAlpha`, clamped
|
|
1063
|
+
* to `0..=1`) on the page and wrapping the element's op range in
|
|
1064
|
+
* `q /<gs> gs … Q`. This is the way to set an **image**'s alpha in place;
|
|
1065
|
+
* shapes may also use {@link setPathStyle}'s `fillAlpha`/`strokeAlpha` (same
|
|
1066
|
+
* underlying `/ExtGState` mechanism). Returns `false` if the page/index doesn't
|
|
1067
|
+
* exist.
|
|
1068
|
+
*/
|
|
1069
|
+
setElementOpacity(page: number, index: number, fillAlpha: number): boolean;
|
|
1070
|
+
/**
|
|
1071
|
+
* Change the paint order (z-order) of element `index` on `page`. `toFront`
|
|
1072
|
+
* brings it visually on top (its op range is moved to the end of the content
|
|
1073
|
+
* stream, painted last); otherwise it is sent behind everything (moved to the
|
|
1074
|
+
* start, painted first). The moved range is re-wrapped in `q … Q` so it neither
|
|
1075
|
+
* inherits nor leaks graphics state. Works for text, image and shape elements.
|
|
1076
|
+
* The element's index changes after the move — re-read {@link pageElements}.
|
|
1077
|
+
* Returns `false` if the page/index doesn't exist.
|
|
1078
|
+
*/
|
|
1079
|
+
reorderElement(page: number, index: number, toFront: boolean): boolean;
|
|
1059
1080
|
duplicateElement(page: number, index: number): boolean;
|
|
1060
1081
|
/** Index of the element at page point `(x, y)`, or -1 if none. */
|
|
1061
1082
|
elementAt(page: number, x: number, y: number): number;
|
|
@@ -1196,6 +1217,17 @@ declare class GigaPdfDoc {
|
|
|
1196
1217
|
* text on top of.
|
|
1197
1218
|
*/
|
|
1198
1219
|
renderPageNoText(page: number, scale?: number): Uint8Array;
|
|
1220
|
+
/**
|
|
1221
|
+
* Rasterize a page to a PNG while **omitting** the given top-level element
|
|
1222
|
+
* `indices` (from {@link pageElements}). Each excluded element paints nothing
|
|
1223
|
+
* — fills, strokes, shadings, images and text alike — while everything else
|
|
1224
|
+
* (including the non-text content of non-excluded elements) renders normally.
|
|
1225
|
+
* Use it to paint a background without specific elements and overlay live,
|
|
1226
|
+
* editable versions on top. Generalises {@link renderPageNoText} (which
|
|
1227
|
+
* suppresses *all* text). An empty `indices` renders the full page; unknown
|
|
1228
|
+
* indices are ignored.
|
|
1229
|
+
*/
|
|
1230
|
+
renderPageExcluding(page: number, indices: number[], scale?: number): Uint8Array;
|
|
1199
1231
|
/**
|
|
1200
1232
|
* Embed an outline font program as a Type0 font and return its object number
|
|
1201
1233
|
* (pass to {@link addText} / re-encoded by {@link replaceText}). Accepts
|
package/dist/index.d.ts
CHANGED
|
@@ -1043,10 +1043,11 @@ declare class GigaPdfDoc {
|
|
|
1043
1043
|
* in `0..=1`; `dash` is the PDF dash array (`[]` = solid). Returns `false` if
|
|
1044
1044
|
* the element is not a path (or the page/index doesn't exist).
|
|
1045
1045
|
*
|
|
1046
|
-
* Opacity
|
|
1047
|
-
*
|
|
1048
|
-
*
|
|
1049
|
-
*
|
|
1046
|
+
* Opacity: `fillAlpha`/`strokeAlpha` (`0..=1`) are fully supported — an
|
|
1047
|
+
* `/ExtGState` carrying `/ca`/`/CA` is registered on the page and a `/<gs> gs`
|
|
1048
|
+
* is injected into the path's `q … Q` wrap, so the alpha applies to that path
|
|
1049
|
+
* run only. (For non-path elements such as images, use
|
|
1050
|
+
* {@link setElementOpacity}.)
|
|
1050
1051
|
*/
|
|
1051
1052
|
setPathStyle(page: number, index: number, style: {
|
|
1052
1053
|
fill?: [number, number, number];
|
|
@@ -1056,6 +1057,26 @@ declare class GigaPdfDoc {
|
|
|
1056
1057
|
strokeAlpha?: number;
|
|
1057
1058
|
dash?: number[];
|
|
1058
1059
|
}): boolean;
|
|
1060
|
+
/**
|
|
1061
|
+
* Set a constant opacity on element `index` on `page` — text, image **or**
|
|
1062
|
+
* shape — by registering an `/ExtGState` (`/ca` = `/CA` = `fillAlpha`, clamped
|
|
1063
|
+
* to `0..=1`) on the page and wrapping the element's op range in
|
|
1064
|
+
* `q /<gs> gs … Q`. This is the way to set an **image**'s alpha in place;
|
|
1065
|
+
* shapes may also use {@link setPathStyle}'s `fillAlpha`/`strokeAlpha` (same
|
|
1066
|
+
* underlying `/ExtGState` mechanism). Returns `false` if the page/index doesn't
|
|
1067
|
+
* exist.
|
|
1068
|
+
*/
|
|
1069
|
+
setElementOpacity(page: number, index: number, fillAlpha: number): boolean;
|
|
1070
|
+
/**
|
|
1071
|
+
* Change the paint order (z-order) of element `index` on `page`. `toFront`
|
|
1072
|
+
* brings it visually on top (its op range is moved to the end of the content
|
|
1073
|
+
* stream, painted last); otherwise it is sent behind everything (moved to the
|
|
1074
|
+
* start, painted first). The moved range is re-wrapped in `q … Q` so it neither
|
|
1075
|
+
* inherits nor leaks graphics state. Works for text, image and shape elements.
|
|
1076
|
+
* The element's index changes after the move — re-read {@link pageElements}.
|
|
1077
|
+
* Returns `false` if the page/index doesn't exist.
|
|
1078
|
+
*/
|
|
1079
|
+
reorderElement(page: number, index: number, toFront: boolean): boolean;
|
|
1059
1080
|
duplicateElement(page: number, index: number): boolean;
|
|
1060
1081
|
/** Index of the element at page point `(x, y)`, or -1 if none. */
|
|
1061
1082
|
elementAt(page: number, x: number, y: number): number;
|
|
@@ -1196,6 +1217,17 @@ declare class GigaPdfDoc {
|
|
|
1196
1217
|
* text on top of.
|
|
1197
1218
|
*/
|
|
1198
1219
|
renderPageNoText(page: number, scale?: number): Uint8Array;
|
|
1220
|
+
/**
|
|
1221
|
+
* Rasterize a page to a PNG while **omitting** the given top-level element
|
|
1222
|
+
* `indices` (from {@link pageElements}). Each excluded element paints nothing
|
|
1223
|
+
* — fills, strokes, shadings, images and text alike — while everything else
|
|
1224
|
+
* (including the non-text content of non-excluded elements) renders normally.
|
|
1225
|
+
* Use it to paint a background without specific elements and overlay live,
|
|
1226
|
+
* editable versions on top. Generalises {@link renderPageNoText} (which
|
|
1227
|
+
* suppresses *all* text). An empty `indices` renders the full page; unknown
|
|
1228
|
+
* indices are ignored.
|
|
1229
|
+
*/
|
|
1230
|
+
renderPageExcluding(page: number, indices: number[], scale?: number): Uint8Array;
|
|
1199
1231
|
/**
|
|
1200
1232
|
* Embed an outline font program as a Type0 font and return its object number
|
|
1201
1233
|
* (pass to {@link addText} / re-encoded by {@link replaceText}). Accepts
|
package/dist/index.js
CHANGED
|
@@ -973,10 +973,11 @@ var GigaPdfDoc = class {
|
|
|
973
973
|
* in `0..=1`; `dash` is the PDF dash array (`[]` = solid). Returns `false` if
|
|
974
974
|
* the element is not a path (or the page/index doesn't exist).
|
|
975
975
|
*
|
|
976
|
-
* Opacity
|
|
977
|
-
*
|
|
978
|
-
*
|
|
979
|
-
*
|
|
976
|
+
* Opacity: `fillAlpha`/`strokeAlpha` (`0..=1`) are fully supported — an
|
|
977
|
+
* `/ExtGState` carrying `/ca`/`/CA` is registered on the page and a `/<gs> gs`
|
|
978
|
+
* is injected into the path's `q … Q` wrap, so the alpha applies to that path
|
|
979
|
+
* run only. (For non-path elements such as images, use
|
|
980
|
+
* {@link setElementOpacity}.)
|
|
980
981
|
*/
|
|
981
982
|
setPathStyle(page, index, style) {
|
|
982
983
|
return this.g._withStr(
|
|
@@ -984,6 +985,30 @@ var GigaPdfDoc = class {
|
|
|
984
985
|
(p, l) => this.ex().gp_set_path_style_json(this.h, page, index, p, l)
|
|
985
986
|
) === 0;
|
|
986
987
|
}
|
|
988
|
+
/**
|
|
989
|
+
* Set a constant opacity on element `index` on `page` — text, image **or**
|
|
990
|
+
* shape — by registering an `/ExtGState` (`/ca` = `/CA` = `fillAlpha`, clamped
|
|
991
|
+
* to `0..=1`) on the page and wrapping the element's op range in
|
|
992
|
+
* `q /<gs> gs … Q`. This is the way to set an **image**'s alpha in place;
|
|
993
|
+
* shapes may also use {@link setPathStyle}'s `fillAlpha`/`strokeAlpha` (same
|
|
994
|
+
* underlying `/ExtGState` mechanism). Returns `false` if the page/index doesn't
|
|
995
|
+
* exist.
|
|
996
|
+
*/
|
|
997
|
+
setElementOpacity(page, index, fillAlpha) {
|
|
998
|
+
return this.ex().gp_set_element_opacity(this.h, page, index, fillAlpha) === 0;
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Change the paint order (z-order) of element `index` on `page`. `toFront`
|
|
1002
|
+
* brings it visually on top (its op range is moved to the end of the content
|
|
1003
|
+
* stream, painted last); otherwise it is sent behind everything (moved to the
|
|
1004
|
+
* start, painted first). The moved range is re-wrapped in `q … Q` so it neither
|
|
1005
|
+
* inherits nor leaks graphics state. Works for text, image and shape elements.
|
|
1006
|
+
* The element's index changes after the move — re-read {@link pageElements}.
|
|
1007
|
+
* Returns `false` if the page/index doesn't exist.
|
|
1008
|
+
*/
|
|
1009
|
+
reorderElement(page, index, toFront) {
|
|
1010
|
+
return this.ex().gp_reorder_element(this.h, page, index, toFront ? 1 : 0) === 0;
|
|
1011
|
+
}
|
|
987
1012
|
duplicateElement(page, index) {
|
|
988
1013
|
return this.ex().gp_duplicate_element(this.h, page, index) === 0;
|
|
989
1014
|
}
|
|
@@ -1267,6 +1292,24 @@ var GigaPdfDoc = class {
|
|
|
1267
1292
|
renderPageNoText(page, scale = 1) {
|
|
1268
1293
|
return this.g._buffer((o) => this.ex().gp_render_page_no_text(this.h, page, scale, o));
|
|
1269
1294
|
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Rasterize a page to a PNG while **omitting** the given top-level element
|
|
1297
|
+
* `indices` (from {@link pageElements}). Each excluded element paints nothing
|
|
1298
|
+
* — fills, strokes, shadings, images and text alike — while everything else
|
|
1299
|
+
* (including the non-text content of non-excluded elements) renders normally.
|
|
1300
|
+
* Use it to paint a background without specific elements and overlay live,
|
|
1301
|
+
* editable versions on top. Generalises {@link renderPageNoText} (which
|
|
1302
|
+
* suppresses *all* text). An empty `indices` renders the full page; unknown
|
|
1303
|
+
* indices are ignored.
|
|
1304
|
+
*/
|
|
1305
|
+
renderPageExcluding(page, indices, scale = 1) {
|
|
1306
|
+
return this.g._buffer(
|
|
1307
|
+
(o) => this.g._withU32(
|
|
1308
|
+
indices,
|
|
1309
|
+
(p, c) => this.ex().gp_render_page_excluding(this.h, page, p, c, scale, o)
|
|
1310
|
+
)
|
|
1311
|
+
);
|
|
1312
|
+
}
|
|
1270
1313
|
// fonts — embed a downloaded font, then add real selectable text
|
|
1271
1314
|
/**
|
|
1272
1315
|
* Embed an outline font program as a Type0 font and return its object number
|