@qrcommunication/gigapdf-lib 0.54.0 → 0.56.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 +44 -0
- package/README.md +18 -2
- package/dist/index.cjs +44 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/models/ocr_jpn.gpocr +0 -0
- package/models/ocr_kor.gpocr +0 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -104,6 +104,23 @@ declare class GigaPdfEngine {
|
|
|
104
104
|
rtfToPdf(rtf: string): Uint8Array;
|
|
105
105
|
/** Office (DOCX/ODT/PPTX/XLSX/ODS) → PDF, auto-detected. Empty array if unrecognized. */
|
|
106
106
|
officeToPdf(office: Uint8Array): Uint8Array;
|
|
107
|
+
/**
|
|
108
|
+
* Image (PNG/JPEG/GIF/WebP/AVIF) → one-page PDF, format auto-detected: the
|
|
109
|
+
* image is centred and scaled to fit on an A4 portrait page. PNG/JPEG embed
|
|
110
|
+
* directly; GIF/WebP/AVIF are transcoded to PNG first — all in pure Rust/WASM,
|
|
111
|
+
* no third-party image library. Empty array if the bytes are not a recognized
|
|
112
|
+
* image. To combine many images into a single document, pipe each result
|
|
113
|
+
* through {@link mergePdfs}.
|
|
114
|
+
*/
|
|
115
|
+
imageToPdf(image: Uint8Array): Uint8Array;
|
|
116
|
+
/**
|
|
117
|
+
* Merge several PDFs into one by appending their pages in order. Returns an
|
|
118
|
+
* empty document for an empty list, or the single input unchanged for a list
|
|
119
|
+
* of one. Each subsequent PDF is appended onto the first via
|
|
120
|
+
* {@link GigaPdfDoc.appendPages}; the merged bytes are returned and the working
|
|
121
|
+
* document is closed.
|
|
122
|
+
*/
|
|
123
|
+
mergePdfs(pdfs: Uint8Array[]): Uint8Array;
|
|
107
124
|
/**
|
|
108
125
|
* Write a host-built grid (`pages[rows][cells]`) to an `.xlsx` workbook — one
|
|
109
126
|
* sheet per page — with the engine's native spreadsheet writer (no
|
|
@@ -1116,6 +1133,14 @@ declare class GigaPdfDoc {
|
|
|
1116
1133
|
footer: HeaderFooterSpec | null;
|
|
1117
1134
|
};
|
|
1118
1135
|
renderPage(page: number, scale?: number): Uint8Array;
|
|
1136
|
+
/**
|
|
1137
|
+
* Rasterize a page to a PNG **without the page content stream's text** — glyphs
|
|
1138
|
+
* are suppressed while gradients, shadings, images, vectors and patterns are
|
|
1139
|
+
* preserved. Annotation/widget appearances are still painted in full. Use this
|
|
1140
|
+
* to paint a text-free raster background the editor can overlay real, editable
|
|
1141
|
+
* text on top of.
|
|
1142
|
+
*/
|
|
1143
|
+
renderPageNoText(page: number, scale?: number): Uint8Array;
|
|
1119
1144
|
/**
|
|
1120
1145
|
* Embed an outline font program as a Type0 font and return its object number
|
|
1121
1146
|
* (pass to {@link addText} / re-encoded by {@link replaceText}). Accepts
|
package/dist/index.d.ts
CHANGED
|
@@ -104,6 +104,23 @@ declare class GigaPdfEngine {
|
|
|
104
104
|
rtfToPdf(rtf: string): Uint8Array;
|
|
105
105
|
/** Office (DOCX/ODT/PPTX/XLSX/ODS) → PDF, auto-detected. Empty array if unrecognized. */
|
|
106
106
|
officeToPdf(office: Uint8Array): Uint8Array;
|
|
107
|
+
/**
|
|
108
|
+
* Image (PNG/JPEG/GIF/WebP/AVIF) → one-page PDF, format auto-detected: the
|
|
109
|
+
* image is centred and scaled to fit on an A4 portrait page. PNG/JPEG embed
|
|
110
|
+
* directly; GIF/WebP/AVIF are transcoded to PNG first — all in pure Rust/WASM,
|
|
111
|
+
* no third-party image library. Empty array if the bytes are not a recognized
|
|
112
|
+
* image. To combine many images into a single document, pipe each result
|
|
113
|
+
* through {@link mergePdfs}.
|
|
114
|
+
*/
|
|
115
|
+
imageToPdf(image: Uint8Array): Uint8Array;
|
|
116
|
+
/**
|
|
117
|
+
* Merge several PDFs into one by appending their pages in order. Returns an
|
|
118
|
+
* empty document for an empty list, or the single input unchanged for a list
|
|
119
|
+
* of one. Each subsequent PDF is appended onto the first via
|
|
120
|
+
* {@link GigaPdfDoc.appendPages}; the merged bytes are returned and the working
|
|
121
|
+
* document is closed.
|
|
122
|
+
*/
|
|
123
|
+
mergePdfs(pdfs: Uint8Array[]): Uint8Array;
|
|
107
124
|
/**
|
|
108
125
|
* Write a host-built grid (`pages[rows][cells]`) to an `.xlsx` workbook — one
|
|
109
126
|
* sheet per page — with the engine's native spreadsheet writer (no
|
|
@@ -1116,6 +1133,14 @@ declare class GigaPdfDoc {
|
|
|
1116
1133
|
footer: HeaderFooterSpec | null;
|
|
1117
1134
|
};
|
|
1118
1135
|
renderPage(page: number, scale?: number): Uint8Array;
|
|
1136
|
+
/**
|
|
1137
|
+
* Rasterize a page to a PNG **without the page content stream's text** — glyphs
|
|
1138
|
+
* are suppressed while gradients, shadings, images, vectors and patterns are
|
|
1139
|
+
* preserved. Annotation/widget appearances are still painted in full. Use this
|
|
1140
|
+
* to paint a text-free raster background the editor can overlay real, editable
|
|
1141
|
+
* text on top of.
|
|
1142
|
+
*/
|
|
1143
|
+
renderPageNoText(page: number, scale?: number): Uint8Array;
|
|
1119
1144
|
/**
|
|
1120
1145
|
* Embed an outline font program as a Type0 font and return its object number
|
|
1121
1146
|
* (pass to {@link addText} / re-encoded by {@link replaceText}). Accepts
|
package/dist/index.js
CHANGED
|
@@ -246,6 +246,40 @@ var GigaPdfEngine = class _GigaPdfEngine {
|
|
|
246
246
|
(p, l) => this._buffer((o) => this.ex.gp_office_to_pdf(p, l, o))
|
|
247
247
|
);
|
|
248
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Image (PNG/JPEG/GIF/WebP/AVIF) → one-page PDF, format auto-detected: the
|
|
251
|
+
* image is centred and scaled to fit on an A4 portrait page. PNG/JPEG embed
|
|
252
|
+
* directly; GIF/WebP/AVIF are transcoded to PNG first — all in pure Rust/WASM,
|
|
253
|
+
* no third-party image library. Empty array if the bytes are not a recognized
|
|
254
|
+
* image. To combine many images into a single document, pipe each result
|
|
255
|
+
* through {@link mergePdfs}.
|
|
256
|
+
*/
|
|
257
|
+
imageToPdf(image) {
|
|
258
|
+
return this._withBytes(
|
|
259
|
+
image,
|
|
260
|
+
(p, l) => this._buffer((o) => this.ex.gp_image_to_pdf(p, l, o))
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Merge several PDFs into one by appending their pages in order. Returns an
|
|
265
|
+
* empty document for an empty list, or the single input unchanged for a list
|
|
266
|
+
* of one. Each subsequent PDF is appended onto the first via
|
|
267
|
+
* {@link GigaPdfDoc.appendPages}; the merged bytes are returned and the working
|
|
268
|
+
* document is closed.
|
|
269
|
+
*/
|
|
270
|
+
mergePdfs(pdfs) {
|
|
271
|
+
if (pdfs.length === 0) return new Uint8Array(0);
|
|
272
|
+
if (pdfs.length === 1) return pdfs[0];
|
|
273
|
+
const base = this.open(pdfs[0]);
|
|
274
|
+
try {
|
|
275
|
+
for (let i = 1; i < pdfs.length; i++) {
|
|
276
|
+
base.appendPages(pdfs[i]);
|
|
277
|
+
}
|
|
278
|
+
return base.save();
|
|
279
|
+
} finally {
|
|
280
|
+
base.close();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
249
283
|
/**
|
|
250
284
|
* Write a host-built grid (`pages[rows][cells]`) to an `.xlsx` workbook — one
|
|
251
285
|
* sheet per page — with the engine's native spreadsheet writer (no
|
|
@@ -1182,6 +1216,16 @@ var GigaPdfDoc = class {
|
|
|
1182
1216
|
renderPage(page, scale = 1) {
|
|
1183
1217
|
return this.g._buffer((o) => this.ex().gp_render_page(this.h, page, scale, o));
|
|
1184
1218
|
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Rasterize a page to a PNG **without the page content stream's text** — glyphs
|
|
1221
|
+
* are suppressed while gradients, shadings, images, vectors and patterns are
|
|
1222
|
+
* preserved. Annotation/widget appearances are still painted in full. Use this
|
|
1223
|
+
* to paint a text-free raster background the editor can overlay real, editable
|
|
1224
|
+
* text on top of.
|
|
1225
|
+
*/
|
|
1226
|
+
renderPageNoText(page, scale = 1) {
|
|
1227
|
+
return this.g._buffer((o) => this.ex().gp_render_page_no_text(this.h, page, scale, o));
|
|
1228
|
+
}
|
|
1185
1229
|
// fonts — embed a downloaded font, then add real selectable text
|
|
1186
1230
|
/**
|
|
1187
1231
|
* Embed an outline font program as a Type0 font and return its object number
|