@qrcommunication/gigapdf-lib 0.56.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 +78 -0
- package/README.md +8 -2
- package/dist/index.cjs +84 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +87 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +84 -0
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -664,6 +664,13 @@ type ModelOp = {
|
|
|
664
664
|
* and the source pixel dimensions. `data` is empty when `format` is `"unknown"`.
|
|
665
665
|
*/
|
|
666
666
|
interface ImageElementInfo {
|
|
667
|
+
/**
|
|
668
|
+
* The image's **unified element index** — the same value accepted by
|
|
669
|
+
* {@link GigaPdfDoc.removeElement} / {@link GigaPdfDoc.transformElement} /
|
|
670
|
+
* {@link GigaPdfDoc.duplicateElement} / {@link GigaPdfDoc.moveElement}. Extract
|
|
671
|
+
* an image here and pass this index to edit *that exact* image. It is **not** an
|
|
672
|
+
* image-local 0,1,2 counter, so it is correct on pages that also have text/paths.
|
|
673
|
+
*/
|
|
667
674
|
index: number;
|
|
668
675
|
x: number;
|
|
669
676
|
y: number;
|
|
@@ -697,6 +704,13 @@ interface PathSegment {
|
|
|
697
704
|
* paths are omitted. The native equivalent of a reader's shape/vector layer.
|
|
698
705
|
*/
|
|
699
706
|
interface VectorPathInfo {
|
|
707
|
+
/**
|
|
708
|
+
* The path's **unified element index** — the same value accepted by
|
|
709
|
+
* {@link GigaPdfDoc.setPathStyle} / {@link GigaPdfDoc.removeElement} /
|
|
710
|
+
* {@link GigaPdfDoc.transformElement}. Extract a path here and pass this index
|
|
711
|
+
* to restyle or remove *that exact* path. Clip-only paths are not reported, so
|
|
712
|
+
* the painted path you see is the one your index targets — not a path-local ordinal.
|
|
713
|
+
*/
|
|
700
714
|
index: number;
|
|
701
715
|
/** Whether `x0..y1` describe a real box (`false` for a degenerate path). */
|
|
702
716
|
hasBounds: boolean;
|
|
@@ -977,6 +991,10 @@ declare class GigaPdfDoc {
|
|
|
977
991
|
* `unknown`), and the source pixel dimensions. DCTDecode/JPXDecode images pass
|
|
978
992
|
* through as jpeg/jp2; Flate/raw DeviceRGB|DeviceGray are re-encoded to PNG.
|
|
979
993
|
* The native replacement for a reader's image extraction (bytes + placement).
|
|
994
|
+
*
|
|
995
|
+
* Each result's `index` is the **unified element index** usable directly with
|
|
996
|
+
* {@link removeElement} / {@link transformElement} / {@link duplicateElement} /
|
|
997
|
+
* {@link moveElement} — so you can extract an image and edit *that exact* image.
|
|
980
998
|
*/
|
|
981
999
|
imageElements(page: number): ImageElementInfo[];
|
|
982
1000
|
/**
|
|
@@ -985,6 +1003,10 @@ declare class GigaPdfDoc {
|
|
|
985
1003
|
* fill/stroke RGB, line width, alpha and dash. Clip-only paths are omitted.
|
|
986
1004
|
* The native replacement for walking a reader's operator list to rebuild the
|
|
987
1005
|
* shape layer.
|
|
1006
|
+
*
|
|
1007
|
+
* Each result's `index` is the **unified element index** usable directly with
|
|
1008
|
+
* {@link setPathStyle} / {@link removeElement} / {@link transformElement} — so
|
|
1009
|
+
* you can extract a path and restyle/remove *that exact* path.
|
|
988
1010
|
*/
|
|
989
1011
|
vectorPaths(page: number): VectorPathInfo[];
|
|
990
1012
|
structuredText(page: number): TextLine[];
|
|
@@ -1001,6 +1023,60 @@ declare class GigaPdfDoc {
|
|
|
1001
1023
|
replaceText(page: number, index: number, text: string): boolean;
|
|
1002
1024
|
removeElement(page: number, index: number): boolean;
|
|
1003
1025
|
moveElement(page: number, index: number, dx: number, dy: number): boolean;
|
|
1026
|
+
/**
|
|
1027
|
+
* Apply a full affine transform to element `index` on `page`, wrapping it in
|
|
1028
|
+
* `q … cm … Q` with the matrix `m = [a, b, c, d, e, f]`. This **generalises**
|
|
1029
|
+
* {@link moveElement} (whose matrix is the pure translate `[1,0,0,1,dx,dy]`)
|
|
1030
|
+
* to scale, rotation, shear and translation in one call. Because it is purely
|
|
1031
|
+
* matrix-based it works identically for text, images and shapes — their
|
|
1032
|
+
* internal coordinates are never touched. Returns `false` if the element/page
|
|
1033
|
+
* doesn't exist.
|
|
1034
|
+
*/
|
|
1035
|
+
transformElement(page: number, index: number, m: [number, number, number, number, number, number]): boolean;
|
|
1036
|
+
/**
|
|
1037
|
+
* Re-style the **path** element `index` on `page` in place: any provided field
|
|
1038
|
+
* overrides that part of the graphics state for the path's paint; omitted
|
|
1039
|
+
* fields keep the inherited state. Implemented by wrapping the path's op range
|
|
1040
|
+
* in `q … Q` and injecting the requested state operators (`rg`/`RG`/`w`/`d`)
|
|
1041
|
+
* before its construction + paint ops, so the original paint op now draws with
|
|
1042
|
+
* the override and following content is unaffected. RGB colours are `[r,g,b]`
|
|
1043
|
+
* in `0..=1`; `dash` is the PDF dash array (`[]` = solid). Returns `false` if
|
|
1044
|
+
* the element is not a path (or the page/index doesn't exist).
|
|
1045
|
+
*
|
|
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}.)
|
|
1051
|
+
*/
|
|
1052
|
+
setPathStyle(page: number, index: number, style: {
|
|
1053
|
+
fill?: [number, number, number];
|
|
1054
|
+
stroke?: [number, number, number];
|
|
1055
|
+
strokeWidth?: number;
|
|
1056
|
+
fillAlpha?: number;
|
|
1057
|
+
strokeAlpha?: number;
|
|
1058
|
+
dash?: number[];
|
|
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;
|
|
1004
1080
|
duplicateElement(page: number, index: number): boolean;
|
|
1005
1081
|
/** Index of the element at page point `(x, y)`, or -1 if none. */
|
|
1006
1082
|
elementAt(page: number, x: number, y: number): number;
|
|
@@ -1141,6 +1217,17 @@ declare class GigaPdfDoc {
|
|
|
1141
1217
|
* text on top of.
|
|
1142
1218
|
*/
|
|
1143
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;
|
|
1144
1231
|
/**
|
|
1145
1232
|
* Embed an outline font program as a Type0 font and return its object number
|
|
1146
1233
|
* (pass to {@link addText} / re-encoded by {@link replaceText}). Accepts
|
package/dist/index.d.ts
CHANGED
|
@@ -664,6 +664,13 @@ type ModelOp = {
|
|
|
664
664
|
* and the source pixel dimensions. `data` is empty when `format` is `"unknown"`.
|
|
665
665
|
*/
|
|
666
666
|
interface ImageElementInfo {
|
|
667
|
+
/**
|
|
668
|
+
* The image's **unified element index** — the same value accepted by
|
|
669
|
+
* {@link GigaPdfDoc.removeElement} / {@link GigaPdfDoc.transformElement} /
|
|
670
|
+
* {@link GigaPdfDoc.duplicateElement} / {@link GigaPdfDoc.moveElement}. Extract
|
|
671
|
+
* an image here and pass this index to edit *that exact* image. It is **not** an
|
|
672
|
+
* image-local 0,1,2 counter, so it is correct on pages that also have text/paths.
|
|
673
|
+
*/
|
|
667
674
|
index: number;
|
|
668
675
|
x: number;
|
|
669
676
|
y: number;
|
|
@@ -697,6 +704,13 @@ interface PathSegment {
|
|
|
697
704
|
* paths are omitted. The native equivalent of a reader's shape/vector layer.
|
|
698
705
|
*/
|
|
699
706
|
interface VectorPathInfo {
|
|
707
|
+
/**
|
|
708
|
+
* The path's **unified element index** — the same value accepted by
|
|
709
|
+
* {@link GigaPdfDoc.setPathStyle} / {@link GigaPdfDoc.removeElement} /
|
|
710
|
+
* {@link GigaPdfDoc.transformElement}. Extract a path here and pass this index
|
|
711
|
+
* to restyle or remove *that exact* path. Clip-only paths are not reported, so
|
|
712
|
+
* the painted path you see is the one your index targets — not a path-local ordinal.
|
|
713
|
+
*/
|
|
700
714
|
index: number;
|
|
701
715
|
/** Whether `x0..y1` describe a real box (`false` for a degenerate path). */
|
|
702
716
|
hasBounds: boolean;
|
|
@@ -977,6 +991,10 @@ declare class GigaPdfDoc {
|
|
|
977
991
|
* `unknown`), and the source pixel dimensions. DCTDecode/JPXDecode images pass
|
|
978
992
|
* through as jpeg/jp2; Flate/raw DeviceRGB|DeviceGray are re-encoded to PNG.
|
|
979
993
|
* The native replacement for a reader's image extraction (bytes + placement).
|
|
994
|
+
*
|
|
995
|
+
* Each result's `index` is the **unified element index** usable directly with
|
|
996
|
+
* {@link removeElement} / {@link transformElement} / {@link duplicateElement} /
|
|
997
|
+
* {@link moveElement} — so you can extract an image and edit *that exact* image.
|
|
980
998
|
*/
|
|
981
999
|
imageElements(page: number): ImageElementInfo[];
|
|
982
1000
|
/**
|
|
@@ -985,6 +1003,10 @@ declare class GigaPdfDoc {
|
|
|
985
1003
|
* fill/stroke RGB, line width, alpha and dash. Clip-only paths are omitted.
|
|
986
1004
|
* The native replacement for walking a reader's operator list to rebuild the
|
|
987
1005
|
* shape layer.
|
|
1006
|
+
*
|
|
1007
|
+
* Each result's `index` is the **unified element index** usable directly with
|
|
1008
|
+
* {@link setPathStyle} / {@link removeElement} / {@link transformElement} — so
|
|
1009
|
+
* you can extract a path and restyle/remove *that exact* path.
|
|
988
1010
|
*/
|
|
989
1011
|
vectorPaths(page: number): VectorPathInfo[];
|
|
990
1012
|
structuredText(page: number): TextLine[];
|
|
@@ -1001,6 +1023,60 @@ declare class GigaPdfDoc {
|
|
|
1001
1023
|
replaceText(page: number, index: number, text: string): boolean;
|
|
1002
1024
|
removeElement(page: number, index: number): boolean;
|
|
1003
1025
|
moveElement(page: number, index: number, dx: number, dy: number): boolean;
|
|
1026
|
+
/**
|
|
1027
|
+
* Apply a full affine transform to element `index` on `page`, wrapping it in
|
|
1028
|
+
* `q … cm … Q` with the matrix `m = [a, b, c, d, e, f]`. This **generalises**
|
|
1029
|
+
* {@link moveElement} (whose matrix is the pure translate `[1,0,0,1,dx,dy]`)
|
|
1030
|
+
* to scale, rotation, shear and translation in one call. Because it is purely
|
|
1031
|
+
* matrix-based it works identically for text, images and shapes — their
|
|
1032
|
+
* internal coordinates are never touched. Returns `false` if the element/page
|
|
1033
|
+
* doesn't exist.
|
|
1034
|
+
*/
|
|
1035
|
+
transformElement(page: number, index: number, m: [number, number, number, number, number, number]): boolean;
|
|
1036
|
+
/**
|
|
1037
|
+
* Re-style the **path** element `index` on `page` in place: any provided field
|
|
1038
|
+
* overrides that part of the graphics state for the path's paint; omitted
|
|
1039
|
+
* fields keep the inherited state. Implemented by wrapping the path's op range
|
|
1040
|
+
* in `q … Q` and injecting the requested state operators (`rg`/`RG`/`w`/`d`)
|
|
1041
|
+
* before its construction + paint ops, so the original paint op now draws with
|
|
1042
|
+
* the override and following content is unaffected. RGB colours are `[r,g,b]`
|
|
1043
|
+
* in `0..=1`; `dash` is the PDF dash array (`[]` = solid). Returns `false` if
|
|
1044
|
+
* the element is not a path (or the page/index doesn't exist).
|
|
1045
|
+
*
|
|
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}.)
|
|
1051
|
+
*/
|
|
1052
|
+
setPathStyle(page: number, index: number, style: {
|
|
1053
|
+
fill?: [number, number, number];
|
|
1054
|
+
stroke?: [number, number, number];
|
|
1055
|
+
strokeWidth?: number;
|
|
1056
|
+
fillAlpha?: number;
|
|
1057
|
+
strokeAlpha?: number;
|
|
1058
|
+
dash?: number[];
|
|
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;
|
|
1004
1080
|
duplicateElement(page: number, index: number): boolean;
|
|
1005
1081
|
/** Index of the element at page point `(x, y)`, or -1 if none. */
|
|
1006
1082
|
elementAt(page: number, x: number, y: number): number;
|
|
@@ -1141,6 +1217,17 @@ declare class GigaPdfDoc {
|
|
|
1141
1217
|
* text on top of.
|
|
1142
1218
|
*/
|
|
1143
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;
|
|
1144
1231
|
/**
|
|
1145
1232
|
* Embed an outline font program as a Type0 font and return its object number
|
|
1146
1233
|
* (pass to {@link addText} / re-encoded by {@link replaceText}). Accepts
|
package/dist/index.js
CHANGED
|
@@ -891,6 +891,10 @@ var GigaPdfDoc = class {
|
|
|
891
891
|
* `unknown`), and the source pixel dimensions. DCTDecode/JPXDecode images pass
|
|
892
892
|
* through as jpeg/jp2; Flate/raw DeviceRGB|DeviceGray are re-encoded to PNG.
|
|
893
893
|
* The native replacement for a reader's image extraction (bytes + placement).
|
|
894
|
+
*
|
|
895
|
+
* Each result's `index` is the **unified element index** usable directly with
|
|
896
|
+
* {@link removeElement} / {@link transformElement} / {@link duplicateElement} /
|
|
897
|
+
* {@link moveElement} — so you can extract an image and edit *that exact* image.
|
|
894
898
|
*/
|
|
895
899
|
imageElements(page) {
|
|
896
900
|
const raw = this.g._json(
|
|
@@ -907,6 +911,10 @@ var GigaPdfDoc = class {
|
|
|
907
911
|
* fill/stroke RGB, line width, alpha and dash. Clip-only paths are omitted.
|
|
908
912
|
* The native replacement for walking a reader's operator list to rebuild the
|
|
909
913
|
* shape layer.
|
|
914
|
+
*
|
|
915
|
+
* Each result's `index` is the **unified element index** usable directly with
|
|
916
|
+
* {@link setPathStyle} / {@link removeElement} / {@link transformElement} — so
|
|
917
|
+
* you can extract a path and restyle/remove *that exact* path.
|
|
910
918
|
*/
|
|
911
919
|
vectorPaths(page) {
|
|
912
920
|
return this.g._json((o) => this.ex().gp_vector_paths_json(this.h, page, o));
|
|
@@ -943,6 +951,64 @@ var GigaPdfDoc = class {
|
|
|
943
951
|
moveElement(page, index, dx, dy) {
|
|
944
952
|
return this.ex().gp_move_element(this.h, page, index, dx, dy) === 0;
|
|
945
953
|
}
|
|
954
|
+
/**
|
|
955
|
+
* Apply a full affine transform to element `index` on `page`, wrapping it in
|
|
956
|
+
* `q … cm … Q` with the matrix `m = [a, b, c, d, e, f]`. This **generalises**
|
|
957
|
+
* {@link moveElement} (whose matrix is the pure translate `[1,0,0,1,dx,dy]`)
|
|
958
|
+
* to scale, rotation, shear and translation in one call. Because it is purely
|
|
959
|
+
* matrix-based it works identically for text, images and shapes — their
|
|
960
|
+
* internal coordinates are never touched. Returns `false` if the element/page
|
|
961
|
+
* doesn't exist.
|
|
962
|
+
*/
|
|
963
|
+
transformElement(page, index, m) {
|
|
964
|
+
return this.ex().gp_transform_element(this.h, page, index, m[0], m[1], m[2], m[3], m[4], m[5]) === 0;
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Re-style the **path** element `index` on `page` in place: any provided field
|
|
968
|
+
* overrides that part of the graphics state for the path's paint; omitted
|
|
969
|
+
* fields keep the inherited state. Implemented by wrapping the path's op range
|
|
970
|
+
* in `q … Q` and injecting the requested state operators (`rg`/`RG`/`w`/`d`)
|
|
971
|
+
* before its construction + paint ops, so the original paint op now draws with
|
|
972
|
+
* the override and following content is unaffected. RGB colours are `[r,g,b]`
|
|
973
|
+
* in `0..=1`; `dash` is the PDF dash array (`[]` = solid). Returns `false` if
|
|
974
|
+
* the element is not a path (or the page/index doesn't exist).
|
|
975
|
+
*
|
|
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}.)
|
|
981
|
+
*/
|
|
982
|
+
setPathStyle(page, index, style) {
|
|
983
|
+
return this.g._withStr(
|
|
984
|
+
JSON.stringify(style),
|
|
985
|
+
(p, l) => this.ex().gp_set_path_style_json(this.h, page, index, p, l)
|
|
986
|
+
) === 0;
|
|
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
|
+
}
|
|
946
1012
|
duplicateElement(page, index) {
|
|
947
1013
|
return this.ex().gp_duplicate_element(this.h, page, index) === 0;
|
|
948
1014
|
}
|
|
@@ -1226,6 +1292,24 @@ var GigaPdfDoc = class {
|
|
|
1226
1292
|
renderPageNoText(page, scale = 1) {
|
|
1227
1293
|
return this.g._buffer((o) => this.ex().gp_render_page_no_text(this.h, page, scale, o));
|
|
1228
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
|
+
}
|
|
1229
1313
|
// fonts — embed a downloaded font, then add real selectable text
|
|
1230
1314
|
/**
|
|
1231
1315
|
* Embed an outline font program as a Type0 font and return its object number
|