@pixldocs/canvas-renderer 0.5.189 → 0.5.191

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.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-CmrxeQ_K.cjs");
3
+ const index = require("./index-BJR7zaam.cjs");
4
4
  exports.DEPLOYMENT_VERSION_MARKER = index.DEPLOYMENT_VERSION_MARKER;
5
5
  exports.FONT_FALLBACK_DEVANAGARI = index.FONT_FALLBACK_DEVANAGARI;
6
6
  exports.FONT_FALLBACK_MATH = index.FONT_FALLBACK_MATH;
package/dist/index.d.ts CHANGED
@@ -364,6 +364,15 @@ export declare interface PdfFromFormOptions {
364
364
  fontBaseUrl?: string;
365
365
  /** PDF text rendering mode. Default: selectable text for client vector-PDF parity. */
366
366
  textMode?: 'auto' | 'selectable' | 'pixel-perfect';
367
+ /**
368
+ * Per-call override of `RendererConfig.forcePerElementPdf`. See that field
369
+ * for semantics. Useful when only some templates need the iOS-safe path.
370
+ */
371
+ forcePerElementPdf?: boolean | 'auto';
372
+ /**
373
+ * Per-call override of `RendererConfig.maxImageEdgePx`. See that field.
374
+ */
375
+ maxImageEdgePx?: number;
367
376
  }
368
377
 
369
378
  export declare interface PdfRenderResult {
@@ -529,6 +538,8 @@ export declare class PixldocsRenderer {
529
538
  title?: string;
530
539
  fontBaseUrl?: string;
531
540
  textMode?: 'auto' | 'selectable' | 'pixel-perfect';
541
+ forcePerElementPdf?: boolean | 'auto';
542
+ maxImageEdgePx?: number;
532
543
  }): Promise<PdfRenderResult>;
533
544
  /**
534
545
  * Resolve from V2 sectionState and render a vector PDF.
@@ -636,6 +647,33 @@ export declare interface RendererConfig {
636
647
  assetWaitEarlyExitMs?: number;
637
648
  /** Verbose asset-wait diagnostics. Default: false. */
638
649
  debug?: boolean;
650
+ /**
651
+ * PDF export: when `true`, always skip the live-canvas SVG → svg2pdf fast
652
+ * path and use the per-element Fabric → jsPDF `addImage` path instead.
653
+ *
654
+ * Why: on iOS / Safari the svg2pdf path internally rasterises embedded
655
+ * `data:image/*` sources through a tainted offscreen canvas roundtrip and
656
+ * silently drops large user-uploaded JPEGs from camera-roll pickers. The
657
+ * per-element path goes straight from the live HTMLImageElement into
658
+ * jsPDF.addImage and is reliable across browsers.
659
+ *
660
+ * Default: `'auto'` — on by default for any config containing a
661
+ * `data:image/(jpeg|png|webp)` source when running on Safari / iOS;
662
+ * off everywhere else so the editor's vector fast path stays in use.
663
+ * Set to `true` to force on always (e.g. BioMaker), `false` to fully
664
+ * disable the auto-detect.
665
+ */
666
+ forcePerElementPdf?: boolean | 'auto';
667
+ /**
668
+ * PDF export: cap the longest edge (in pixels) of any rasterised user
669
+ * image (data URLs only) before handing it to the PDF exporter. Larger
670
+ * images are JPEG-recompressed in-browser to fit. Prevents Safari from
671
+ * silently failing to embed multi-megapixel camera-roll JPEGs.
672
+ *
673
+ * Default: `2048` when `forcePerElementPdf` is active, otherwise `0`
674
+ * (no downscaling). Set explicitly to override either way.
675
+ */
676
+ maxImageEdgePx?: number;
639
677
  }
640
678
 
641
679
  /** Options for renderFromForm — matches the server API payload */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D, F, o, q, s, P, t, u, v, w, x, y, z, B, C, E, G, H, I, J, K, L, M, b, N, O, Q, R, S, U, V, W, X, Y, Z, _, $, a0, a1, a2, a3, a4, a5 } from "./index-lQXXPpb8.js";
1
+ import { D, F, o, q, s, P, t, u, v, w, x, y, z, B, C, E, G, H, I, J, K, L, M, b, N, O, Q, R, S, U, V, W, X, Y, Z, _, $, a0, a1, a2, a3, a4, a5 } from "./index-C3kuDISv.js";
2
2
  export {
3
3
  D as DEPLOYMENT_VERSION_MARKER,
4
4
  F as FONT_FALLBACK_DEVANAGARI,
@@ -1,7 +1,7 @@
1
1
  import { jsPDF, ShadingPattern } from "jspdf";
2
2
  import { svg2pdf } from "svg2pdf.js";
3
3
  import * as fabric from "fabric";
4
- import { g as getCanvasForPage, c as captureFabricCanvasSvgForPdf, f as findNodeById, a as getAbsoluteBounds, p as parseTextMarkdown, r as renderSmartElementToSvg, n as normalizeShapeType, h as hasEdgeFade, b as getProxiedImageUrl, d as bakeEdgeFade, i as isElement, e as isGroup, j as buildRoundedTrianglePath, A as API_URL, k as getImageProxyFetchOptions, l as getRoundedRectRadii, T as TRIANGLE_STROKE_MITER_LIMIT, m as getTrianglePoints } from "./index-lQXXPpb8.js";
4
+ import { g as getCanvasForPage, c as captureFabricCanvasSvgForPdf, f as findNodeById, a as getAbsoluteBounds, p as parseTextMarkdown, r as renderSmartElementToSvg, n as normalizeShapeType, h as hasEdgeFade, b as getProxiedImageUrl, d as bakeEdgeFade, i as isElement, e as isGroup, j as buildRoundedTrianglePath, A as API_URL, k as getImageProxyFetchOptions, l as getRoundedRectRadii, T as TRIANGLE_STROKE_MITER_LIMIT, m as getTrianglePoints } from "./index-C3kuDISv.js";
5
5
  import { resetPdfFontRegistry, FONT_FALLBACK_SYMBOLS, FONT_FALLBACK_MATH, FONT_FALLBACK_DEVANAGARI, embedFontWithGoogleFallback, getEmbeddedVariantsList, isFontAvailable, isFamilyEmbedded, resolveBestRegisteredVariant, getEmbeddedJsPDFFontName, resolveFontWeight, doesVariantSupportChar } from "./pdfFonts-DhEaMTZl.js";
6
6
  async function embedFontsForSvg(pdf, svgStr) {
7
7
  var _a;
@@ -2506,7 +2506,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
2506
2506
  async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
2507
2507
  if (!colorMap || Object.keys(colorMap).length === 0) return null;
2508
2508
  try {
2509
- const { getNormalizedSvgUrl } = await import("./index-lQXXPpb8.js").then((n) => n.a6);
2509
+ const { getNormalizedSvgUrl } = await import("./index-C3kuDISv.js").then((n) => n.a6);
2510
2510
  return await getNormalizedSvgUrl(imageUrl, colorMap);
2511
2511
  } catch {
2512
2512
  return null;
@@ -3297,7 +3297,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
3297
3297
  }
3298
3298
  let fetchUrl = imageUrl;
3299
3299
  if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
3300
- const { isPrivateUrl } = await import("./index-lQXXPpb8.js").then((n) => n.a6);
3300
+ const { isPrivateUrl } = await import("./index-C3kuDISv.js").then((n) => n.a6);
3301
3301
  if (isPrivateUrl(imageUrl)) return null;
3302
3302
  const proxyUrl = new URL(`${API_URL}/image-proxy`);
3303
3303
  proxyUrl.searchParams.set("url", imageUrl);
@@ -4904,7 +4904,7 @@ function preparePagesForExport(pages, canvasWidth, canvasHeight, options) {
4904
4904
  }
4905
4905
  async function exportMultiPagePdf(pages, options) {
4906
4906
  var _a, _b, _c, _d, _e;
4907
- const { filename = "document.pdf", title, watermark = false, returnBlob = false, pdfTextMode = "selectable" } = options;
4907
+ const { filename = "document.pdf", title, watermark = false, returnBlob = false, pdfTextMode = "selectable", skipLiveCanvasSvgFastPath = false } = options;
4908
4908
  resetPdfFontRegistry();
4909
4909
  if (pages.length === 0) {
4910
4910
  throw new Error("No pages to export");
@@ -5048,8 +5048,8 @@ async function exportMultiPagePdf(pages, options) {
5048
5048
  }
5049
5049
  }
5050
5050
  const liveCanvasForPage = page.pageId ? getCanvasForPage(page.pageId) : null;
5051
- let allowLiveCanvasFallback = !!liveCanvasForPage;
5052
- if (liveCanvasForPage) {
5051
+ let allowLiveCanvasFallback = !!liveCanvasForPage && !skipLiveCanvasSvgFastPath;
5052
+ if (liveCanvasForPage && !skipLiveCanvasSvgFastPath) {
5053
5053
  try {
5054
5054
  const liveSvgString = captureFabricCanvasSvgForPdf(
5055
5055
  liveCanvasForPage,
@@ -5293,4 +5293,4 @@ export {
5293
5293
  preparePagesForExport,
5294
5294
  rewriteSvgFontsForJsPDFWithSourceMeta
5295
5295
  };
5296
- //# sourceMappingURL=vectorPdfExport-Ch-qwcNJ.js.map
5296
+ //# sourceMappingURL=vectorPdfExport-CrTGqxx6.js.map