Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix alignment and spacing

Keep the project styling consistent for newcomers.
  • Loading branch information...
commit 139d595760b84969a84c68174ebe436f5820bae0 1 parent 24a0c91
Kushal Pisavadia authored

Showing 1 changed file with 7 additions and 13 deletions. Show diff stats Hide diff stats

  1. +7 13 src/camelot/core.clj
20 src/camelot/core.clj
@@ -41,15 +41,13 @@
41 41
42 42 (defn draw-text-lines-for-page
43 43 "Given PDocument, PDPage, PDRectangle and sequence of lines
44   - (e.g. [[{:font-size 10 :font-face \"Helvetica-Bold\"} \"Hello, World!\"}]),
  44 + (e.g. [[{:font-size 10 :font-face \"Helvetica-Bold\"} \"Hello, World!\"}]),
45 45 produces a PDocument with the provided text."
46 46 [doc page page-size lines]
47 47 (let [start-x 35
48 48 start-y (- (.getUpperRightY page-size) 75)]
49   -
50 49 (do
51 50 (.addPage doc page))
52   -
53 51 (with-open [content (PDPageContentStream. doc page)]
54 52 (loop [lines lines
55 53 start-y start-y]
@@ -57,11 +55,11 @@
57 55 (let [font-face (font (or (:font-face line-meta) "Helvetica-Bold"))
58 56 font-size (or (:font-size line-meta) 10)]
59 57 (doto content
60   - (.setFont font-face font-size)
61   - (.beginText)
62   - (.moveTextPositionByAmount start-x start-y)
63   - (.drawString line-content)
64   - (.endText))
  58 + (.setFont font-face font-size)
  59 + (.beginText)
  60 + (.moveTextPositionByAmount start-x start-y)
  61 + (.drawString line-content)
  62 + (.endText))
65 63 (let [new-y (- start-y (* font-size 1.2))]
66 64 (if (.contains page-size start-x (- new-y 30))
67 65 (recur (rest lines) new-y)
@@ -71,7 +69,6 @@
71 69 (PDPage. page-size)
72 70 page-size
73 71 (rest lines))))))))))
74   -
75 72 doc)
76 73
77 74 (defn save-as
@@ -86,12 +83,9 @@
86 83 (PDPage. page-size)
87 84 page-size
88 85 (:lines doc-map)))
89   -
90 86 (when (contains? doc-map :metadata)
91 87 (set-metadata doc (:metadata doc-map)))
92   -
93 88 (.save doc filename)
94   -
95 89 doc))
96 90
97 91 (defn merge-pdfs
@@ -123,4 +117,4 @@
123 117 (.save start-doc filename)
124 118 (finally (if (not (nil? start-doc))
125 119 (.close start-doc))))
126   - start-doc))
  120 + start-doc))

0 comments on commit 139d595

Please sign in to comment.
Something went wrong with that request. Please try again.