         :reportable-external-comp (parse-comp (doocr (reportable-external-comp y-off)))
         :other-comp (parse-comp (doocr (other-comp y-off)))))))
 
-(defn threshold [filename]
-  (sh "convert" filename "-threshold" "75%" filename))
+(defn threshold [file]
+  (sh "convert" (.getName file) "-threshold" "75%" (.getName file)))
+
+(defn save-image [image]
+  (let [file (File. (str (java.util.UUID/randomUUID) ".png"))]
+    (ImageIO/write image "png" file)
+    (threshold file)
+    file))
 
 (defn efiled-990? [page-one]
   (let [name-rect (Rectangle. 115 30 75 40)

           [java.awt Rectangle]
           [java.io File PrintStream OutputStreamWriter FileOutputStream BufferedWriter]
           [org.apache.commons.io FilenameUtils]))

(def row-height 112)
(def page-two-row-height 116)

    (when (> (.getPageCount doc) 8)
      (let [renderer (doto (SimpleRenderer.)
                       (.setResolution 300))
            [page-one page-two] (.render renderer doc 7 8)]
        (with-image [file-one (save-image page-one)]
          (when (efiled-990? file-one)
            (with-image [file-two (save-image page-two)]
              (loop [idx 0
                     records []]
                (if-let [record (try
                                  (read-record file-one file-two idx)
                                  (catch Exception e
                                    (println "Failed to read record" idx)
                                    (println "Exception:" (.getMessage e))
                                    nil))]
                  (do (print ".")
                      (flush)
                      (recur (inc idx)
                             (conj records record)))
                  records)))))))))

(defn process-pdf [pdf out-path]
  (print "Processing" (.getName pdf))
