@imggion/html2realpdf 0.1.14 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imggion/html2realpdf",
3
- "version": "0.1.14",
3
+ "version": "0.2.0",
4
4
  "description": "Browser-first HTML to real, selectable PDF rendering powered by Zig and WebAssembly",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -348,7 +348,7 @@ Pass these options to `PdfDocument.preview`:
348
348
 
349
349
  | Option | Values and default |
350
350
  | --- | --- |
351
- | `showToolbar` | `true` by default; set to `false` to hide the summary and zoom controls |
351
+ | `showToolbar` | `true` by default; set to `false` to hide page navigation and zoom controls |
352
352
  | `padding` | Non-negative CSS pixel value; `28` by default and `16` on narrow screens |
353
353
  | `initialScale` | `"fit-width"` (default) or a numeric scale |
354
354
  | `minScale` | `0.25` by default, clamped to at least `0.1` |
@@ -357,6 +357,7 @@ Pass these options to `PdfDocument.preview`:
357
357
  | `maxPixelRatio` | `2` by default; caps page-canvas device pixel ratio |
358
358
  | `ariaLabel` | `"PDF preview"` by default |
359
359
  | `onProgress` | Callback after each page canvas completes |
360
+ | `onPageChange` | Callback after initial loading and whenever the 1-based current page changes |
360
361
 
361
362
  ### html2pdf.js compatibility options
362
363
 
@@ -421,8 +422,16 @@ all previews it owns.
421
422
  ```ts
422
423
  const preview = await pdf.preview(document.querySelector("#preview")!, {
423
424
  initialScale: "fit-width",
425
+ onPageChange(currentPage, totalPages) {
426
+ document.querySelector("#page-count")!.textContent = `Page ${currentPage} of ${totalPages}`;
427
+ },
424
428
  });
425
429
 
430
+ document.querySelector("#previous")!.addEventListener("click", () => preview.previousPage());
431
+ document.querySelector("#next")!.addEventListener("click", () => preview.nextPage());
432
+ preview.goToPage(7); // Clamped to the first or last page when outside the document range.
433
+ console.log(preview.currentPage);
434
+
426
435
  preview.dispose();
427
436
  pdf.dispose();
428
437
  ```