@pixldocs/canvas-renderer 0.5.161 → 0.5.163
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-Co0kEgTl.js → index-BJTAZJHO.js} +58 -6
- package/dist/{index-Co0kEgTl.js.map → index-BJTAZJHO.js.map} +1 -1
- package/dist/{index-OWSb_i03.cjs → index-Dct1bg7t.cjs} +58 -6
- package/dist/{index-OWSb_i03.cjs.map → index-Dct1bg7t.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-CqdQi3YK.cjs → vectorPdfExport-Cxegm-1t.cjs} +46 -5
- package/dist/vectorPdfExport-Cxegm-1t.cjs.map +1 -0
- package/dist/{vectorPdfExport-B_T8jiQ3.js → vectorPdfExport-DdZj8pHe.js} +46 -5
- package/dist/vectorPdfExport-DdZj8pHe.js.map +1 -0
- package/package.json +1 -1
- package/dist/vectorPdfExport-B_T8jiQ3.js.map +0 -1
- package/dist/vectorPdfExport-CqdQi3YK.cjs.map +0 -1
|
@@ -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-
|
|
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-BJTAZJHO.js";
|
|
5
5
|
import { resetPdfFontRegistry, FONT_FALLBACK_SYMBOLS, FONT_FALLBACK_MATH, FONT_FALLBACK_DEVANAGARI, embedFontWithGoogleFallback, getEmbeddedVariantsList, isFontAvailable, isFamilyEmbedded, resolveBestRegisteredVariant, getEmbeddedJsPDFFontName, resolveFontWeight, doesVariantSupportChar } from "./pdfFonts-b3_bv7F0.js";
|
|
6
6
|
async function embedFontsForSvg(pdf, svgStr) {
|
|
7
7
|
var _a;
|
|
@@ -1247,9 +1247,19 @@ async function bakeTextAnchorPositionsFromLiveSvg(svg) {
|
|
|
1247
1247
|
return NaN;
|
|
1248
1248
|
};
|
|
1249
1249
|
const bakeNode = (srcNode, liveNode, anchorOverride, refXOverride) => {
|
|
1250
|
-
if (srcNode.getAttribute("data-pd-line-anchor") === "1") return;
|
|
1251
1250
|
const anchor = (anchorOverride || _resolveAnchor(srcNode)).trim().toLowerCase();
|
|
1252
1251
|
if (anchor !== "middle" && anchor !== "end") return;
|
|
1252
|
+
const stampedWidth = parseFloat(srcNode.getAttribute("data-pd-line-width") || "");
|
|
1253
|
+
const stampedStart = parseFloat(srcNode.getAttribute("data-pd-line-start") || "");
|
|
1254
|
+
if (Number.isFinite(stampedWidth) && stampedWidth > 0 && Number.isFinite(stampedStart)) {
|
|
1255
|
+
srcNode.setAttribute("x", String(stampedStart));
|
|
1256
|
+
srcNode.setAttribute("text-anchor", "start");
|
|
1257
|
+
srcNode.setAttribute("textLength", String(stampedWidth));
|
|
1258
|
+
srcNode.setAttribute("lengthAdjust", "spacing");
|
|
1259
|
+
stripTextAnchorStyle(srcNode);
|
|
1260
|
+
baked++;
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1253
1263
|
try {
|
|
1254
1264
|
const content = srcNode.textContent || "";
|
|
1255
1265
|
if (content.length > 0) {
|
|
@@ -1886,6 +1896,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
1886
1896
|
}
|
|
1887
1897
|
}
|
|
1888
1898
|
async function drawPreparedLiveCanvasSvgPageToPdf(options) {
|
|
1899
|
+
var _a;
|
|
1889
1900
|
const { rawSvg, pdf, pageWidth, pageHeight, pageKey, stripPageBackground } = options;
|
|
1890
1901
|
const svgToDraw = await prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey, {
|
|
1891
1902
|
stripPageBackground
|
|
@@ -1897,6 +1908,36 @@ async function drawPreparedLiveCanvasSvgPageToPdf(options) {
|
|
|
1897
1908
|
pdf.saveGraphicsState();
|
|
1898
1909
|
setPdfColorFromSvg(pdf, svgToDraw);
|
|
1899
1910
|
const pdfToUse = pdfWithColorLogging(pdf);
|
|
1911
|
+
try {
|
|
1912
|
+
const texts = Array.from(svgToDraw.querySelectorAll("text"));
|
|
1913
|
+
for (let i = 0; i < texts.length; i++) {
|
|
1914
|
+
const t = texts[i];
|
|
1915
|
+
const content = (t.textContent || "").replace(/\s+/g, " ").trim().slice(0, 60);
|
|
1916
|
+
const tspans = Array.from(t.querySelectorAll("tspan")).map((s) => ({
|
|
1917
|
+
x: s.getAttribute("x"),
|
|
1918
|
+
y: s.getAttribute("y"),
|
|
1919
|
+
text: (s.textContent || "").slice(0, 40)
|
|
1920
|
+
}));
|
|
1921
|
+
const parentG = ((_a = t.parentElement) == null ? void 0 : _a.tagName) === "g" ? t.parentElement : null;
|
|
1922
|
+
console.log("[svg-parity-dump]", JSON.stringify({
|
|
1923
|
+
page: pageKey,
|
|
1924
|
+
idx: i,
|
|
1925
|
+
snippet: content,
|
|
1926
|
+
textAttrs: {
|
|
1927
|
+
x: t.getAttribute("x"),
|
|
1928
|
+
y: t.getAttribute("y"),
|
|
1929
|
+
anchor: t.getAttribute("text-anchor"),
|
|
1930
|
+
fontFamily: t.getAttribute("font-family"),
|
|
1931
|
+
fontSize: t.getAttribute("font-size"),
|
|
1932
|
+
fontWeight: t.getAttribute("font-weight")
|
|
1933
|
+
},
|
|
1934
|
+
parentTransform: (parentG == null ? void 0 : parentG.getAttribute("transform")) || null,
|
|
1935
|
+
tspans
|
|
1936
|
+
}));
|
|
1937
|
+
}
|
|
1938
|
+
} catch (e) {
|
|
1939
|
+
console.warn("[svg-parity-dump] failed:", e);
|
|
1940
|
+
}
|
|
1900
1941
|
await svg2pdfWithDomMount(svgToDraw, pdfToUse, svg2pdfOpts(0, 0, pageWidth, pageHeight));
|
|
1901
1942
|
pdf.restoreGraphicsState();
|
|
1902
1943
|
pdf.setFillColor(0, 0, 0);
|
|
@@ -2459,7 +2500,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
|
|
|
2459
2500
|
async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
|
|
2460
2501
|
if (!colorMap || Object.keys(colorMap).length === 0) return null;
|
|
2461
2502
|
try {
|
|
2462
|
-
const { getNormalizedSvgUrl } = await import("./index-
|
|
2503
|
+
const { getNormalizedSvgUrl } = await import("./index-BJTAZJHO.js").then((n) => n.$);
|
|
2463
2504
|
return await getNormalizedSvgUrl(imageUrl, colorMap);
|
|
2464
2505
|
} catch {
|
|
2465
2506
|
return null;
|
|
@@ -3240,7 +3281,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
|
|
|
3240
3281
|
}
|
|
3241
3282
|
let fetchUrl = imageUrl;
|
|
3242
3283
|
if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
|
|
3243
|
-
const { isPrivateUrl } = await import("./index-
|
|
3284
|
+
const { isPrivateUrl } = await import("./index-BJTAZJHO.js").then((n) => n.$);
|
|
3244
3285
|
if (isPrivateUrl(imageUrl)) return null;
|
|
3245
3286
|
const proxyUrl = new URL(`${API_URL}/image-proxy`);
|
|
3246
3287
|
proxyUrl.searchParams.set("url", imageUrl);
|
|
@@ -5224,4 +5265,4 @@ export {
|
|
|
5224
5265
|
preparePagesForExport,
|
|
5225
5266
|
rewriteSvgFontsForJsPDFWithSourceMeta
|
|
5226
5267
|
};
|
|
5227
|
-
//# sourceMappingURL=vectorPdfExport-
|
|
5268
|
+
//# sourceMappingURL=vectorPdfExport-DdZj8pHe.js.map
|