@pixldocs/canvas-renderer 0.5.461 → 0.5.463
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-COG7WTYO.js → index-CJ3vY_6d.js} +47 -15
- package/dist/index-CJ3vY_6d.js.map +1 -0
- package/dist/{index-D1sMo2it.cjs → index-kf9OkhGi.cjs} +47 -15
- package/dist/index-kf9OkhGi.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-Bn1wgD8Q.js → vectorPdfExport-BlCi6g1y.js} +34 -10
- package/dist/{vectorPdfExport-Bn1wgD8Q.js.map → vectorPdfExport-BlCi6g1y.js.map} +1 -1
- package/dist/{vectorPdfExport-C7mmAR68.cjs → vectorPdfExport-DFhh1h5p.cjs} +34 -10
- package/dist/{vectorPdfExport-C7mmAR68.cjs.map → vectorPdfExport-DFhh1h5p.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/index-COG7WTYO.js.map +0 -1
- package/dist/index-D1sMo2it.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-kf9OkhGi.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-kf9OkhGi.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-kf9OkhGi.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,15 +4790,27 @@ 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";
|
|
4795
|
+
const containScaleVal = Math.max(1, Math.min(3, Number(element.containScale ?? 1)));
|
|
4793
4796
|
const cropSvgRect = (clipX, clipY, clipW, clipH) => {
|
|
4794
4797
|
const baseScale = fitContain ? Math.min(clipW / naturalW, clipH / naturalH) : Math.max(clipW / naturalW, clipH / naturalH);
|
|
4795
|
-
const finalScale = baseScale * (fitContain ?
|
|
4798
|
+
const finalScale = baseScale * (fitContain ? containScaleVal : cropZoomVal);
|
|
4796
4799
|
const drawW = naturalW * finalScale;
|
|
4797
4800
|
const drawH = naturalH * finalScale;
|
|
4798
4801
|
const overflowX = Math.max(0, drawW - clipW);
|
|
4799
4802
|
const overflowY = Math.max(0, drawH - clipH);
|
|
4800
|
-
|
|
4801
|
-
|
|
4803
|
+
let offX = 0;
|
|
4804
|
+
let offY = 0;
|
|
4805
|
+
if (fitContain) {
|
|
4806
|
+
const slackX = clipW - drawW;
|
|
4807
|
+
const slackY = clipH - drawH;
|
|
4808
|
+
offX = alignH === "left" ? -slackX / 2 : alignH === "right" ? slackX / 2 : 0;
|
|
4809
|
+
offY = alignV === "top" ? -slackY / 2 : alignV === "bottom" ? slackY / 2 : 0;
|
|
4810
|
+
} else {
|
|
4811
|
+
offX = overflowX > 0 ? -overflowX * (cropPanXVal - 0.5) : 0;
|
|
4812
|
+
offY = overflowY > 0 ? -overflowY * (cropPanYVal - 0.5) : 0;
|
|
4813
|
+
}
|
|
4802
4814
|
return {
|
|
4803
4815
|
x: clipX + clipW / 2 + offX - drawW / 2,
|
|
4804
4816
|
y: clipY + clipH / 2 + offY - drawH / 2,
|
|
@@ -5464,14 +5476,26 @@ async function drawElementContentCore(pdf, element, norm, x, y, w, h, embeddedFo
|
|
|
5464
5476
|
const naturalW = Math.max(1, Number(element.imageNaturalWidth ?? 0) || w);
|
|
5465
5477
|
const naturalH = Math.max(1, Number(element.imageNaturalHeight ?? 0) || h);
|
|
5466
5478
|
const fitContain = (element.imageFit ?? "cover") === "contain";
|
|
5479
|
+
const containScaleVal = Math.max(1, Math.min(3, Number(element.containScale ?? 1)));
|
|
5467
5480
|
const baseScale = fitContain ? Math.min(w / naturalW, h / naturalH) : Math.max(w / naturalW, h / naturalH);
|
|
5468
|
-
const finalScale = baseScale * (fitContain ?
|
|
5481
|
+
const finalScale = baseScale * (fitContain ? containScaleVal : cropZoom);
|
|
5469
5482
|
const drawW = naturalW * finalScale;
|
|
5470
5483
|
const drawH = naturalH * finalScale;
|
|
5471
5484
|
const overflowX = Math.max(0, drawW - w);
|
|
5472
5485
|
const overflowY = Math.max(0, drawH - h);
|
|
5473
|
-
const
|
|
5474
|
-
const
|
|
5486
|
+
const alignH = element.imageAlignH ?? "center";
|
|
5487
|
+
const alignV = element.imageAlignV ?? "middle";
|
|
5488
|
+
let offsetX = 0;
|
|
5489
|
+
let offsetY = 0;
|
|
5490
|
+
if (fitContain) {
|
|
5491
|
+
const slackX = w - drawW;
|
|
5492
|
+
const slackY = h - drawH;
|
|
5493
|
+
offsetX = alignH === "left" ? -slackX / 2 : alignH === "right" ? slackX / 2 : 0;
|
|
5494
|
+
offsetY = alignV === "top" ? -slackY / 2 : alignV === "bottom" ? slackY / 2 : 0;
|
|
5495
|
+
} else {
|
|
5496
|
+
offsetX = overflowX > 0 ? -overflowX * (cropPanX - 0.5) : 0;
|
|
5497
|
+
offsetY = overflowY > 0 ? -overflowY * (cropPanY - 0.5) : 0;
|
|
5498
|
+
}
|
|
5475
5499
|
const svgX = x + w / 2 + offsetX - drawW / 2;
|
|
5476
5500
|
const svgY = y + h / 2 + offsetY - drawH / 2;
|
|
5477
5501
|
try {
|
|
@@ -6192,4 +6216,4 @@ exports.exportMultiPagePdf = exportMultiPagePdf;
|
|
|
6192
6216
|
exports.logTextMeasurementDiagnostic = logTextMeasurementDiagnostic;
|
|
6193
6217
|
exports.preparePagesForExport = preparePagesForExport;
|
|
6194
6218
|
exports.rewriteSvgFontsForJsPDFWithSourceMeta = rewriteSvgFontsForJsPDFWithSourceMeta;
|
|
6195
|
-
//# sourceMappingURL=vectorPdfExport-
|
|
6219
|
+
//# sourceMappingURL=vectorPdfExport-DFhh1h5p.cjs.map
|