        ))
 
 (defn generate-pdf [ctx page-id user-id header?]
-  (let [ badge-info-fn (first (plugin-fun (get-plugins ctx) "pdf" "pdf-generator-helper"))
-         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]}
+  (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 }
+                     :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}]

                                                                                                                         [: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}]]]))

                                                                       [:paragraph [:chunk [:image {:align :center :width 80 :height 80} (str data-dir "/" (:image_file %))]] [:spacer 1]"\n" ]
                                                                       "")])
                                                                  [:paragraph
                                                                   (let [badge (pdf-generator-helper ctx user-id (list (:badge_id %)))]
                                                                    (when-not (empty? badge)
                                                                      [:phrase {:align :center}
                                                                       [:chunk [:image {:align :center :width 75 :height 75  :base64 true} (:qr_code (first badge))]]"\n"
