@qrcommunication/gigapdf-lib 0.52.3 → 0.52.5
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 +33 -0
- package/dist/index.cjs +38 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +38 -2
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1014,6 +1014,34 @@ declare class GigaPdfDoc {
|
|
|
1014
1014
|
addSvg(page: number, svg: string, x: number, y: number, w: number, h: number): boolean;
|
|
1015
1015
|
/** True redaction: delete content intersecting the region (no opaque cover by default). */
|
|
1016
1016
|
redact(page: number, x: number, y: number, w: number, h: number, coverRgb?: number, hasCover?: boolean): number;
|
|
1017
|
+
/**
|
|
1018
|
+
* True **PII redaction** of one or more rectangles `(x, y, width, height)` in
|
|
1019
|
+
* PDF points (origin bottom-left), in a single call. For every rect this:
|
|
1020
|
+
*
|
|
1021
|
+
* - **deletes** the overlapping text/vector elements from the content stream —
|
|
1022
|
+
* the glyphs and their `/ToUnicode` mapping are gone, so copy/paste and text
|
|
1023
|
+
* extraction reveal nothing in the area;
|
|
1024
|
+
* - **overwrites the pixels** of any underlying image (a scan/photo) with opaque
|
|
1025
|
+
* black — only the intersecting sub-rectangle, so the rest of the page image
|
|
1026
|
+
* survives — and re-encodes the image, erasing the sensitive pixels from the
|
|
1027
|
+
* bytes (not merely covering them);
|
|
1028
|
+
* - strips overlapping annotations and clears their form-field values;
|
|
1029
|
+
* - paints an opaque **black** box over the rect as the visible redaction mark.
|
|
1030
|
+
*
|
|
1031
|
+
* The black cover is the default for PII (unlike {@link redact}). Pass
|
|
1032
|
+
* `opts.coverRgb` to change the mark colour, or `opts.cover = false` to remove
|
|
1033
|
+
* the content/pixels with no visible box. Returns the number of content
|
|
1034
|
+
* elements deleted across all rects.
|
|
1035
|
+
*/
|
|
1036
|
+
redactPii(page: number, rects: {
|
|
1037
|
+
x: number;
|
|
1038
|
+
y: number;
|
|
1039
|
+
width: number;
|
|
1040
|
+
height: number;
|
|
1041
|
+
}[], opts?: {
|
|
1042
|
+
cover?: boolean;
|
|
1043
|
+
coverRgb?: number;
|
|
1044
|
+
}): number;
|
|
1017
1045
|
rotatePage(page: number, degrees: number): boolean;
|
|
1018
1046
|
deletePage(page: number): boolean;
|
|
1019
1047
|
movePage(from: number, to: number): boolean;
|
|
@@ -1197,7 +1225,13 @@ declare class GigaPdfDoc {
|
|
|
1197
1225
|
removeAnnotation(page: number, index: number): boolean;
|
|
1198
1226
|
addSquare(page: number, x0: number, y0: number, x1: number, y1: number, stroke?: number | null, fill?: number | null, lineWidth?: number): boolean;
|
|
1199
1227
|
addHighlight(page: number, x0: number, y0: number, x1: number, y1: number, rgb?: number): boolean;
|
|
1200
|
-
|
|
1228
|
+
/**
|
|
1229
|
+
* Add a `/Line` annotation from `(x1,y1)` to `(x2,y2)`. When `endArrow` is
|
|
1230
|
+
* `true`, an open arrowhead (`/LE [/None /OpenArrow]`) is drawn at the
|
|
1231
|
+
* `(x2,y2)` end — a real, editable annotation in conforming readers, ideal
|
|
1232
|
+
* for callouts that point at content.
|
|
1233
|
+
*/
|
|
1234
|
+
addLineAnnotation(page: number, x1: number, y1: number, x2: number, y2: number, rgb?: number, lineWidth?: number, endArrow?: boolean): boolean;
|
|
1201
1235
|
addFreeText(page: number, x0: number, y0: number, x1: number, y1: number, text: string, fontSize?: number, rgb?: number): boolean;
|
|
1202
1236
|
addUnderline(page: number, x0: number, y0: number, x1: number, y1: number, rgb?: number): boolean;
|
|
1203
1237
|
addStrikeOut(page: number, x0: number, y0: number, x1: number, y1: number, rgb?: number): boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1014,6 +1014,34 @@ declare class GigaPdfDoc {
|
|
|
1014
1014
|
addSvg(page: number, svg: string, x: number, y: number, w: number, h: number): boolean;
|
|
1015
1015
|
/** True redaction: delete content intersecting the region (no opaque cover by default). */
|
|
1016
1016
|
redact(page: number, x: number, y: number, w: number, h: number, coverRgb?: number, hasCover?: boolean): number;
|
|
1017
|
+
/**
|
|
1018
|
+
* True **PII redaction** of one or more rectangles `(x, y, width, height)` in
|
|
1019
|
+
* PDF points (origin bottom-left), in a single call. For every rect this:
|
|
1020
|
+
*
|
|
1021
|
+
* - **deletes** the overlapping text/vector elements from the content stream —
|
|
1022
|
+
* the glyphs and their `/ToUnicode` mapping are gone, so copy/paste and text
|
|
1023
|
+
* extraction reveal nothing in the area;
|
|
1024
|
+
* - **overwrites the pixels** of any underlying image (a scan/photo) with opaque
|
|
1025
|
+
* black — only the intersecting sub-rectangle, so the rest of the page image
|
|
1026
|
+
* survives — and re-encodes the image, erasing the sensitive pixels from the
|
|
1027
|
+
* bytes (not merely covering them);
|
|
1028
|
+
* - strips overlapping annotations and clears their form-field values;
|
|
1029
|
+
* - paints an opaque **black** box over the rect as the visible redaction mark.
|
|
1030
|
+
*
|
|
1031
|
+
* The black cover is the default for PII (unlike {@link redact}). Pass
|
|
1032
|
+
* `opts.coverRgb` to change the mark colour, or `opts.cover = false` to remove
|
|
1033
|
+
* the content/pixels with no visible box. Returns the number of content
|
|
1034
|
+
* elements deleted across all rects.
|
|
1035
|
+
*/
|
|
1036
|
+
redactPii(page: number, rects: {
|
|
1037
|
+
x: number;
|
|
1038
|
+
y: number;
|
|
1039
|
+
width: number;
|
|
1040
|
+
height: number;
|
|
1041
|
+
}[], opts?: {
|
|
1042
|
+
cover?: boolean;
|
|
1043
|
+
coverRgb?: number;
|
|
1044
|
+
}): number;
|
|
1017
1045
|
rotatePage(page: number, degrees: number): boolean;
|
|
1018
1046
|
deletePage(page: number): boolean;
|
|
1019
1047
|
movePage(from: number, to: number): boolean;
|
|
@@ -1197,7 +1225,13 @@ declare class GigaPdfDoc {
|
|
|
1197
1225
|
removeAnnotation(page: number, index: number): boolean;
|
|
1198
1226
|
addSquare(page: number, x0: number, y0: number, x1: number, y1: number, stroke?: number | null, fill?: number | null, lineWidth?: number): boolean;
|
|
1199
1227
|
addHighlight(page: number, x0: number, y0: number, x1: number, y1: number, rgb?: number): boolean;
|
|
1200
|
-
|
|
1228
|
+
/**
|
|
1229
|
+
* Add a `/Line` annotation from `(x1,y1)` to `(x2,y2)`. When `endArrow` is
|
|
1230
|
+
* `true`, an open arrowhead (`/LE [/None /OpenArrow]`) is drawn at the
|
|
1231
|
+
* `(x2,y2)` end — a real, editable annotation in conforming readers, ideal
|
|
1232
|
+
* for callouts that point at content.
|
|
1233
|
+
*/
|
|
1234
|
+
addLineAnnotation(page: number, x1: number, y1: number, x2: number, y2: number, rgb?: number, lineWidth?: number, endArrow?: boolean): boolean;
|
|
1201
1235
|
addFreeText(page: number, x0: number, y0: number, x1: number, y1: number, text: string, fontSize?: number, rgb?: number): boolean;
|
|
1202
1236
|
addUnderline(page: number, x0: number, y0: number, x1: number, y1: number, rgb?: number): boolean;
|
|
1203
1237
|
addStrikeOut(page: number, x0: number, y0: number, x1: number, y1: number, rgb?: number): boolean;
|
package/dist/index.js
CHANGED
|
@@ -1045,6 +1045,36 @@ var GigaPdfDoc = class {
|
|
|
1045
1045
|
redact(page, x, y, w, h, coverRgb = 0, hasCover = false) {
|
|
1046
1046
|
return this.ex().gp_redact_region(this.h, page, x, y, w, h, RGB(coverRgb), hasCover ? 1 : 0);
|
|
1047
1047
|
}
|
|
1048
|
+
/**
|
|
1049
|
+
* True **PII redaction** of one or more rectangles `(x, y, width, height)` in
|
|
1050
|
+
* PDF points (origin bottom-left), in a single call. For every rect this:
|
|
1051
|
+
*
|
|
1052
|
+
* - **deletes** the overlapping text/vector elements from the content stream —
|
|
1053
|
+
* the glyphs and their `/ToUnicode` mapping are gone, so copy/paste and text
|
|
1054
|
+
* extraction reveal nothing in the area;
|
|
1055
|
+
* - **overwrites the pixels** of any underlying image (a scan/photo) with opaque
|
|
1056
|
+
* black — only the intersecting sub-rectangle, so the rest of the page image
|
|
1057
|
+
* survives — and re-encodes the image, erasing the sensitive pixels from the
|
|
1058
|
+
* bytes (not merely covering them);
|
|
1059
|
+
* - strips overlapping annotations and clears their form-field values;
|
|
1060
|
+
* - paints an opaque **black** box over the rect as the visible redaction mark.
|
|
1061
|
+
*
|
|
1062
|
+
* The black cover is the default for PII (unlike {@link redact}). Pass
|
|
1063
|
+
* `opts.coverRgb` to change the mark colour, or `opts.cover = false` to remove
|
|
1064
|
+
* the content/pixels with no visible box. Returns the number of content
|
|
1065
|
+
* elements deleted across all rects.
|
|
1066
|
+
*/
|
|
1067
|
+
redactPii(page, rects, opts = {}) {
|
|
1068
|
+
if (rects.length === 0) return 0;
|
|
1069
|
+
const flat = [];
|
|
1070
|
+
for (const r of rects) flat.push(r.x, r.y, r.width, r.height);
|
|
1071
|
+
const cover = opts.cover ?? true;
|
|
1072
|
+
const coverRgb = opts.coverRgb ?? 0;
|
|
1073
|
+
return this.g._withF64(
|
|
1074
|
+
flat,
|
|
1075
|
+
(p, c) => this.ex().gp_redact_pii(this.h, page, p, c, RGB(coverRgb), cover ? 1 : 0)
|
|
1076
|
+
);
|
|
1077
|
+
}
|
|
1048
1078
|
// pages
|
|
1049
1079
|
rotatePage(page, degrees) {
|
|
1050
1080
|
return this.ex().gp_rotate_page(this.h, page, degrees) === 0;
|
|
@@ -1479,8 +1509,14 @@ var GigaPdfDoc = class {
|
|
|
1479
1509
|
addHighlight(page, x0, y0, x1, y1, rgb = 16776960) {
|
|
1480
1510
|
return this.ex().gp_add_highlight(this.h, page, x0, y0, x1, y1, RGB(rgb)) === 0;
|
|
1481
1511
|
}
|
|
1482
|
-
|
|
1483
|
-
|
|
1512
|
+
/**
|
|
1513
|
+
* Add a `/Line` annotation from `(x1,y1)` to `(x2,y2)`. When `endArrow` is
|
|
1514
|
+
* `true`, an open arrowhead (`/LE [/None /OpenArrow]`) is drawn at the
|
|
1515
|
+
* `(x2,y2)` end — a real, editable annotation in conforming readers, ideal
|
|
1516
|
+
* for callouts that point at content.
|
|
1517
|
+
*/
|
|
1518
|
+
addLineAnnotation(page, x1, y1, x2, y2, rgb = 0, lineWidth = 1, endArrow = false) {
|
|
1519
|
+
return this.ex().gp_add_line(this.h, page, x1, y1, x2, y2, RGB(rgb), lineWidth, endArrow ? 1 : 0) === 0;
|
|
1484
1520
|
}
|
|
1485
1521
|
addFreeText(page, x0, y0, x1, y1, text, fontSize = 12, rgb = 0) {
|
|
1486
1522
|
return this.g._withStr(
|