@qrcommunication/gigapdf-lib 0.54.0 → 0.55.1

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
@@ -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
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
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