Skip to content

Commit

Permalink
fixed background for chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
yogthos committed Aug 28, 2019
1 parent 25c4e94 commit 31a9553
Show file tree
Hide file tree
Showing 25 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion project.clj
@@ -1,4 +1,4 @@
(defproject clj-pdf "2.3.9"
(defproject clj-pdf "2.4.0"
:description "PDF generation library"
:url "https://github.com/yogthos/clj-pdf"

Expand Down
2 changes: 1 addition & 1 deletion src/clj/clj_pdf/section.clj
Expand Up @@ -45,7 +45,7 @@

(apply render tag new-meta elements)))
(catch Exception e
(prn meta element)
#_(prn meta element)
(throw (ex-info "failed to parse element" {:meta meta :element element} e))))))


Expand Down
10 changes: 5 additions & 5 deletions src/clj/clj_pdf/section/core.clj
Expand Up @@ -58,8 +58,8 @@
(.setBackground element color)))


(defn- text-chunk [style content]
(let [ch (Chunk. ^String (make-section content) ^Font (font style))]
(defn- text-chunk [style ^String content]
(let [ch (Chunk. ^String content ^Font (font style))]
(set-background ch style)
(cond
(:super style) (.setTextRise ch (float 5))
Expand All @@ -69,8 +69,8 @@

(defn- format-content [meta content]
(cond
(string? content) (Chunk. ^String content ^Font (font meta))
(number? content) (Chunk. ^String (str content) ^Font (font meta))
(string? content) (text-chunk meta content)
(number? content) (text-chunk meta (str content))
:else content))


Expand All @@ -80,7 +80,7 @@
(cond
(instance? Image children) (image-chunk meta children)
(instance? Chunk children) children
:else (text-chunk meta children))))
:else (format-content meta children))))


(defmethod render :graphics
Expand Down
Binary file modified test/anchor.pdf
Binary file not shown.
Binary file modified test/base64image.pdf
Binary file not shown.
Binary file modified test/chapter.pdf
Binary file not shown.
Binary file modified test/chunk.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions test/clj_pdf/test/example.clj
Expand Up @@ -578,3 +578,9 @@
"STYLED"]
[:chunk "UNSTYLEs"]]
"font-test.pdf")

#_(pdf
[{}
[:chunk 123]
[:chunk {:color [255 0 0] :background [0 255 0]} "Text with green background"]]
"doc.pdf")
Binary file modified test/header.pdf
Binary file not shown.
Binary file modified test/heading.pdf
Binary file not shown.
Binary file modified test/image.pdf
Binary file not shown.
Binary file modified test/image1.pdf
Binary file not shown.
Binary file modified test/image2.pdf
Binary file not shown.
Binary file modified test/line.pdf
Binary file not shown.
Binary file modified test/list.pdf
Binary file not shown.
Binary file modified test/nil.pdf
Binary file not shown.
Binary file modified test/nofooter.pdf
Binary file not shown.
Binary file modified test/pages1.pdf
Binary file not shown.
Binary file modified test/pages2.pdf
Binary file not shown.
Binary file modified test/paragraph.pdf
Binary file not shown.
Binary file modified test/phrase.pdf
Binary file not shown.
Binary file modified test/section.pdf
Binary file not shown.
Binary file modified test/spacer.pdf
Binary file not shown.
Binary file modified test/subsuper.pdf
Binary file not shown.
Binary file modified test/table.pdf
Binary file not shown.

0 comments on commit 31a9553

Please sign in to comment.