@pixldocs/canvas-renderer 0.5.65 → 0.5.67
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.cjs +31 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +31 -5
- package/dist/index.js.map +1 -1
- package/dist/svgTextToPath-BP0Kppla.js +1083 -0
- package/dist/svgTextToPath-BP0Kppla.js.map +1 -0
- package/dist/svgTextToPath-BTHnqJpM.cjs +1105 -0
- package/dist/svgTextToPath-BTHnqJpM.cjs.map +1 -0
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -254,7 +254,7 @@ export declare function normalizeFontFamily(fontStack: string): string;
|
|
|
254
254
|
* Package version banner. Bump alongside package.json so we can confirm
|
|
255
255
|
* (via browser:log) that the deployed bundle matches the expected build.
|
|
256
256
|
*/
|
|
257
|
-
export declare const PACKAGE_VERSION = "0.5.
|
|
257
|
+
export declare const PACKAGE_VERSION = "0.5.67";
|
|
258
258
|
|
|
259
259
|
export declare interface PageSettings {
|
|
260
260
|
backgroundColor?: string;
|
|
@@ -272,6 +272,8 @@ export declare interface PdfAssemblyOptions {
|
|
|
272
272
|
stripPageBackground?: boolean;
|
|
273
273
|
/** Base URL for TTF font files (e.g. 'https://pixldocs.com/fonts/' or '/fonts/'). Required for correct font rendering. */
|
|
274
274
|
fontBaseUrl?: string;
|
|
275
|
+
/** Convert SVG text to paths before svg2pdf. Default: false — keep live Fabric SVG text for preview/PDF metric parity. */
|
|
276
|
+
outlineText?: boolean;
|
|
275
277
|
}
|
|
276
278
|
|
|
277
279
|
/** Options for PDF rendering */
|
package/dist/index.js
CHANGED
|
@@ -12542,7 +12542,7 @@ function PixldocsPreview(props) {
|
|
|
12542
12542
|
!canvasSettled && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
|
|
12543
12543
|
] });
|
|
12544
12544
|
}
|
|
12545
|
-
const PACKAGE_VERSION = "0.5.
|
|
12545
|
+
const PACKAGE_VERSION = "0.5.67";
|
|
12546
12546
|
let __underlineFixInstalled = false;
|
|
12547
12547
|
function installUnderlineFix(fab) {
|
|
12548
12548
|
var _a;
|
|
@@ -15198,6 +15198,14 @@ async function svg2pdfWithDomMount(svg, pdf, opts) {
|
|
|
15198
15198
|
async function convertTextDecorationsToLines(svg) {
|
|
15199
15199
|
const doc = svg.ownerDocument;
|
|
15200
15200
|
if (!doc) return;
|
|
15201
|
+
const stripTextDecoration = (el) => {
|
|
15202
|
+
el.removeAttribute("text-decoration");
|
|
15203
|
+
const style = el.getAttribute("style") || "";
|
|
15204
|
+
if (!style) return;
|
|
15205
|
+
const kept = style.split(";").map((part) => part.trim()).filter(Boolean).filter((part) => !/^text-decoration\s*:/i.test(part));
|
|
15206
|
+
if (kept.length > 0) el.setAttribute("style", kept.join("; "));
|
|
15207
|
+
else el.removeAttribute("style");
|
|
15208
|
+
};
|
|
15201
15209
|
const resolveInheritedSvgValue = (el, attr, styleProp = attr) => {
|
|
15202
15210
|
var _a, _b;
|
|
15203
15211
|
let current = el;
|
|
@@ -15348,6 +15356,8 @@ async function convertTextDecorationsToLines(svg) {
|
|
|
15348
15356
|
if (textEl.parentElement) {
|
|
15349
15357
|
textEl.parentElement.insertBefore(line, textEl.nextSibling);
|
|
15350
15358
|
}
|
|
15359
|
+
stripTextDecoration(tspan);
|
|
15360
|
+
if (textHasUnderline) stripTextDecoration(textEl);
|
|
15351
15361
|
}
|
|
15352
15362
|
}
|
|
15353
15363
|
if (tempContainer) {
|
|
@@ -15586,7 +15596,7 @@ function drawPageBackground(pdf, pageIndex, pageWidth, pageHeight, backgroundCol
|
|
|
15586
15596
|
}
|
|
15587
15597
|
}
|
|
15588
15598
|
async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
15589
|
-
var _a, _b;
|
|
15599
|
+
var _a, _b, _c;
|
|
15590
15600
|
if (svgResults.length === 0) throw new Error("No pages to export");
|
|
15591
15601
|
const { title, stripPageBackground } = options;
|
|
15592
15602
|
const firstPage = svgResults[0];
|
|
@@ -15614,17 +15624,33 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
|
15614
15624
|
const hasGradient = !!((_b = (_a = page.backgroundGradient) == null ? void 0 : _a.stops) == null ? void 0 : _b.length);
|
|
15615
15625
|
drawPageBackground(pdf, i, page.width, page.height, page.backgroundColor, page.backgroundGradient);
|
|
15616
15626
|
const shouldStripBg = stripPageBackground ?? hasGradient;
|
|
15627
|
+
const shouldOutlineText = options.outlineText === true;
|
|
15617
15628
|
const pageSvg = page.svg;
|
|
15618
15629
|
let processedSvg = await prepareLiveCanvasSvgForPdf(pageSvg, page.width, page.height, `page-${i + 1}`, {
|
|
15619
15630
|
stripPageBackground: shouldStripBg
|
|
15620
15631
|
});
|
|
15621
15632
|
if (processedSvg) {
|
|
15622
|
-
|
|
15623
|
-
|
|
15633
|
+
await convertTextDecorationsToLines(processedSvg);
|
|
15634
|
+
if (shouldOutlineText) {
|
|
15635
|
+
try {
|
|
15636
|
+
const { convertAllTextToPath } = await import("./svgTextToPath-BP0Kppla.js");
|
|
15637
|
+
const outlinedSvg = await convertAllTextToPath(
|
|
15638
|
+
new XMLSerializer().serializeToString(processedSvg),
|
|
15639
|
+
fontBaseUrl
|
|
15640
|
+
);
|
|
15641
|
+
const outlineDoc = new DOMParser().parseFromString(outlinedSvg, "image/svg+xml");
|
|
15642
|
+
const outlinedRoot = outlineDoc.documentElement;
|
|
15643
|
+
if (outlinedRoot && ((_c = outlinedRoot.tagName) == null ? void 0 : _c.toLowerCase()) === "svg" && !outlineDoc.querySelector("parsererror")) {
|
|
15644
|
+
processedSvg = outlinedRoot;
|
|
15645
|
+
}
|
|
15646
|
+
} catch (outlineErr) {
|
|
15647
|
+
console.warn("[canvas-renderer][pdf] text outlining unavailable, falling back to embedded SVG text:", outlineErr);
|
|
15648
|
+
}
|
|
15649
|
+
}
|
|
15650
|
+
const rewrittenSvg = rewriteSvgFontsForJsPDF(new XMLSerializer().serializeToString(processedSvg));
|
|
15624
15651
|
const reParser = new DOMParser();
|
|
15625
15652
|
const reDoc = reParser.parseFromString(rewrittenSvg, "image/svg+xml");
|
|
15626
15653
|
processedSvg = reDoc.documentElement;
|
|
15627
|
-
await convertTextDecorationsToLines(processedSvg);
|
|
15628
15654
|
}
|
|
15629
15655
|
if (processedSvg) {
|
|
15630
15656
|
pdf.setFillColor(0, 0, 0);
|