Compare commits

...

5 Commits

Author SHA1 Message Date
Alejandro Alonso
86cb6b6f51 WIP 2026-02-04 14:16:26 +01:00
Alejandro Alonso
f3e0c2409e WIP 2026-02-04 14:11:12 +01:00
Alejandro Alonso
8584e070f9 WIP 2026-02-04 14:06:03 +01:00
Alejandro Alonso
49ea9a30a9 🐛 Fix pdf export 2026-02-04 13:58:03 +01:00
Alejandro Alonso
24c8fc484f 🐛 Fix Internal Error when adding a new text layer and trying to go back to Dashboard without saving 2026-02-04 10:01:10 +01:00
2 changed files with 25 additions and 2 deletions

View File

@@ -38,6 +38,26 @@
(assoc :path "/render.html")
(assoc :query (u/map->query-string params)))))
(sync-page-size! [dom]
(bw/eval! dom
(fn [elem]
(let [rect (.getBoundingClientRect ^js elem)
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")
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 "; }"))))))
(render-object [page base-uri {:keys [id] :as object}]
(p/let [uri (prepare-uri base-uri id)
path (sh/tempfile :prefix "penpot.tmp.pdf." :suffix (mime/get-extension type))]
@@ -45,6 +65,7 @@
(bw/nav! page uri)
(p/let [dom (bw/select page (dm/str "#screenshot-" id))]
(bw/wait-for dom)
(sync-page-size! dom)
(bw/screenshot dom {:full-page? true})
(bw/sleep page 2000) ; the good old fix with sleep
(bw/pdf page {:path path})

View File

@@ -78,13 +78,15 @@
(fn []
(close-modals)
;; FIXME: move set-mode to uri?
(st/emit! (dw/set-options-mode :design)
(st/emit! :interrupt
(dw/set-options-mode :design)
(dcm/go-to-dashboard-recent))))
nav-to-project
(mf/use-fn
(mf/deps project-id)
#(st/emit! (dcm/go-to-dashboard-files ::rt/new-window true :project-id project-id)))]
#(st/emit! :interrupt
(dcm/go-to-dashboard-files ::rt/new-window true :project-id project-id)))]
(mf/with-effect [editing?]
(when ^boolean editing?