                            :content %2)) badge-with-content temp)]
     (replace-nils badges)))
 
+
 #_(defn process-pdf-page [stylesheet template badge ul]
-  (if-let [p (blank? (slurp (io/piped-input-stream (fn [out] (pdf/pdf (into [stylesheet] (template badge)) out)))))]
-    (io/piped-input-stream (fn [out] (pdf/pdf [{} [:paragraph (t :core/Errorpage ul) #_"Error while processing, Page can't be displayed"]] out)))
-    (io/piped-input-stream (fn [out] (pdf/pdf (into [stylesheet] (template badge)) out)))))
-
-(defn process-pdf-page [stylesheet template badge ul]
-  (let [file (java.io.File/createTempFile "temp" ".pdf")
-        pdf (pdf/pdf (into [stylesheet] (template badge)) (.getAbsolutePath file))]
-    (if (blank? (slurp file))
-      (pdf/pdf [{} [:paragraph (t :core/Errorpage ul)]] (.getAbsolutePath file))
-      file)))
-
-
-#_(defn process-markdown [markdown]
-  (if (== 1 (count markdown))
-    markdown
-      (if-let [p (blank? (slurp (io/piped-input-stream (fn [out] (pdf/pdf [{} (markdown->clj-pdf {:spacer {:extra-starting-value 1 :allow-extra-line-breaks? true :single-value 2} :wrap {:global-wrapper :paragraph}} markdown)] out)))))]
-        ;""
-        (markdown->clj-pdf {:image {:x 10 :y 10} :spacer {:extra-starting-value 1 :allow-extra-line-breaks? true :single-value 2} :wrap {:global-wrapper :paragraph}} markdown))))
+    (let [file (java.io.File/createTempFile "temp" ".pdf")
+          pdf (pdf/pdf (into [stylesheet] (template badge)) (.getAbsolutePath file))]
+      (if (blank? (slurp file))
+        (pdf/pdf [{} [:paragraph (t :core/Errorpage ul)]] (.getAbsolutePath file))
+        file)))
+
 
 
 (defn process-markdown-helper [markdown id context]

                                                                                             [:chunk {:style :italic} (:description a)] "\n"
                                                                                             [:chunk.link (:url a)] [:spacer 0]]) )]))]
                                                                [:paragraph
                                                                 [:chunk.chunk (str (t :badge/Criteria ul)": ")] [:anchor {:target (:criteria_url %) :style{:family :times-roman :color [66 100 162]}} (:criteria_url %)]]
                                                                [:spacer 0]
                                                                (process-markdown (:criteria_content %) $id "Criteria")]

                                                               (when-not (empty? $endorsements)
                                                                 [:paragraph.generic

                               content (if (= lang "all") (map template $content) (map template (filter #(= (:default_language_code %) (:language_code %)) $content)))]

                           (reduce into [] content)))
        ;files (into [] (for [b badges] (process-pdf-page pdf-settings badge-template (list b) ul)))
        ]
    (fn [out]
      (try
        (pdf/pdf (into [pdf-settings] (badge-template badges)) out)
        (catch Exception e
          (log/error "PDF not generated")
          (log/error (.getMessage e))
          (pdf/pdf [{} [:paragraph (t :core/Errorpage ul)]] out)
          )
        )
      )
    #_(fn [output-stream]
        (try
          (apply pdf/collate output-stream
                 (map #(-> %
                           (.getAbsolutePath)) files))
          (catch Exception e
            (log/error "PDF not generated")
            )
          (finally (doseq [f files] (.delete f)))))))
