我想用ClojureScript将一个pdf文件转换为一个字节向量,比如:[1 23 4 43 ......]。[1 23 4 43 ......],使用ClojureScript。请问,有什么好办法吗?
非常感谢
我写了这个快速的例子,它应该能让您获得使用 HTML5 Files API 的网页版所需的大部分内容。
(defn handle-files [fs]
(let [file (aget (.-files fs) 0) ;; the first file
slice (.slice file 0 100)] ;; a slice with the first 100 bytes
;; The API to get the file contents returns a promise, so we'll update
;; the atom when the data is available
(-> slice .text (.then #(swap! file-info assoc-in [:contents] %)))
;; Most of the file info is available right away
(reset! file-info {:name (.-name file)
:size (.-size file)
:type (.-type file)})))
;; App initialization
(defn mount-root []
(rdom/render [example-app] (.getElementById js/document "app"))
;; register fn to check on the file[s] we want the browser to scan
(-> (.getElementById js/document "input")
(.addEventListener "change" #(handle-files (.-target %)) false)))
您可以在这个回帖中找到一个工作示例。https:/github.comdfuenzalidacljs-files-api。