@pixldocs/canvas-renderer 0.5.157 → 0.5.159
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-NR05ndTM.cjs → index-CA-UhjM7.cjs} +101 -7
- package/dist/{index-NR05ndTM.cjs.map → index-CA-UhjM7.cjs.map} +1 -1
- package/dist/{index-xn-L7QHB.js → index-ogNxtubz.js} +101 -7
- package/dist/{index-xn-L7QHB.js.map → index-ogNxtubz.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{svgTextToPath-7fhL08qs.cjs → pdfFonts-BTEVnYX8.cjs} +31 -796
- package/dist/pdfFonts-BTEVnYX8.cjs.map +1 -0
- package/dist/{svgTextToPath-V1vC0SQt.js → pdfFonts-b3_bv7F0.js} +20 -747
- package/dist/pdfFonts-b3_bv7F0.js.map +1 -0
- package/dist/svgTextToPath-BXAzwaaR.js +706 -0
- package/dist/svgTextToPath-BXAzwaaR.js.map +1 -0
- package/dist/svgTextToPath-IM1f6F-f.cjs +745 -0
- package/dist/svgTextToPath-IM1f6F-f.cjs.map +1 -0
- package/dist/{vectorPdfExport-CZyyQbwm.js → vectorPdfExport-BRxfHxZU.js} +8 -54
- package/dist/vectorPdfExport-BRxfHxZU.js.map +1 -0
- package/dist/{vectorPdfExport-CTktki-M.cjs → vectorPdfExport-BqyoXT--.cjs} +8 -54
- package/dist/vectorPdfExport-BqyoXT--.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/svgTextToPath-7fhL08qs.cjs.map +0 -1
- package/dist/svgTextToPath-V1vC0SQt.js.map +0 -1
- package/dist/vectorPdfExport-CTktki-M.cjs.map +0 -1
- package/dist/vectorPdfExport-CZyyQbwm.js.map +0 -1
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jspdf = require("jspdf");
|
|
4
4
|
const svg2pdf_js = require("svg2pdf.js");
|
|
5
5
|
const fabric = require("fabric");
|
|
6
|
-
const index = require("./index-
|
|
7
|
-
const pdfFonts = require("./
|
|
6
|
+
const index = require("./index-CA-UhjM7.cjs");
|
|
7
|
+
const pdfFonts = require("./pdfFonts-BTEVnYX8.cjs");
|
|
8
8
|
function _interopNamespaceDefault(e) {
|
|
9
9
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
10
|
if (e) {
|
|
@@ -31,7 +31,7 @@ async function embedFontsForSvg(pdf, svgStr) {
|
|
|
31
31
|
FONT_FALLBACK_SYMBOLS: FONT_FALLBACK_SYMBOLS2,
|
|
32
32
|
FONT_FALLBACK_DEVANAGARI: FONT_FALLBACK_DEVANAGARI2,
|
|
33
33
|
FONT_FALLBACK_MATH: FONT_FALLBACK_MATH2
|
|
34
|
-
} = await Promise.resolve().then(() => require("./
|
|
34
|
+
} = await Promise.resolve().then(() => require("./pdfFonts-BTEVnYX8.cjs"));
|
|
35
35
|
const parser = new DOMParser();
|
|
36
36
|
const doc = parser.parseFromString(svgStr, "image/svg+xml");
|
|
37
37
|
const textEls = Array.from(doc.querySelectorAll("text, tspan, textPath"));
|
|
@@ -1327,45 +1327,6 @@ async function bakeTextAnchorPositionsFromLiveSvg(svg) {
|
|
|
1327
1327
|
}
|
|
1328
1328
|
}
|
|
1329
1329
|
}
|
|
1330
|
-
function appendInvisibleSelectableTextLayer(svg) {
|
|
1331
|
-
var _a;
|
|
1332
|
-
const doc = svg.ownerDocument;
|
|
1333
|
-
if (!doc) return;
|
|
1334
|
-
const texts = Array.from(svg.querySelectorAll("text"));
|
|
1335
|
-
if (texts.length === 0) return;
|
|
1336
|
-
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
1337
|
-
const layer = doc.createElementNS(SVG_NS, "g");
|
|
1338
|
-
layer.setAttribute("data-pd-selectable-layer", "1");
|
|
1339
|
-
layer.setAttribute("fill", "none");
|
|
1340
|
-
layer.setAttribute("stroke", "none");
|
|
1341
|
-
layer.setAttribute("style", "fill: none; stroke: none;");
|
|
1342
|
-
let cloned = 0;
|
|
1343
|
-
for (const text of texts) {
|
|
1344
|
-
if ((_a = text.closest) == null ? void 0 : _a.call(text, '[data-pd-selectable-layer="1"]')) continue;
|
|
1345
|
-
if (!(text.textContent || "").trim()) continue;
|
|
1346
|
-
const clone = text.cloneNode(true);
|
|
1347
|
-
clone.setAttribute("fill", "none");
|
|
1348
|
-
clone.setAttribute("stroke", "none");
|
|
1349
|
-
clone.setAttribute("style", "fill: none; stroke: none;");
|
|
1350
|
-
clone.removeAttribute("opacity");
|
|
1351
|
-
clone.removeAttribute("fill-opacity");
|
|
1352
|
-
clone.removeAttribute("stroke-opacity");
|
|
1353
|
-
for (const child of Array.from(clone.querySelectorAll("*"))) {
|
|
1354
|
-
child.setAttribute("fill", "none");
|
|
1355
|
-
child.setAttribute("stroke", "none");
|
|
1356
|
-
child.setAttribute("style", "fill: none; stroke: none;");
|
|
1357
|
-
child.removeAttribute("opacity");
|
|
1358
|
-
child.removeAttribute("fill-opacity");
|
|
1359
|
-
child.removeAttribute("stroke-opacity");
|
|
1360
|
-
}
|
|
1361
|
-
layer.appendChild(clone);
|
|
1362
|
-
cloned++;
|
|
1363
|
-
}
|
|
1364
|
-
if (cloned > 0) {
|
|
1365
|
-
svg.appendChild(layer);
|
|
1366
|
-
console.log(`[Vector PDF][selectable-layer] appended ${cloned} invisible text clone(s)`);
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
1330
|
async function logTextMeasurementDiagnostic(svg) {
|
|
1370
1331
|
var _a, _b, _c, _d, _e;
|
|
1371
1332
|
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
@@ -1894,7 +1855,7 @@ async function collectInlinedFontFaceCss() {
|
|
|
1894
1855
|
return cachedInlinedFontFaceCss;
|
|
1895
1856
|
}
|
|
1896
1857
|
async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey, options) {
|
|
1897
|
-
var _a
|
|
1858
|
+
var _a;
|
|
1898
1859
|
try {
|
|
1899
1860
|
const parser = new DOMParser();
|
|
1900
1861
|
const processedSvg = inlineNestedSvgImageDataUris(rawSvg, parser);
|
|
@@ -1931,17 +1892,11 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
1931
1892
|
} catch (e) {
|
|
1932
1893
|
console.warn("[Vector PDF] anchor-bake pass failed (continuing):", e);
|
|
1933
1894
|
}
|
|
1934
|
-
appendInvisibleSelectableTextLayer(svgToDraw);
|
|
1935
1895
|
await rasterizeShadowMarkers(svgToDraw);
|
|
1936
1896
|
await convertTextDecorationsToLines(svgToDraw);
|
|
1937
|
-
const outlined = await pdfFonts.convertAllTextToPath(new XMLSerializer().serializeToString(svgToDraw), void 0, { mode: "all" });
|
|
1938
|
-
const outlinedDoc = parser.parseFromString(outlined, "image/svg+xml");
|
|
1939
|
-
if (!outlinedDoc.querySelector("parsererror") && ((_a = outlinedDoc.documentElement) == null ? void 0 : _a.tagName.toLowerCase()) === "svg") {
|
|
1940
|
-
svgToDraw = outlinedDoc.documentElement;
|
|
1941
|
-
}
|
|
1942
1897
|
const rewritten = rewriteSvgFontsForJsPDFWithSourceMeta(new XMLSerializer().serializeToString(svgToDraw));
|
|
1943
1898
|
const rewrittenDoc = parser.parseFromString(rewritten, "image/svg+xml");
|
|
1944
|
-
if (!rewrittenDoc.querySelector("parsererror") && ((
|
|
1899
|
+
if (!rewrittenDoc.querySelector("parsererror") && ((_a = rewrittenDoc.documentElement) == null ? void 0 : _a.tagName.toLowerCase()) === "svg") {
|
|
1945
1900
|
return rewrittenDoc.documentElement;
|
|
1946
1901
|
}
|
|
1947
1902
|
return svgToDraw;
|
|
@@ -2523,7 +2478,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
|
|
|
2523
2478
|
async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
|
|
2524
2479
|
if (!colorMap || Object.keys(colorMap).length === 0) return null;
|
|
2525
2480
|
try {
|
|
2526
|
-
const { getNormalizedSvgUrl } = await Promise.resolve().then(() => require("./index-
|
|
2481
|
+
const { getNormalizedSvgUrl } = await Promise.resolve().then(() => require("./index-CA-UhjM7.cjs")).then((n) => n.canvasImageLoader);
|
|
2527
2482
|
return await getNormalizedSvgUrl(imageUrl, colorMap);
|
|
2528
2483
|
} catch {
|
|
2529
2484
|
return null;
|
|
@@ -3304,7 +3259,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
|
|
|
3304
3259
|
}
|
|
3305
3260
|
let fetchUrl = imageUrl;
|
|
3306
3261
|
if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
|
|
3307
|
-
const { isPrivateUrl } = await Promise.resolve().then(() => require("./index-
|
|
3262
|
+
const { isPrivateUrl } = await Promise.resolve().then(() => require("./index-CA-UhjM7.cjs")).then((n) => n.canvasImageLoader);
|
|
3308
3263
|
if (isPrivateUrl(imageUrl)) return null;
|
|
3309
3264
|
const proxyUrl = new URL(`${index.API_URL}/image-proxy`);
|
|
3310
3265
|
proxyUrl.searchParams.set("url", imageUrl);
|
|
@@ -5277,7 +5232,6 @@ async function exportMultiPagePdf(pages, options) {
|
|
|
5277
5232
|
}
|
|
5278
5233
|
pdf.save(filename);
|
|
5279
5234
|
}
|
|
5280
|
-
exports.appendInvisibleSelectableTextLayer = appendInvisibleSelectableTextLayer;
|
|
5281
5235
|
exports.bakeTextAnchorPositionsFromLiveSvg = bakeTextAnchorPositionsFromLiveSvg;
|
|
5282
5236
|
exports.convertSvgTextDecorationsToLinesString = convertSvgTextDecorationsToLinesString;
|
|
5283
5237
|
exports.drawPreparedLiveCanvasSvgPageToPdf = drawPreparedLiveCanvasSvgPageToPdf;
|
|
@@ -5287,4 +5241,4 @@ exports.exportMultiPagePdf = exportMultiPagePdf;
|
|
|
5287
5241
|
exports.logTextMeasurementDiagnostic = logTextMeasurementDiagnostic;
|
|
5288
5242
|
exports.preparePagesForExport = preparePagesForExport;
|
|
5289
5243
|
exports.rewriteSvgFontsForJsPDFWithSourceMeta = rewriteSvgFontsForJsPDFWithSourceMeta;
|
|
5290
|
-
//# sourceMappingURL=vectorPdfExport-
|
|
5244
|
+
//# sourceMappingURL=vectorPdfExport-BqyoXT--.cjs.map
|