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

                                                               (case (:size %)
                                                                 "h1" [:paragraph.generic {:align :left }
                                                                       [:spacer 0]
                                                                       [:heading (or (:content %) "")]
                                                                       [:line {:dotted true}]
                                                                       ]
                                                                 "h2" [:paragraph.generic {:align :left}
                                                                       [:spacer 1]
                                                                       [:heading {:style {:size 12 :align :center}}  (or (:content %) "")]
                                                                       [:line {:dotted true}]] ))

                                                             (when (= "badge" (:type %))
                                                               [:table {:widths [1 3] :border false :keep-together? false }
                                                                [[:cell {:align :center}
                                                                  (when-not (blank? (:image_file %))
                                                                    [:paragraph {:align :center :keep-together true}
                                                                     (if (ends-with? (:image_file %) "png")
                                                                       [:paragraph [:chunk [:image {:align :center :width 80 :height 80} (str data-dir "/" (:image_file %))]] [:spacer 1]"\n" ]

                                                                   (let [badge (badge-info-fn ctx user-id (conj () (:badge_id %)))]
                                                                    (when-not (empty? badge)
                                                                      [:phrase {:align :center}
                                                                       [:chunk [:image {:align :center :width 75 :height 75  :base64 true} (:qr_code (first badge))]]"\n"
;;                                                                        [:spacer 0]
                                                                       [:chunk.generic (t :badge/Scantobadge ul)]]))]]

                                                                 [:cell
                                                                  [:heading.generic  (:name %)]
                                                                  [:spacer 0]
                                                                  [:paragraph.generic
                                                                   [:chunk.bold (str (t :badge/Issuedby ul) ": ")] [:chunk (:issuer_content_name %)] "\n"
                                                                   [:chunk.bold (str (t :badge/Issuedon ul)": ")] [:chunk (if (number? (:issued_on %)) (date-from-unix-time (long (* 1000 (:issued_on %))) "date") (:issued_on %))]
                                                                   [:spacer 0]
                                                                   (:description %)"\n"
                                                                   [:spacer 0]
                                                                   [:paragraph {:keep-together true}
                                                                    [:phrase.bold (str (t :badge/Criteria ul)": ")] [:spacer 0]
                                                                    [:anchor {:target (:criteria_url %) :style{:family :times-roman :color [66 100 162]}} (:criteria_url %)]
                                                                    [:spacer 0]
                                                                    (let [content (some->> (badge-info-fn ctx user-id (conj () (:badge_id %))) first :content first) ]
                                                                      (when-not (empty? content)
                                                                        (process-markdown "Criteria" (:criteria_content content))))]]]]

                                                                [[:cell {:colspan 2} [:line {:dotted true}]]]])

                                                             (when (and (= "html" (:type %)) (not (= "-" (:content %))))
                                                               [:paragraph.generic {:keep-together false :align :left}
                                                                [:chunk.bold {:size 11 :style :bold} (str (t :page/html ul) ": ")]"\n"
                                                                [:spacer 1]
