@qrcommunication/gigapdf-lib 0.52.3 → 0.52.4

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/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;
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;
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;