                                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 [output-stream]
+        ;files (into [] (for [b badges] (process-pdf-page pdf-settings badge-template (list b) ul)))
+        ]
+    (fn [out]
       (try
-        (apply pdf/collate output-stream
-               (map #(-> %
-                         (.getAbsolutePath)) files))
+        (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)
           )
-        (finally (doseq [f files] (.delete f)))))))
+        )
+      )
+    #_(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)))))))

                                                                                             [: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

                                                                            [:paragraph {:indent 0}
                                                                             (:issuer_name e) "\n"
                                                                             [:anchor {:target (:issuer_url e) :style{:family :times-roman :color [66 100 162]}} (:issuer_url e)] "\n"
                                                                             [:chunk (if (number? (:issued_on e)) (date-from-unix-time (long (* 1000 (:issued_on e)))) (:issued_on e))] "\n"
                                                                             (process-markdown (:content e) $id "Issuer Endorsements")]))]))

                                                               [:pdf-table {:align :right :width-percent 100 :cell-border false}
