@pixldocs/canvas-renderer 0.5.172 → 0.5.174
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-DYtJJzdk.cjs → index-BH1kJLpb.cjs} +174 -67
- package/dist/index-BH1kJLpb.cjs.map +1 -0
- package/dist/{index-DuI8QJDd.js → index-DLAkGTqW.js} +174 -67
- package/dist/index-DLAkGTqW.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{pdfFonts-BTEVnYX8.cjs → pdfFonts-BTj2f465.cjs} +12 -3
- package/dist/pdfFonts-BTj2f465.cjs.map +1 -0
- package/dist/{pdfFonts-b3_bv7F0.js → pdfFonts-DhEaMTZl.js} +12 -3
- package/dist/pdfFonts-DhEaMTZl.js.map +1 -0
- package/dist/{svgTextToPath-IM1f6F-f.cjs → svgTextToPath-BLk_mcqi.cjs} +85 -3
- package/dist/svgTextToPath-BLk_mcqi.cjs.map +1 -0
- package/dist/{svgTextToPath-BXAzwaaR.js → svgTextToPath-ra4EhtBL.js} +86 -4
- package/dist/svgTextToPath-ra4EhtBL.js.map +1 -0
- package/dist/{vectorPdfExport-wH2x4QIj.js → vectorPdfExport-B4B0CPjW.js} +40 -10
- package/dist/vectorPdfExport-B4B0CPjW.js.map +1 -0
- package/dist/{vectorPdfExport-CDOztP1H.cjs → vectorPdfExport-wyGn4ybk.cjs} +40 -10
- package/dist/vectorPdfExport-wyGn4ybk.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/index-DYtJJzdk.cjs.map +0 -1
- package/dist/index-DuI8QJDd.js.map +0 -1
- package/dist/pdfFonts-BTEVnYX8.cjs.map +0 -1
- package/dist/pdfFonts-b3_bv7F0.js.map +0 -1
- package/dist/svgTextToPath-BXAzwaaR.js.map +0 -1
- package/dist/svgTextToPath-IM1f6F-f.cjs.map +0 -1
- package/dist/vectorPdfExport-CDOztP1H.cjs.map +0 -1
- package/dist/vectorPdfExport-wH2x4QIj.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
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-
|
|
5
|
-
import { resetPdfFontRegistry, FONT_FALLBACK_SYMBOLS, FONT_FALLBACK_MATH, FONT_FALLBACK_DEVANAGARI, embedFontWithGoogleFallback, getEmbeddedVariantsList, isFontAvailable, isFamilyEmbedded, resolveBestRegisteredVariant, getEmbeddedJsPDFFontName, resolveFontWeight, doesVariantSupportChar } from "./pdfFonts-
|
|
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-DLAkGTqW.js";
|
|
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;
|
|
8
8
|
const {
|
|
@@ -12,7 +12,7 @@ async function embedFontsForSvg(pdf, svgStr) {
|
|
|
12
12
|
FONT_FALLBACK_SYMBOLS: FONT_FALLBACK_SYMBOLS2,
|
|
13
13
|
FONT_FALLBACK_DEVANAGARI: FONT_FALLBACK_DEVANAGARI2,
|
|
14
14
|
FONT_FALLBACK_MATH: FONT_FALLBACK_MATH2
|
|
15
|
-
} = await import("./pdfFonts-
|
|
15
|
+
} = await import("./pdfFonts-DhEaMTZl.js");
|
|
16
16
|
const parser = new DOMParser();
|
|
17
17
|
const doc = parser.parseFromString(svgStr, "image/svg+xml");
|
|
18
18
|
const textEls = Array.from(doc.querySelectorAll("text, tspan, textPath"));
|
|
@@ -2500,7 +2500,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
|
|
|
2500
2500
|
async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
|
|
2501
2501
|
if (!colorMap || Object.keys(colorMap).length === 0) return null;
|
|
2502
2502
|
try {
|
|
2503
|
-
const { getNormalizedSvgUrl } = await import("./index-
|
|
2503
|
+
const { getNormalizedSvgUrl } = await import("./index-DLAkGTqW.js").then((n) => n.a2);
|
|
2504
2504
|
return await getNormalizedSvgUrl(imageUrl, colorMap);
|
|
2505
2505
|
} catch {
|
|
2506
2506
|
return null;
|
|
@@ -2529,8 +2529,18 @@ function normalizeElement(el) {
|
|
|
2529
2529
|
const skewY = el.skewY ?? 0;
|
|
2530
2530
|
const style = el.style || {};
|
|
2531
2531
|
const opacity = el.opacity ?? style.opacity ?? 1;
|
|
2532
|
-
const
|
|
2533
|
-
|
|
2532
|
+
const firstStop = (g) => {
|
|
2533
|
+
var _a2;
|
|
2534
|
+
const stops = g == null ? void 0 : g.stops;
|
|
2535
|
+
if (!Array.isArray(stops) || stops.length === 0) return null;
|
|
2536
|
+
const sorted = [...stops].sort((a, b) => (Number(a == null ? void 0 : a.offset) || 0) - (Number(b == null ? void 0 : b.offset) || 0));
|
|
2537
|
+
const c = (_a2 = sorted[0]) == null ? void 0 : _a2.color;
|
|
2538
|
+
return typeof c === "string" && c ? c : null;
|
|
2539
|
+
};
|
|
2540
|
+
const fillGradientFirst = firstStop(el.fillGradient);
|
|
2541
|
+
const strokeGradientFirst = firstStop(el.strokeGradient);
|
|
2542
|
+
const fill = fillGradientFirst ?? (el.fill || style.fill || "");
|
|
2543
|
+
const stroke = strokeGradientFirst ?? (el.stroke || style.stroke || "");
|
|
2534
2544
|
const strokeWidth = el.strokeWidth ?? style.strokeWidth ?? 0;
|
|
2535
2545
|
const strokeDashArray = ((_e = el.strokeDashArray) == null ? void 0 : _e.join(",")) || style.strokeDasharray;
|
|
2536
2546
|
const text = el.text || el.content || "";
|
|
@@ -3281,7 +3291,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
|
|
|
3281
3291
|
}
|
|
3282
3292
|
let fetchUrl = imageUrl;
|
|
3283
3293
|
if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
|
|
3284
|
-
const { isPrivateUrl } = await import("./index-
|
|
3294
|
+
const { isPrivateUrl } = await import("./index-DLAkGTqW.js").then((n) => n.a2);
|
|
3285
3295
|
if (isPrivateUrl(imageUrl)) return null;
|
|
3286
3296
|
const proxyUrl = new URL(`${API_URL}/image-proxy`);
|
|
3287
3297
|
proxyUrl.searchParams.set("url", imageUrl);
|
|
@@ -4888,7 +4898,7 @@ function preparePagesForExport(pages, canvasWidth, canvasHeight, options) {
|
|
|
4888
4898
|
}
|
|
4889
4899
|
async function exportMultiPagePdf(pages, options) {
|
|
4890
4900
|
var _a, _b, _c, _d, _e;
|
|
4891
|
-
const { filename = "document.pdf", title, watermark = false, returnBlob = false } = options;
|
|
4901
|
+
const { filename = "document.pdf", title, watermark = false, returnBlob = false, pdfTextMode = "selectable" } = options;
|
|
4892
4902
|
resetPdfFontRegistry();
|
|
4893
4903
|
if (pages.length === 0) {
|
|
4894
4904
|
throw new Error("No pages to export");
|
|
@@ -5047,8 +5057,28 @@ async function exportMultiPagePdf(pages, options) {
|
|
|
5047
5057
|
} catch (fontEmbedErr) {
|
|
5048
5058
|
console.warn("[client-pdf-export] JIT font embed for live SVG failed", fontEmbedErr);
|
|
5049
5059
|
}
|
|
5060
|
+
let preppedSvgString = liveSvgString;
|
|
5061
|
+
try {
|
|
5062
|
+
if (pdfTextMode === "auto" || pdfTextMode === "pixel-perfect") {
|
|
5063
|
+
const { convertDevanagariTextToPath } = await import("./svgTextToPath-ra4EhtBL.js");
|
|
5064
|
+
preppedSvgString = await convertDevanagariTextToPath(
|
|
5065
|
+
liveSvgString,
|
|
5066
|
+
void 0,
|
|
5067
|
+
{ mode: "gradient-only" }
|
|
5068
|
+
);
|
|
5069
|
+
} else {
|
|
5070
|
+
const { replaceGradientTextFillsWithFirstStop } = await import("./svgTextToPath-ra4EhtBL.js");
|
|
5071
|
+
preppedSvgString = replaceGradientTextFillsWithFirstStop(liveSvgString);
|
|
5072
|
+
}
|
|
5073
|
+
console.log("[client-pdf-export] gradient text mode", {
|
|
5074
|
+
pdfTextMode,
|
|
5075
|
+
outlinedGradientText: pdfTextMode === "auto" || pdfTextMode === "pixel-perfect"
|
|
5076
|
+
});
|
|
5077
|
+
} catch (gradErr) {
|
|
5078
|
+
console.warn("[client-pdf-export] gradient-text fill resolution failed", gradErr);
|
|
5079
|
+
}
|
|
5050
5080
|
const liveSvg = await prepareLiveCanvasSvgForPdf(
|
|
5051
|
-
|
|
5081
|
+
preppedSvgString,
|
|
5052
5082
|
liveSvgWidth,
|
|
5053
5083
|
liveSvgHeight,
|
|
5054
5084
|
`page-${pageIndex + 1}`,
|
|
@@ -5265,4 +5295,4 @@ export {
|
|
|
5265
5295
|
preparePagesForExport,
|
|
5266
5296
|
rewriteSvgFontsForJsPDFWithSourceMeta
|
|
5267
5297
|
};
|
|
5268
|
-
//# sourceMappingURL=vectorPdfExport-
|
|
5298
|
+
//# sourceMappingURL=vectorPdfExport-B4B0CPjW.js.map
|