Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Further pdf export improvements (#71031)

Nick Fitzpatrick536d6bf22f47
diff --git a/patches/html2canvas-pro+2.0.2.patch b/patches/html2canvas-pro+2.0.2.patch
index b0c0484456e..2e5393bd0c2 100644
--- a/patches/html2canvas-pro+2.0.2.patch
+++ b/patches/html2canvas-pro+2.0.2.patch
@@ -1,5 +1,5 @@
diff --git a/node_modules/html2canvas-pro/dist/html2canvas-pro.esm.js b/node_modules/html2canvas-pro/dist/html2canvas-pro.esm.js
-index d49f1bd..1387285 100644
+index d49f1bd..77be9b6 100644
--- a/node_modules/html2canvas-pro/dist/html2canvas-pro.esm.js
+++ b/node_modules/html2canvas-pro/dist/html2canvas-pro.esm.js
@@ -5875,6 +5875,8 @@ class SVGElementContainer extends ElementContainer {
@@ -11,7 +11,53 @@ index d49f1bd..1387285 100644
const bounds = parseBounds(context, img);
img.setAttribute('width', `${bounds.width}px`);
img.setAttribute('height', `${bounds.height}px`);
-@@ -7534,7 +7536,8 @@ class ElementPaint {
+@@ -7144,13 +7146,39 @@ const ignoredStyleProperties = [
+ 'd', // #2483
+ 'content' // Safari shows pseudoelements if content is set
+ ];
++const svgTextFontProperties = [
++ 'font-family',
++ 'font-size',
++ 'font-weight',
++ 'font-style',
++ 'font-variant',
++ 'font-stretch',
++ 'font-size-adjust',
++ 'letter-spacing',
++ 'word-spacing',
++ 'line-height',
++];
++const isSVGTextNode = (node) => {
++ const tagName = node.tagName;
++ return tagName === 'text' || tagName === 'tspan' || tagName === 'textPath';
++};
+ const copyCSSStyles = (style, target) => {
+- // Edge does not provide value for cssText
+- for (let i = style.length - 1; i >= 0; i--) {
+- const property = style.item(i);
+- // fix: Chrome_138 ignore custom properties
+- if (ignoredStyleProperties.indexOf(property) === -1 && !property.startsWith('--')) {
+- target.style.setProperty(property, style.getPropertyValue(property));
++ // Use cssText for a single native call instead of iterating 300+ properties
++ // individually via style.item(i), which is extremely slow in Firefox due to
++ // Stylo's per-call indexmap lookups in the custom properties map.
++ target.style.cssText = style.cssText;
++ // Remove properties that should be ignored
++ for (let i = ignoredStyleProperties.length - 1; i >= 0; i--) {
++ target.style.removeProperty(ignoredStyleProperties[i]);
++ }
++ // For SVG text elements, explicitly re-apply font properties from the
++ // computed style since cssText may not reliably serialize them.
++ if (isSVGTextNode(target)) {
++ for (let i = 0; i < svgTextFontProperties.length; i++) {
++ const value = style.getPropertyValue(svgTextFontProperties[i]);
++ if (value) {
++ target.style.setProperty(svgTextFontProperties[i], value);
++ }
+ }
+ }
+ return target;
+@@ -7534,7 +7562,8 @@ class ElementPaint {
const rotateMatrix = [cos, sin, -sin, cos, 0, 0];
this.effects.push(new TransformEffect(offsetX, offsetY, rotateMatrix));
}
@@ -21,7 +67,7 @@ index d49f1bd..1387285 100644
const origin = this.container.styles.transformOrigin;
const offsetX = this.container.bounds.left + getAbsoluteValue(origin[0], this.container.bounds.width);
const offsetY = this.container.bounds.top + getAbsoluteValue(origin[1], this.container.bounds.height);
-@@ -10373,12 +10376,12 @@ class Validator {
+@@ -10373,12 +10402,12 @@ class Validator {
}
// Basic format validation - nonce should be base64-like
// Typical format: base64 string, often 32+ characters