fix default base-uri option to point to "resources" dir on classpath
this should fix the most common usage scenario where you would probably like to be able to use e.g. <img> tags to point to image files that exist locally within your project's "resources" directory somewhere. the :base-uri option can still be overridden in the call to ->pdf for the more uncommon scenarios
This commit is contained in:
parent
01f12c6f2c
commit
ce2a7f78fe
|
@ -8,6 +8,14 @@
|
||||||
[org.jsoup.nodes Document Element]
|
[org.jsoup.nodes Document Element]
|
||||||
[org.jsoup.parser Tag]))
|
[org.jsoup.parser Tag]))
|
||||||
|
|
||||||
|
(defn- get-base-resource-path-url
|
||||||
|
[]
|
||||||
|
(if-let [css-resource (io/resource "htmltopdf-base.css")]
|
||||||
|
(-> (io/file css-resource)
|
||||||
|
(.getParentFile)
|
||||||
|
(.toURL))
|
||||||
|
""))
|
||||||
|
|
||||||
(defn append-style-tag!
|
(defn append-style-tag!
|
||||||
^Element [^Element parent css-styles]
|
^Element [^Element parent css-styles]
|
||||||
(let [element (.appendElement parent "style")]
|
(let [element (.appendElement parent "style")]
|
||||||
|
@ -32,7 +40,7 @@
|
||||||
|
|
||||||
(def default-options
|
(def default-options
|
||||||
{:logging? false
|
{:logging? false
|
||||||
:base-uri ""
|
:base-uri (get-base-resource-path-url)
|
||||||
:styles true
|
:styles true
|
||||||
:page {:size :letter
|
:page {:size :letter
|
||||||
:orientation :portrait
|
:orientation :portrait
|
||||||
|
|
Loading…
Reference in a new issue