1.2.3-SNAPSHOT Arrow_down_16x16

save-pdf

incanter.pdf

  • (save-pdf chart filename & options)
Save a chart object as a pdf document.

Arguments:
chart
filename

Options:
:width (default 500)
:height (defualt 400)

Examples:

(use '(incanter core charts pdf))
(save-pdf (function-plot sin -4 4) "./pdf-chart.pdf")


0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source incanter/pdf.clj:19 top

(defn save-pdf
" Save a chart object as a pdf document.

  Arguments:
    chart
    filename

  Options:
    :width (default 500)
    :height (defualt 400)

  Examples:

    (use '(incanter core charts pdf))
    (save-pdf (function-plot sin -4 4) \"./pdf-chart.pdf\")


"
  ([chart filename & options]
     (let [opts (when options (apply assoc {} options))
	   width (or (:width opts) 500)
	   height (or (:height opts) 400)
	   pagesize (Rectangle. width height)
	   document (Document. pagesize 50 50 50 50)
	   out (BufferedOutputStream. (FileOutputStream. filename))
	   writer (PdfWriter/getInstance document out)
	   _ (.open document)
	   cb (.getDirectContent writer)
	   tp (.createTemplate cb width height)
	   mapper (DefaultFontMapper.)
	   g2 (.createGraphics tp width height mapper)
	   r2D (new java.awt.geom.Rectangle2D$Double 0 0 width height)]
       (do
	 (.draw chart g2 r2D)
	 (.dispose g2)
	 (.addTemplate cb tp 0 0)
	 (.close document)
	 (.close out)))))
Vars in incanter.pdf/save-pdf: defn let
Used in 0 other vars

Comments top

No comments for save-pdf. Log in to add a comment.