@pixldocs/canvas-renderer 0.5.81 → 0.5.82
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 +21 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +21 -7
- package/dist/index.js.map +1 -1
- package/dist/{svgTextToPath-BP0Kppla.js → svgTextToPath-B5sT7sre.js} +24 -2
- package/dist/{svgTextToPath-BP0Kppla.js.map → svgTextToPath-B5sT7sre.js.map} +1 -1
- package/dist/{svgTextToPath-BTHnqJpM.cjs → svgTextToPath-DHAXuVMF.cjs} +24 -2
- package/dist/{svgTextToPath-BTHnqJpM.cjs.map → svgTextToPath-DHAXuVMF.cjs.map} +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12884,7 +12884,7 @@ class PixldocsRenderer {
|
|
|
12884
12884
|
async renderPdf(templateConfig, options) {
|
|
12885
12885
|
const svgs = await this.renderAllPageSvgs(templateConfig);
|
|
12886
12886
|
const { assemblePdfFromSvgs: assemblePdfFromSvgs2 } = await Promise.resolve().then(() => pdfExport);
|
|
12887
|
-
return assemblePdfFromSvgs2(svgs, { title: options == null ? void 0 : options.title, fontBaseUrl: options == null ? void 0 : options.fontBaseUrl });
|
|
12887
|
+
return assemblePdfFromSvgs2(svgs, { title: options == null ? void 0 : options.title, fontBaseUrl: options == null ? void 0 : options.fontBaseUrl, textMode: (options == null ? void 0 : options.textMode) ?? templateConfig.pdfTextMode ?? "selectable" });
|
|
12888
12888
|
}
|
|
12889
12889
|
/**
|
|
12890
12890
|
* Resolve from V2 sectionState and render a vector PDF.
|
|
@@ -12909,7 +12909,7 @@ class PixldocsRenderer {
|
|
|
12909
12909
|
}
|
|
12910
12910
|
const svgs = await this.renderAllPageSvgs(configToRender);
|
|
12911
12911
|
const { assemblePdfFromSvgs: assemblePdfFromSvgs2 } = await Promise.resolve().then(() => pdfExport);
|
|
12912
|
-
return assemblePdfFromSvgs2(svgs, { title: title ?? resolved.config.name, fontBaseUrl });
|
|
12912
|
+
return assemblePdfFromSvgs2(svgs, { title: title ?? resolved.config.name, fontBaseUrl, textMode: options.textMode ?? configToRender.pdfTextMode ?? "selectable" });
|
|
12913
12913
|
}
|
|
12914
12914
|
async renderById(templateId, formData, options) {
|
|
12915
12915
|
const resolved = await resolveTemplateData({
|
|
@@ -14159,10 +14159,22 @@ async function embedFont(pdf, fontName, weight, fontBaseUrl, isItalic = false) {
|
|
|
14159
14159
|
async function embedFontsForConfig(pdf, config, fontBaseUrl) {
|
|
14160
14160
|
const fontKeys = /* @__PURE__ */ new Set();
|
|
14161
14161
|
const SEP = "";
|
|
14162
|
+
const normalizeWeight = (raw) => {
|
|
14163
|
+
if (raw == null) return 400;
|
|
14164
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return resolveFontWeight(raw);
|
|
14165
|
+
const str = String(raw).trim().toLowerCase();
|
|
14166
|
+
const parsed = Number.parseInt(str, 10);
|
|
14167
|
+
if (Number.isFinite(parsed)) return resolveFontWeight(parsed);
|
|
14168
|
+
if (str === "bold" || str === "bolder") return 700;
|
|
14169
|
+
if (str === "semibold" || str === "demibold") return 600;
|
|
14170
|
+
if (str === "medium") return 500;
|
|
14171
|
+
if (str === "light" || str === "lighter" || str === "thin") return 300;
|
|
14172
|
+
return 400;
|
|
14173
|
+
};
|
|
14162
14174
|
const walkElements = (elements) => {
|
|
14163
14175
|
for (const el of elements) {
|
|
14164
14176
|
if (el.fontFamily) {
|
|
14165
|
-
const w =
|
|
14177
|
+
const w = normalizeWeight(el.fontWeight);
|
|
14166
14178
|
fontKeys.add(`${el.fontFamily}${SEP}${w}`);
|
|
14167
14179
|
}
|
|
14168
14180
|
if (el.styles && typeof el.styles === "object") {
|
|
@@ -14172,7 +14184,7 @@ async function embedFontsForConfig(pdf, config, fontBaseUrl) {
|
|
|
14172
14184
|
for (const charKey of Object.keys(lineStyles)) {
|
|
14173
14185
|
const s = lineStyles[charKey];
|
|
14174
14186
|
if (s == null ? void 0 : s.fontFamily) {
|
|
14175
|
-
const w =
|
|
14187
|
+
const w = normalizeWeight(s.fontWeight);
|
|
14176
14188
|
fontKeys.add(`${s.fontFamily}${SEP}${w}`);
|
|
14177
14189
|
}
|
|
14178
14190
|
}
|
|
@@ -15807,7 +15819,9 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
|
15807
15819
|
const hasGradient = !!((_b = (_a = page.backgroundGradient) == null ? void 0 : _a.stops) == null ? void 0 : _b.length);
|
|
15808
15820
|
drawPageBackground(pdf, i, page.width, page.height, page.backgroundColor, page.backgroundGradient);
|
|
15809
15821
|
const shouldStripBg = stripPageBackground ?? hasGradient;
|
|
15810
|
-
const
|
|
15822
|
+
const textMode = options.textMode ?? (options.outlineText ? "pixel-perfect" : "selectable");
|
|
15823
|
+
const shouldOutlineText = textMode === "pixel-perfect" || textMode === "auto";
|
|
15824
|
+
const outlineSubMode = textMode === "auto" ? "complex-only" : "all";
|
|
15811
15825
|
let pageSvg = page.svg;
|
|
15812
15826
|
try {
|
|
15813
15827
|
pageSvg = await convertSvgTextDecorationsToLinesString(pageSvg);
|
|
@@ -15819,8 +15833,8 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
|
15819
15833
|
}
|
|
15820
15834
|
if (shouldOutlineText) {
|
|
15821
15835
|
try {
|
|
15822
|
-
const { convertAllTextToPath } = await Promise.resolve().then(() => require("./svgTextToPath-
|
|
15823
|
-
pageSvg = await convertAllTextToPath(pageSvg, fontBaseUrl);
|
|
15836
|
+
const { convertAllTextToPath } = await Promise.resolve().then(() => require("./svgTextToPath-DHAXuVMF.cjs"));
|
|
15837
|
+
pageSvg = await convertAllTextToPath(pageSvg, fontBaseUrl, { mode: outlineSubMode });
|
|
15824
15838
|
try {
|
|
15825
15839
|
dumpSvgTextDiagnostics(pageSvg, i, PARITY_TAG, "STAGE-1b-after-text-to-path-raw");
|
|
15826
15840
|
} catch {
|