@pixldocs/canvas-renderer 0.5.460 → 0.5.462
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-CtJvkbzV.cjs → index-DjoKgogq.cjs} +45 -15
- package/dist/index-DjoKgogq.cjs.map +1 -0
- package/dist/{index-B306IfvT.js → index-DzpYcUNd.js} +45 -15
- package/dist/index-DzpYcUNd.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-CWiNW81v.js → vectorPdfExport-CFxK100y.js} +30 -8
- package/dist/{vectorPdfExport-CWiNW81v.js.map → vectorPdfExport-CFxK100y.js.map} +1 -1
- package/dist/{vectorPdfExport-B5Xxp9RH.cjs → vectorPdfExport-IjuMSK-o.cjs} +30 -8
- package/dist/{vectorPdfExport-B5Xxp9RH.cjs.map → vectorPdfExport-IjuMSK-o.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/index-B306IfvT.js.map +0 -1
- package/dist/index-CtJvkbzV.cjs.map +0 -1
|
@@ -3,7 +3,7 @@ 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-
|
|
6
|
+
const index = require("./index-DjoKgogq.cjs");
|
|
7
7
|
const pdfFonts = require("./pdfFonts-BTj2f465.cjs");
|
|
8
8
|
function _interopNamespaceDefault(e) {
|
|
9
9
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -3271,7 +3271,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
|
|
|
3271
3271
|
async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
|
|
3272
3272
|
if (!colorMap || Object.keys(colorMap).length === 0) return null;
|
|
3273
3273
|
try {
|
|
3274
|
-
const { getNormalizedSvgUrl } = await Promise.resolve().then(() => require("./index-
|
|
3274
|
+
const { getNormalizedSvgUrl } = await Promise.resolve().then(() => require("./index-DjoKgogq.cjs")).then((n) => n.canvasImageLoader);
|
|
3275
3275
|
return await getNormalizedSvgUrl(imageUrl, colorMap);
|
|
3276
3276
|
} catch {
|
|
3277
3277
|
return null;
|
|
@@ -4080,7 +4080,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
|
|
|
4080
4080
|
}
|
|
4081
4081
|
let fetchUrl = imageUrl;
|
|
4082
4082
|
if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
|
|
4083
|
-
const { isPrivateUrl } = await Promise.resolve().then(() => require("./index-
|
|
4083
|
+
const { isPrivateUrl } = await Promise.resolve().then(() => require("./index-DjoKgogq.cjs")).then((n) => n.canvasImageLoader);
|
|
4084
4084
|
if (isPrivateUrl(imageUrl)) return null;
|
|
4085
4085
|
const proxyUrl = new URL(`${index.API_URL}/image-proxy`);
|
|
4086
4086
|
proxyUrl.searchParams.set("url", imageUrl);
|
|
@@ -4790,6 +4790,8 @@ async function drawElement(pdf, element, embeddedFonts, canvasWidth, canvasHeigh
|
|
|
4790
4790
|
const naturalW = Math.max(1, Number(element.imageNaturalWidth ?? 0) || Number(((_g = cropData == null ? void 0 : cropData._img) == null ? void 0 : _g.width) ?? 0) || frameW);
|
|
4791
4791
|
const naturalH = Math.max(1, Number(element.imageNaturalHeight ?? 0) || Number(((_h = cropData == null ? void 0 : cropData._img) == null ? void 0 : _h.height) ?? 0) || frameH);
|
|
4792
4792
|
const fitContain = ((cropData == null ? void 0 : cropData.fit) ?? element.imageFit ?? "cover") === "contain";
|
|
4793
|
+
const alignH = element.imageAlignH ?? "center";
|
|
4794
|
+
const alignV = element.imageAlignV ?? "middle";
|
|
4793
4795
|
const cropSvgRect = (clipX, clipY, clipW, clipH) => {
|
|
4794
4796
|
const baseScale = fitContain ? Math.min(clipW / naturalW, clipH / naturalH) : Math.max(clipW / naturalW, clipH / naturalH);
|
|
4795
4797
|
const finalScale = baseScale * (fitContain ? 1 : cropZoomVal);
|
|
@@ -4797,8 +4799,17 @@ async function drawElement(pdf, element, embeddedFonts, canvasWidth, canvasHeigh
|
|
|
4797
4799
|
const drawH = naturalH * finalScale;
|
|
4798
4800
|
const overflowX = Math.max(0, drawW - clipW);
|
|
4799
4801
|
const overflowY = Math.max(0, drawH - clipH);
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
+
let offX = 0;
|
|
4803
|
+
let offY = 0;
|
|
4804
|
+
if (fitContain) {
|
|
4805
|
+
const slackX = Math.max(0, clipW - drawW);
|
|
4806
|
+
const slackY = Math.max(0, clipH - drawH);
|
|
4807
|
+
offX = alignH === "left" ? -slackX / 2 : alignH === "right" ? slackX / 2 : 0;
|
|
4808
|
+
offY = alignV === "top" ? -slackY / 2 : alignV === "bottom" ? slackY / 2 : 0;
|
|
4809
|
+
} else {
|
|
4810
|
+
offX = overflowX > 0 ? -overflowX * (cropPanXVal - 0.5) : 0;
|
|
4811
|
+
offY = overflowY > 0 ? -overflowY * (cropPanYVal - 0.5) : 0;
|
|
4812
|
+
}
|
|
4802
4813
|
return {
|
|
4803
4814
|
x: clipX + clipW / 2 + offX - drawW / 2,
|
|
4804
4815
|
y: clipY + clipH / 2 + offY - drawH / 2,
|
|
@@ -5470,8 +5481,19 @@ async function drawElementContentCore(pdf, element, norm, x, y, w, h, embeddedFo
|
|
|
5470
5481
|
const drawH = naturalH * finalScale;
|
|
5471
5482
|
const overflowX = Math.max(0, drawW - w);
|
|
5472
5483
|
const overflowY = Math.max(0, drawH - h);
|
|
5473
|
-
const
|
|
5474
|
-
const
|
|
5484
|
+
const alignH = element.imageAlignH ?? "center";
|
|
5485
|
+
const alignV = element.imageAlignV ?? "middle";
|
|
5486
|
+
let offsetX = 0;
|
|
5487
|
+
let offsetY = 0;
|
|
5488
|
+
if (fitContain) {
|
|
5489
|
+
const slackX = Math.max(0, w - drawW);
|
|
5490
|
+
const slackY = Math.max(0, h - drawH);
|
|
5491
|
+
offsetX = alignH === "left" ? -slackX / 2 : alignH === "right" ? slackX / 2 : 0;
|
|
5492
|
+
offsetY = alignV === "top" ? -slackY / 2 : alignV === "bottom" ? slackY / 2 : 0;
|
|
5493
|
+
} else {
|
|
5494
|
+
offsetX = overflowX > 0 ? -overflowX * (cropPanX - 0.5) : 0;
|
|
5495
|
+
offsetY = overflowY > 0 ? -overflowY * (cropPanY - 0.5) : 0;
|
|
5496
|
+
}
|
|
5475
5497
|
const svgX = x + w / 2 + offsetX - drawW / 2;
|
|
5476
5498
|
const svgY = y + h / 2 + offsetY - drawH / 2;
|
|
5477
5499
|
try {
|
|
@@ -6192,4 +6214,4 @@ exports.exportMultiPagePdf = exportMultiPagePdf;
|
|
|
6192
6214
|
exports.logTextMeasurementDiagnostic = logTextMeasurementDiagnostic;
|
|
6193
6215
|
exports.preparePagesForExport = preparePagesForExport;
|
|
6194
6216
|
exports.rewriteSvgFontsForJsPDFWithSourceMeta = rewriteSvgFontsForJsPDFWithSourceMeta;
|
|
6195
|
-
//# sourceMappingURL=vectorPdfExport-
|
|
6217
|
+
//# sourceMappingURL=vectorPdfExport-IjuMSK-o.cjs.map
|