This commit is contained in:
Alejandro Alonso
2026-02-04 14:16:26 +01:00
parent f3e0c2409e
commit 86cb6b6f51

View File

@@ -42,22 +42,21 @@
(bw/eval! dom
(fn [elem]
(let [rect (.getBoundingClientRect ^js elem)
width (or (some-> (.getAttribute ^js elem "width") js/parseFloat) 0)
height (or (some-> (.getAttribute ^js elem "height") js/parseFloat) 0)
width (js/Math.max width (.-width rect))
height (js/Math.max height (.-height rect))
width (js/Math.max (or (some-> (.getAttribute ^js elem "width") js/parseFloat) 0)
(.-width rect))
height (js/Math.max (or (some-> (.getAttribute ^js elem "height") js/parseFloat) 0)
(.-height rect))
width-px (str width "px")
height-px (str height "px")
head (.-head js/document)
style-id "penpot-pdf-page-size"
style-node (or (.getElementById js/document style-id)
(doto (.createElement js/document "style")
(set! (.-id %) style-id)
(.appendChild head %)))]
style-node (or (.getElementById js/document "penpot-pdf-page-size")
(let [node (.createElement js/document "style")]
(set! (.-id node) "penpot-pdf-page-size")
(.appendChild (.-head js/document) node)
node))]
(set! (.-textContent style-node)
(str "@page { size: " width-px " " height-px "; margin: 0; }\n"
"html, body, #app { margin: 0; padding: 0; "
"width: " width-px "; height: " height-px "; overflow: visible; }\n"))))))
"html, body, #app { margin: 0; padding: 0;"
"width: " width-px "; height: " height-px "; }"))))))
(render-object [page base-uri {:keys [id] :as object}]
(p/let [uri (prepare-uri base-uri id)