title: How do I add PDF print functionality to Metabase in Clojure
body: <p>I have forked the metabase project and want to add some "export to pdf" functionality into the reports where you can currently export to csv, excel and json.</p>
  
  <p><a href="https://i.stack.imgur.com/ww2BK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ww2BK.png" alt="export options for reports"></a></p>
  
  <p>I tried finding it and spent a lot of time looking for an existing fork of metabase that might have this functionality but could not find anything.</p>
  
  <p>In src/metabase/util there is a file containing some of the logic for exporting to csv, json, etc. It is called export.clj</p>
  
  <p>so far I have written some edits but I have no experience with Clojure so I'm just trying to wing it so far and then hopefully get some guidance from the SO community.</p>
  
  <pre><code>(def export-formats
    "Map of export types to their relevant metadata"
    {
      "pdf"  {:export-fn      export-to-pdf
             :content-type     "application/pdf"
             :ext            "pdf"
             :context     :pdf-download},
      "csv"  {:export-fn    export-to-csv
             :content-type "text/csv"
             :ext          "csv"
             :context      :csv-download},
     "xlsx" {:export-fn    export-to-xlsx
             :content-type "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
             :ext          "xlsx"
             :context      :xlsx-download},
     "json" {:export-fn    export-to-json
             :content-type "applicaton/json"
             :ext          "json"
             :context      :json-download}})
  </code></pre>
  
  <p>Further up in that same page are the definitions of some of these functions referred to. So I added one for pdf which is just the csv function duplicated because I just want to try see that a new option shows first. </p>
  
  <pre><code>(defn- export-to-pdf [column-names rows]
    (with-out-str
      ;; turn keywords into strings, otherwise we get colons in our output
      (csv/write-csv *out* (into [(mapv name column-names)] rows))))
  </code></pre>
  
  <p>My metabase clone is installed on Heroku. I tried making the above changes and saw no result in the download option. I tried removing other download methods from this file and also saw no changes.</p>
  
  <p>I'm hoping someone can point me in the right direction to go about changing this.</p>