                                                                   [[:cell
                                                                     [:table {:align :center :width-percent 100 :border false :num-cols 5}
                                                                      (into [[:cell {:colspan 5}]] (for [badge (:badges %)
-                                                                                                        :let [b (badge-info-fn ctx user-id (conj () (:id badge)))
+                                                                                                        :let [b (pdf-generator-helper ctx user-id (list (:id badge)))
                                                                                                               content (-> b first :content first)]]
                                                                                                     (when-not (empty? b)
                                                                                                       [:cell {:padding-right 10}[:anchor {:target (str site-url "/badge/info/" (:id badge))}

                                                                                                                         [:paragraph {:keep-together true}
                                                                                                                          [:phrase.bold (str (t :badge/Criteria ul)": ")] "\n"
                                                                                                                          [:anchor {:target (:criteria_url badge) :style{:family :times-roman :color [66 100 162]}} (:criteria_url badge)] "\n"
                                                                                                                          (process-markdown "Criteria" (:criteria_content content))
                                                                                                                          ]
                                                                                                                         ][:spacer 0]]))))
                                                                              [[:cell {:colspan 2}[:line {:dotted true}]]]))

       ))

(defn generate-pdf [ctx page-id user-id header?]
  (let [page (replace-nils (conj () (page-with-blocks ctx page-id)))
        data-dir (get-in ctx [:config :core :data-dir])
        site-url (get-in ctx [:config :core :site-url])
        plugins (get-plugins ctx)
        user-data (ud/user-information ctx user-id)
        ul (if (blank? (:language user-data)) "en" (:language user-data))
        font-path  (first (mapcat #(get-in ctx [:config % :font] []) plugins))
        header-path (first (mapcat #(get-in ctx [:config % :logo] []) plugins))
        font  {:ttf-name (str site-url font-path)}
        stylesheet  {:generic {:family :times-roman
                               :color [127 113 121]}
                      :link {:family :times-roman
                             :color [66 100 162]}
                     :bold {:style :bold}}
        header      (if (= "true" header?)
                      {:table
                       [:pdf-table {:border false}
                        [100]
                        [[:pdf-cell {:padding 5}[:image {:width 200 :height 48} (str site-url (if-not (blank? header-path) header-path "/img/logo.png"))] [:line] [:spacer 2]]
                         ]]} nil)

        pdf-settings  (if (empty? font-path) {:header header :stylesheet stylesheet  :bottom-margin 0 :footer {:page-numbers false :align :right}} {:font font :header header :stylesheet stylesheet  :bottom-margin 0 :footer {:page-numbers false :align :right}})
        page-template (pdf/template
                        (let [template #(cons [:paragraph][
                                                            (when (= "heading"  (:type %))
                                                              (case (:size %)
                                                                "h1" [:paragraph.generic {:align :left }
                                                                       [:spacer 0]
                                                                       [:heading  (:content %)]
                                                                       [:line {:dotted true}]
