From 271185690affa56c47c63a4b84f707966262dbfa Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Tue, 31 Jul 2018 10:31:43 -0700 Subject: [PATCH] Fixing pdf long invoice lines. --- src/clj/auto_ap/routes/checks.clj | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/clj/auto_ap/routes/checks.clj b/src/clj/auto_ap/routes/checks.clj index 3f7d4bc9..cb975a61 100644 --- a/src/clj/auto_ap/routes/checks.clj +++ b/src/clj/auto_ap/routes/checks.clj @@ -33,6 +33,22 @@ (let [sum (reduce + 0 nums)] (map #(* 100 (/ % sum)) nums))) +(defn split-memo [memo] + (str/join "\n" + (reverse + (take 6 + (concat + (reduce + (fn [[line & rest ] word] + (let [line (or line "")] + (if (> (+ (count line) (count word)) 50) + (concat [word line] rest) + (concat [(str line " " word)] + rest)))) + [] + (str/split memo #" ")) + (repeat "")))))) + (defn make-check-pdf [check] (let [output-stream (ByteArrayOutputStream.)] (pdf/pdf @@ -73,15 +89,17 @@ [:cell {:colspan 3}]] - [[:cell {:colspan 6 :leading 50} [:spacer]] - [:cell {:colspan 6 :rowspan 2} (if (:signature-file company) + [[:cell {:size 9 :leading 11.5} "\n\n\n\n\nMEMO"] + [:cell {:colspan 5 :leading 11.5} (split-memo memo) + [:line {:line-width 0.15 :color [50 50 50]}]] + [:cell {:colspan 6 } (if (:signature-file company) [:image { :top-margin 90 :xscale 0.30 :yscale 0.30 :align :center} (:signature-file company)] [:spacer])]] - [[:cell {:size 9 } "MEMO"] - [:cell {:colspan 5} memo [:line {:line-width 0.15 :color [50 50 50]}]] + #_[ + #_[:cell {:colspan 5} #_memo ] #_[:cell {:colspan 6}]] [[:cell {:colspan 2}]