Subject: A patch to support pdf and pdfcairo terminals
From: Peter Gardner
Date: Wed, 5 Nov 2008 18:10:28 +0000 (GMT)
Hi,
As gnuplot 4.2.4 now supports "set terminal pdf", and the future gnuplot 4.3
supports "set terminal pdfcairo", I made a small patch (see below, and also attached) for draw.lisp
in maxima 5.16.3 to add these two additional pdf terminals.
The patch creates two new terminal types: pdf pdfcairo
The default pdf file is A4 portrait (21.0 cm width x 29.7 cm height).
The height and width can be specfied in cms (real or integer) with pdf_width and pdf_height,
similar to the existing eps_width and eps_height.
I've tested this on Slackware Linux 12.1 with maxima-5.6.13 + gnuplot-4.3.0cvs
(also wxMaxima 0.7.6) with both single plots and multiplot. I've not tried anything with Windows.
I didn't experiment much with fonts. (Fonts seems to be a minefield!).
It's quite easy to try without reinstalling maxima,
assuming gnuplot already has pdf support.
You only need to edit the installed draw.lisp - save a copy first, of course.
Mine is installed in /usr/share/maxima/5.16.3/share/draw/draw.lisp
If anybody out there finds this useful I'd be interested to know.
Maybe the maxima team could add official support for pdf/pdfcairo for a future release
of their excellent software.
Cheers,
Peter
n.b. gnuplot needs libpdf. I used the free version from:
http://www.pdflib.com/en/download/pdflib-family/pdflib-lite/
And gnuplot-4.3 came from:
http://gnuplot.sourceforge.net/development/index.html#DownloadCVS
--- ./share/draw/draw.lisp.original??? 2008-08-10 18:41:10.000000000 +0100
+++ ./share/draw/draw.lisp??? 2008-11-05
16:40:43.000000000 +0000
@@ -166,6 +166,8 @@
?????? (gethash '$pic_height *gr-options*) 480??? ; points for bitmap pictures
?????? (gethash '$eps_width *gr-options*)? 12???? ; cm for eps pictures
?????? (gethash '$eps_height *gr-options*) 8????? ; cm for eps pictures
+????? (gethash '$pdf_width *gr-options*)? 21.0?? ; cm for pdf pictures (A4 portrait width)
+????? (gethash '$pdf_height *gr-options*) 29.7?? ; cm for pdf pictures (A4 portrait height)
?
?????? (gethash '$file_name *gr-options*)? "maxima_out"
?????? (gethash '$delay *gr-options*)? 5????????? ; delay for animated gif's,
default 5*(1/100) sec
@@ -209,7 +211,7 @@
????????????????????? (<= val 1 ))
???????????????? (setf (gethash opt *gr-options*) val)
???????????????? (merror "draw: fill_density must be a number in [0, 1]")))
-????? (($line_width $head_length $head_angle $eps_width $eps_height
+????? (($line_width $head_length $head_angle $eps_width $eps_height $pdf_width $pdf_height
???????? $xaxis_width $yaxis_width $zaxis_width) ; defined as positive numbers
???????????? (setf val (convert-to-float
val))
???????????? (if (and (numberp val)
@@ -332,8 +334,8 @@
????????????????????????????????????????? ")")))))
?????????????????? (t
????????????????????? (merror "draw: illegal tics allocation: ~M" val)) ))
-????? ($terminal ; defined as screen, png, jpg, gif, eps, eps_color or wxt
-??????????? (if (member val '($screen $png $jpg $gif $eps $eps_color $wxt $animated_gif
$aquaterm))
+????? ($terminal ; defined as screen, png, jpg, gif, eps, eps_color, pdf, pdfcairo or wxt
+??????????? (if (member val '($screen $png $jpg $gif $eps $eps_color $pdf $pdfcairo $wxt $animated_gif $aquaterm))
???????????????? (setf (gethash opt *gr-options*) val)
???????????????? (merror "draw: this is not a terminal: ~M" val)))
?????? ($head_type ; defined as $filled, $empty and $nofilled
@@ -2669,6 +2671,8 @@
???????????????? ($pic_height (update-gr-option '$pic_height ($rhs x)))
????????????????
($eps_width? (update-gr-option '$eps_width ($rhs x)))
???????????????? ($eps_height (update-gr-option '$eps_height ($rhs x)))
+??????????????? ($pdf_width? (update-gr-option '$pdf_width ($rhs x)))
+??????????????? ($pdf_height (update-gr-option '$pdf_height ($rhs x)))
???????????????? ($file_name? (update-gr-option '$file_name ($rhs x)))
???????????????? ($delay????? (update-gr-option '$delay ($rhs x)))
???????????????? (otherwise
(merror "draw: unknown global option ~M " ($lhs x)))? ))
@@ -2708,6 +2712,16 @@
??????????????????????????? (get-option '$eps_width)
??????????????????????????? (get-option '$eps_height)
??????????????????????????? (get-option '$file_name)))
+????? ($pdf (format cmdstorage "set terminal pdf enhanced ~a color size ~acm, ~acm~%set out '~a.pdf'"
+??????????????????????????
(write-font-type)
+?????????????????????????? (get-option '$pdf_width)
+?????????????????????????? (get-option '$pdf_height)
+?????????????????????????? (get-option '$file_name)))
+????? ($pdfcairo (format cmdstorage "set terminal pdfcairo enhanced ~a color size ~acm, ~acm~%set out '~a.pdf'"
+??????????????????????????
(write-font-type)
+?????????????????????????? (get-option '$pdf_width)
+?????????????????????????? (get-option '$pdf_height)
+?????????????????????????? (get-option '$file_name)))
?????? ($jpg (format cmdstorage "set terminal jpeg ~a size ~a, ~a~%set out '~a.jpg'"
???????????????????????????
(write-font-type)
??????????????????????????? (get-option '$pic_width)
@@ -2832,6 +2846,10 @@
??????????????????? ((not (string= (gethash '$xy_file *gr-options*) ""))
?????????????????????? (format cmdstorage "set print \"~a\" append~%bind x \"print MOUSE_X,MOUSE_Y\"~%"
??????????????????????????????????? (gethash '$xy_file *gr-options*))) )
+
+???????????? (format
cmdstorage "unset output~%")
+???????????? (format cmdstorage "reset~%")
+
????????????? (close cmdstorage)
?
????????????? ; get the plot
-------------- next part --------------
A non-text attachment was scrubbed...
Name: draw.lisp.diff
Type: application/octet-stream
Size: 4006 bytes
Desc: not available
Url : http://www.math.utexas.edu/pipermail/maxima/attachments/20081105/4621bfa5/attachment.obj