Created
March 27, 2017 13:39
-
-
Save voldmar/c243aa2b0f434d6d43a30b9598482eea to your computer and use it in GitHub Desktop.
Filling PDF AcroForm with Clojure and iText 7 community edition POF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env boot | |
; vim: set ft=clojure: | |
(set-env! :dependencies | |
'[[com.itextpdf/forms "7.0.2"]]) | |
(import | |
'[com.itextpdf.forms PdfAcroForm] | |
'[com.itextpdf.kernel.pdf PdfDocument PdfReader PdfWriter] | |
'[java.io IOException]) | |
(defn run [] | |
(let [template "Gildi-lanaeydublad.pdf" | |
filled "Gildi-lanaeydublad-filled.pdf" | |
pdf-doc (PdfDocument. (PdfReader. template) (PdfWriter. filled)) | |
form (PdfAcroForm/getAcroForm pdf-doc true)] | |
(.removeXfaForm form) | |
(.setValue (.getField form "nafn") "Hello") | |
(.setValue (.getField form "lan 3") "On") | |
(.close pdf-doc))) | |
(defn -main [& args] | |
(println "here") | |
(run)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment