 
 (defn draw-line!
   [parent pdf-object]
-  (let [graphics-2d (parent :graphics-2d)]
-    (. graphics-2d drawLine (pdf-object "x1") (pdf-object "y1") (pdf-object "x2") (pdf-object "y2"))))
+  (let [document     (parent :object)
+        context-byte (parent :context-byte)
+        graphics-2d  (PdfGraphics2D. context-byte (. document getWidth) (. document getHeight))]
+    (. graphics-2d drawLine (pdf-object "x1") (pdf-object "y1") (pdf-object "x2") (pdf-object "y2"))
+    (. graphics-2d dispose)))
 
 (defn add-phrase!
   [parent pdf-object]
-  ;(pprint/pprint pdf-object)
   (let [parent-object (parent :object)
         base-font     (let [font-path (fonts/get-font-file-path (pdf-object "font"))]
                         (if (or (nil? font-path) (= font-path ""))

        ]
    (. document open)
    (let [context-byte (.. writer getDirectContent)
          graphics-2d  (PdfGraphics2D. context-byte (. page-rect getWidth) (. page-rect getHeight))
          parent       {:object       document
                        :context-byte context-byte
                        :graphics-2d  graphics-2d
                        :font         (@default-fonts :hkgh)
                        :font-size    (float 10.0)}]
      (add-objects parent (data "pdf_objects"))
      (. graphics-2d dispose))
    (. document close)
    (. writer close)))


  "application/pdf")

(def directions { "h" BaseFont/IDENTITY_H
                  "v" BaseFont/IDENTITY_V })

(def default-fonts (ref {:hmv  (BaseFont/createFont "HeiseiMin-W3" "UniJIS-UCS2-V" BaseFont/EMBEDDED)
                         :hmh  (BaseFont/createFont "HeiseiMin-W3" "UniJIS-UCS2-H" BaseFont/EMBEDDED)
