Skip to content

Instantly share code, notes, and snippets.

@matstani
Last active December 24, 2015 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matstani/6864398 to your computer and use it in GitHub Desktop.
Save matstani/6864398 to your computer and use it in GitHub Desktop.
ClojureでiTextを利用した日本語PDFファイル出力
(ns try-itext.core
(:import [com.itextpdf.text
Document PageSize Paragraph Font
pdf.PdfWriter pdf.BaseFont]
[java.io FileOutputStream])
(:gen-class))
(defn create-pdf []
(with-open [pdf-doc (Document. PageSize/A4 50 50 50 40)]
(doto pdf-doc
(PdfWriter/getInstance (FileOutputStream. "test.pdf"))
.open
(.add (Paragraph. "こんにちは、世界!"
(Font. (BaseFont/createFont
"HeiseiKakuGo-W5"
"UniJIS-UCS2-H"
BaseFont/NOT_EMBEDDED)))))))
(defn -main
[& args]
(create-pdf))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment