@qrcommunication/gigapdf-lib 0.52.1 → 0.52.3
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 +24 -0
- package/dist/index.cjs +38 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -2
- package/dist/index.d.ts +31 -2
- package/dist/index.js +38 -6
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1063,6 +1063,20 @@ declare class GigaPdfDoc {
|
|
|
1063
1063
|
removeHeaders(): boolean;
|
|
1064
1064
|
/** Remove every previously-baked running footer from all pages. */
|
|
1065
1065
|
removeFooters(): boolean;
|
|
1066
|
+
/**
|
|
1067
|
+
* Detect the running header/footer already baked into this PDF — the reader
|
|
1068
|
+
* counterpart of {@link GigaPdfDoc.setHeader} / {@link GigaPdfDoc.setFooter}.
|
|
1069
|
+
* Each side is a {@link HeaderFooterSpec} (with its recovered `text`) when a
|
|
1070
|
+
* baked `/GPHF` span is present, or `null` when absent. The `text` is faithful
|
|
1071
|
+
* (the per-page-substituted text of the first matching page); `align`,
|
|
1072
|
+
* `fontSize`, `color`, etc. are best-effort defaults, since the bake records
|
|
1073
|
+
* only the drawn text. Use it to reflect existing document state (e.g. a
|
|
1074
|
+
* Word-like editor toggle).
|
|
1075
|
+
*/
|
|
1076
|
+
headerFooter(): {
|
|
1077
|
+
header: HeaderFooterSpec | null;
|
|
1078
|
+
footer: HeaderFooterSpec | null;
|
|
1079
|
+
};
|
|
1066
1080
|
renderPage(page: number, scale?: number): Uint8Array;
|
|
1067
1081
|
/**
|
|
1068
1082
|
* Embed an outline font program as a Type0 font and return its object number
|
|
@@ -1080,8 +1094,16 @@ declare class GigaPdfDoc {
|
|
|
1080
1094
|
* font's char→glyph map (Identity-H, 2-byte glyph ids). `rgb` is packed
|
|
1081
1095
|
* `0xRRGGBB`; `rotationDeg` rotates CCW about `(x, y)`. For a built-in base-14
|
|
1082
1096
|
* family with no embedding, use {@link addStandardText}.
|
|
1097
|
+
*
|
|
1098
|
+
* Pass `opts` to bake **text decorations** into the run: `{ underline: true }`
|
|
1099
|
+
* draws a rule just below the baseline, `{ strikethrough: true }` a rule near
|
|
1100
|
+
* the x-height — both span the run's advance and are filled in the text colour.
|
|
1101
|
+
* Omitting `opts` is fully backward-compatible (no decoration).
|
|
1083
1102
|
*/
|
|
1084
|
-
addText(page: number, x: number, y: number, size: number, text: string, fontObj: number, rgb?: number, opacity?: number, rotationDeg?: number
|
|
1103
|
+
addText(page: number, x: number, y: number, size: number, text: string, fontObj: number, rgb?: number, opacity?: number, rotationDeg?: number, opts?: {
|
|
1104
|
+
underline?: boolean;
|
|
1105
|
+
strikethrough?: boolean;
|
|
1106
|
+
}): boolean;
|
|
1085
1107
|
/**
|
|
1086
1108
|
* Draw `text` at `(x, y)` in a built-in **base-14 standard font** (`fontName`,
|
|
1087
1109
|
* e.g. `"Times-Bold"`, `"Courier-Oblique"`, `"Symbol"`) — no embedding needed,
|
|
@@ -1089,8 +1111,15 @@ declare class GigaPdfDoc {
|
|
|
1089
1111
|
* {@link embedFont} (a Google Font fetched by the host, or one pulled out of
|
|
1090
1112
|
* the document with {@link extractFont}) and use {@link addText}. Returns
|
|
1091
1113
|
* `false` on an unknown font name or bad page.
|
|
1114
|
+
*
|
|
1115
|
+
* Pass `opts` to bake **text decorations** into the run: `{ underline: true }`
|
|
1116
|
+
* and/or `{ strikethrough: true }` draw filled rules in the text colour.
|
|
1117
|
+
* Omitting `opts` is fully backward-compatible (no decoration).
|
|
1092
1118
|
*/
|
|
1093
|
-
addStandardText(page: number, x: number, y: number, size: number, text: string, fontName: string, rgb?: number, opacity?: number, rotationDeg?: number
|
|
1119
|
+
addStandardText(page: number, x: number, y: number, size: number, text: string, fontName: string, rgb?: number, opacity?: number, rotationDeg?: number, opts?: {
|
|
1120
|
+
underline?: boolean;
|
|
1121
|
+
strikethrough?: boolean;
|
|
1122
|
+
}): boolean;
|
|
1094
1123
|
/**
|
|
1095
1124
|
* Stamp a standard-**Helvetica** watermark (no font embed needed): `text` at
|
|
1096
1125
|
* `(x, y)`, rotated `rotationDeg`° counter-clockwise, `rgb` packed `0xRRGGBB`,
|
package/dist/index.d.ts
CHANGED
|
@@ -1063,6 +1063,20 @@ declare class GigaPdfDoc {
|
|
|
1063
1063
|
removeHeaders(): boolean;
|
|
1064
1064
|
/** Remove every previously-baked running footer from all pages. */
|
|
1065
1065
|
removeFooters(): boolean;
|
|
1066
|
+
/**
|
|
1067
|
+
* Detect the running header/footer already baked into this PDF — the reader
|
|
1068
|
+
* counterpart of {@link GigaPdfDoc.setHeader} / {@link GigaPdfDoc.setFooter}.
|
|
1069
|
+
* Each side is a {@link HeaderFooterSpec} (with its recovered `text`) when a
|
|
1070
|
+
* baked `/GPHF` span is present, or `null` when absent. The `text` is faithful
|
|
1071
|
+
* (the per-page-substituted text of the first matching page); `align`,
|
|
1072
|
+
* `fontSize`, `color`, etc. are best-effort defaults, since the bake records
|
|
1073
|
+
* only the drawn text. Use it to reflect existing document state (e.g. a
|
|
1074
|
+
* Word-like editor toggle).
|
|
1075
|
+
*/
|
|
1076
|
+
headerFooter(): {
|
|
1077
|
+
header: HeaderFooterSpec | null;
|
|
1078
|
+
footer: HeaderFooterSpec | null;
|
|
1079
|
+
};
|
|
1066
1080
|
renderPage(page: number, scale?: number): Uint8Array;
|
|
1067
1081
|
/**
|
|
1068
1082
|
* Embed an outline font program as a Type0 font and return its object number
|
|
@@ -1080,8 +1094,16 @@ declare class GigaPdfDoc {
|
|
|
1080
1094
|
* font's char→glyph map (Identity-H, 2-byte glyph ids). `rgb` is packed
|
|
1081
1095
|
* `0xRRGGBB`; `rotationDeg` rotates CCW about `(x, y)`. For a built-in base-14
|
|
1082
1096
|
* family with no embedding, use {@link addStandardText}.
|
|
1097
|
+
*
|
|
1098
|
+
* Pass `opts` to bake **text decorations** into the run: `{ underline: true }`
|
|
1099
|
+
* draws a rule just below the baseline, `{ strikethrough: true }` a rule near
|
|
1100
|
+
* the x-height — both span the run's advance and are filled in the text colour.
|
|
1101
|
+
* Omitting `opts` is fully backward-compatible (no decoration).
|
|
1083
1102
|
*/
|
|
1084
|
-
addText(page: number, x: number, y: number, size: number, text: string, fontObj: number, rgb?: number, opacity?: number, rotationDeg?: number
|
|
1103
|
+
addText(page: number, x: number, y: number, size: number, text: string, fontObj: number, rgb?: number, opacity?: number, rotationDeg?: number, opts?: {
|
|
1104
|
+
underline?: boolean;
|
|
1105
|
+
strikethrough?: boolean;
|
|
1106
|
+
}): boolean;
|
|
1085
1107
|
/**
|
|
1086
1108
|
* Draw `text` at `(x, y)` in a built-in **base-14 standard font** (`fontName`,
|
|
1087
1109
|
* e.g. `"Times-Bold"`, `"Courier-Oblique"`, `"Symbol"`) — no embedding needed,
|
|
@@ -1089,8 +1111,15 @@ declare class GigaPdfDoc {
|
|
|
1089
1111
|
* {@link embedFont} (a Google Font fetched by the host, or one pulled out of
|
|
1090
1112
|
* the document with {@link extractFont}) and use {@link addText}. Returns
|
|
1091
1113
|
* `false` on an unknown font name or bad page.
|
|
1114
|
+
*
|
|
1115
|
+
* Pass `opts` to bake **text decorations** into the run: `{ underline: true }`
|
|
1116
|
+
* and/or `{ strikethrough: true }` draw filled rules in the text colour.
|
|
1117
|
+
* Omitting `opts` is fully backward-compatible (no decoration).
|
|
1092
1118
|
*/
|
|
1093
|
-
addStandardText(page: number, x: number, y: number, size: number, text: string, fontName: string, rgb?: number, opacity?: number, rotationDeg?: number
|
|
1119
|
+
addStandardText(page: number, x: number, y: number, size: number, text: string, fontName: string, rgb?: number, opacity?: number, rotationDeg?: number, opts?: {
|
|
1120
|
+
underline?: boolean;
|
|
1121
|
+
strikethrough?: boolean;
|
|
1122
|
+
}): boolean;
|
|
1094
1123
|
/**
|
|
1095
1124
|
* Stamp a standard-**Helvetica** watermark (no font embed needed): `text` at
|
|
1096
1125
|
* `(x, y)`, rotated `rotationDeg`° counter-clockwise, `rgb` packed `0xRRGGBB`,
|
package/dist/index.js
CHANGED
|
@@ -1149,6 +1149,21 @@ var GigaPdfDoc = class {
|
|
|
1149
1149
|
removeFooters() {
|
|
1150
1150
|
return this.ex().gp_remove_footers(this.h) === 0;
|
|
1151
1151
|
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Detect the running header/footer already baked into this PDF — the reader
|
|
1154
|
+
* counterpart of {@link GigaPdfDoc.setHeader} / {@link GigaPdfDoc.setFooter}.
|
|
1155
|
+
* Each side is a {@link HeaderFooterSpec} (with its recovered `text`) when a
|
|
1156
|
+
* baked `/GPHF` span is present, or `null` when absent. The `text` is faithful
|
|
1157
|
+
* (the per-page-substituted text of the first matching page); `align`,
|
|
1158
|
+
* `fontSize`, `color`, etc. are best-effort defaults, since the bake records
|
|
1159
|
+
* only the drawn text. Use it to reflect existing document state (e.g. a
|
|
1160
|
+
* Word-like editor toggle).
|
|
1161
|
+
*/
|
|
1162
|
+
headerFooter() {
|
|
1163
|
+
return this.g._json(
|
|
1164
|
+
(o) => this.ex().gp_header_footer(this.h, o)
|
|
1165
|
+
);
|
|
1166
|
+
}
|
|
1152
1167
|
// render
|
|
1153
1168
|
renderPage(page, scale = 1) {
|
|
1154
1169
|
return this.g._buffer((o) => this.ex().gp_render_page(this.h, page, scale, o));
|
|
@@ -1179,11 +1194,18 @@ var GigaPdfDoc = class {
|
|
|
1179
1194
|
* font's char→glyph map (Identity-H, 2-byte glyph ids). `rgb` is packed
|
|
1180
1195
|
* `0xRRGGBB`; `rotationDeg` rotates CCW about `(x, y)`. For a built-in base-14
|
|
1181
1196
|
* family with no embedding, use {@link addStandardText}.
|
|
1197
|
+
*
|
|
1198
|
+
* Pass `opts` to bake **text decorations** into the run: `{ underline: true }`
|
|
1199
|
+
* draws a rule just below the baseline, `{ strikethrough: true }` a rule near
|
|
1200
|
+
* the x-height — both span the run's advance and are filled in the text colour.
|
|
1201
|
+
* Omitting `opts` is fully backward-compatible (no decoration).
|
|
1182
1202
|
*/
|
|
1183
|
-
addText(page, x, y, size, text, fontObj, rgb = 0, opacity = 1, rotationDeg = 0) {
|
|
1203
|
+
addText(page, x, y, size, text, fontObj, rgb = 0, opacity = 1, rotationDeg = 0, opts) {
|
|
1204
|
+
const underline = opts?.underline ? 1 : 0;
|
|
1205
|
+
const strikethrough = opts?.strikethrough ? 1 : 0;
|
|
1184
1206
|
return this.g._withStr(
|
|
1185
1207
|
text,
|
|
1186
|
-
(p, l) => this.ex().
|
|
1208
|
+
(p, l) => this.ex().gp_add_text_styled(
|
|
1187
1209
|
this.h,
|
|
1188
1210
|
page,
|
|
1189
1211
|
x,
|
|
@@ -1194,7 +1216,9 @@ var GigaPdfDoc = class {
|
|
|
1194
1216
|
fontObj,
|
|
1195
1217
|
RGB(rgb),
|
|
1196
1218
|
opacity,
|
|
1197
|
-
rotationDeg
|
|
1219
|
+
rotationDeg,
|
|
1220
|
+
underline,
|
|
1221
|
+
strikethrough
|
|
1198
1222
|
)
|
|
1199
1223
|
) === 0;
|
|
1200
1224
|
}
|
|
@@ -1205,13 +1229,19 @@ var GigaPdfDoc = class {
|
|
|
1205
1229
|
* {@link embedFont} (a Google Font fetched by the host, or one pulled out of
|
|
1206
1230
|
* the document with {@link extractFont}) and use {@link addText}. Returns
|
|
1207
1231
|
* `false` on an unknown font name or bad page.
|
|
1232
|
+
*
|
|
1233
|
+
* Pass `opts` to bake **text decorations** into the run: `{ underline: true }`
|
|
1234
|
+
* and/or `{ strikethrough: true }` draw filled rules in the text colour.
|
|
1235
|
+
* Omitting `opts` is fully backward-compatible (no decoration).
|
|
1208
1236
|
*/
|
|
1209
|
-
addStandardText(page, x, y, size, text, fontName, rgb = 0, opacity = 1, rotationDeg = 0) {
|
|
1237
|
+
addStandardText(page, x, y, size, text, fontName, rgb = 0, opacity = 1, rotationDeg = 0, opts) {
|
|
1238
|
+
const underline = opts?.underline ? 1 : 0;
|
|
1239
|
+
const strikethrough = opts?.strikethrough ? 1 : 0;
|
|
1210
1240
|
return this.g._withStr(
|
|
1211
1241
|
text,
|
|
1212
1242
|
(tp, tl) => this.g._withStr(
|
|
1213
1243
|
fontName,
|
|
1214
|
-
(fp, fl) => this.ex().
|
|
1244
|
+
(fp, fl) => this.ex().gp_add_text_standard_styled(
|
|
1215
1245
|
this.h,
|
|
1216
1246
|
page,
|
|
1217
1247
|
x,
|
|
@@ -1223,7 +1253,9 @@ var GigaPdfDoc = class {
|
|
|
1223
1253
|
fl,
|
|
1224
1254
|
RGB(rgb),
|
|
1225
1255
|
opacity,
|
|
1226
|
-
rotationDeg
|
|
1256
|
+
rotationDeg,
|
|
1257
|
+
underline,
|
|
1258
|
+
strikethrough
|
|
1227
1259
|
)
|
|
1228
1260
|
)
|
|
1229
1261
|
) === 0;
|