Skip to content

Instantly share code, notes, and snippets.

@martintrojer
Created May 2, 2013 07:46
Show Gist options
  • Save martintrojer/5500748 to your computer and use it in GitHub Desktop.
Save martintrojer/5500748 to your computer and use it in GitHub Desktop.
Get text from PDF
(ns pdftstr.core
(:import [com.snowtide.pdf OutputTarget PDFTextStream]))
(defn get-text [filename]
(with-open [pdfts (PDFTextStream. filename)]
(let [txt (StringBuilder. 1024)]
(.pipe pdfts (OutputTarget. txt))
(str txt))))
(get-text "kalle.pdf")
(defproject pdftstr "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"]
[com.snowtide/pdftextstream "2.6.2"]]
:repositories [["snowtide-releases" "http://maven.snowtide.com/releases"]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment