From dd9cdf8e7f185926003883fd89a98bd84da9d544 Mon Sep 17 00:00:00 2001 From: gered Date: Fri, 18 May 2018 10:07:16 -0400 Subject: [PATCH] update README.md with some more examples --- README.md | 35 +++++++++++++++++++++++++++++++++++ src/clj_htmltopdf/core.clj | 1 - 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0810c5f..85bbbc9 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,41 @@ a bit of CSS to give them some size so that they will be rendered. For example: ### Some More Examples: ```clojure +; renderer support +(->pdf + [:div + [:h2 "Object Drawing Test"] + [:object {:id "the-object" :style "width: 400px; height: 300px;"}] + [:p "Text after the object"]] + "object.pdf" + {:objects + {:by-id + {"the-object" + (fn [object-element-attrs ^java.awt.Graphics2D g] + (.setColor g java.awt.Color/RED) + (.drawRect g 50 50 200 200) + (.setColor g java.awt.Color/BLUE) + (.drawRect g 75 75 300 200))}}}) + +; SVG support +(->pdf + [:div + [:h2 "SVG test"] + [:svg {:xmlns "http://www.w3.org/2000/svg" :version "1.1"} + [:rect {:x 25 :y 25 :width 200 :height 200 :fill "lime" :stroke-width 4 :stroke "pink"}] + [:circle {:cx 125 :cy 125 :r 75 :fill "orange"}] + [:polyline {:points "50,150 50,200 200,200 200,100" :stroke "red" :stroke-width 4 :fill "none"}] + [:line {:x1 50 :y1 50 :x2 200 :y2 200 :stroke "blue" :stroke-width 4}]] + [:hr] + [:svg {:xmlns "http://www.w3.org/2000/svg" :width 100 :height 100} + [:circle {:cx 50 :cy 50 :r 40 :stroke "green" :stroke-width 4 :fill "yellow"}]] + [:hr] + [:svg {:xmlns "http://www.w3.org/2000/svg" :width 300 :height 200} + [:rect {:width "100%" :height "100%" :fill "red"}] + [:circle {:cx 150 :cy 100 :r 80 :fill "green"}] + [:text {:x 150 :y 125 :font-size 60 :text-anchor "middle" :fill "white"} "SVG"]]] + "svg.pdf") + ; disables automatically injected base styles and @page settings. this allows your html to specify completely custom ; styles and page properties if needed. (->pdf diff --git a/src/clj_htmltopdf/core.clj b/src/clj_htmltopdf/core.clj index 6683bc1..7dbe405 100644 --- a/src/clj_htmltopdf/core.clj +++ b/src/clj_htmltopdf/core.clj @@ -126,4 +126,3 @@ ; the future... except if we deref the future! thus the explicit call to deref it here (deref renderer) result))) -