annotate scripts/plot/print.m @ 9152:4c9aff0c9a61

print.m: Use Ghostscript rather than ImageMagick's 'convert'.
author Ben Abbott <bpabbott@mac.com>
date Thu, 23 Apr 2009 20:04:29 -0400
parents d0d507cbd123
children fce7315c1eee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8889
diff changeset
1 ## Copyright (C) 1999, 2005, 2006, 2007, 2008, 2009 Daniel Heiserer
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
2 ## Copyright (C) 2001 Laurent Mazet
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
3 ##
5362
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
4 ## This file is part of Octave.
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
5 ##
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
7 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6965
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6965
diff changeset
9 ## your option) any later version.
5362
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
10 ##
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
14 ## General Public License for more details.
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
15 ##
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
16 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6965
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6965
diff changeset
18 ## <http://www.gnu.org/licenses/>.
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
19
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
20 ## -*- texinfo -*-
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
21 ## @deftypefn {Function File} {} print (@var{filename}, @var{options})
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
22 ## @deftypefnx {Function File} {} print (@var{h}, @var{filename}, @var{options})
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
23 ## Print a graph, or save it to a file
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
24 ##
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
25 ## @var{filename} defines the file name of the output file. If no
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
26 ## filename is specified, output is sent to the printer.
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
27 ##
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
28 ## @var{h} specifies the figure handle. If no handle is specified
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
29 ## the handle for the current figure is used.
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
30 ##
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
31 ## @var{options}:
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
32 ## @table @code
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
33 ## @item -P@var{printer}
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
34 ## Set the @var{printer} name to which the graph is sent if no
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
35 ## @var{filename} is specified.
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
36 ## @item -G@var{ghostscript_command}
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
37 ## Specify the command for calling Ghostscript. For Unix and Windows,
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
38 ## the defaults are 'gs' and 'gswin32c', respectively.
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
39 ## @item -color
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
40 ## @itemx -mono
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
41 ## Monochrome or color lines.
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
42 ## @item -solid
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
43 ## @itemx -dashed
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
44 ## Solid or dashed lines.
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
45 ## @item -portrait
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
46 ## @itemx -landscape
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
47 ## Plot orientation, as returned by "orient".
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
48 ## @item -d@var{device}
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
49 ## Output device, where @var{device} is one of:
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
50 ## @table @code
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
51 ## @item ps
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
52 ## @itemx ps2
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
53 ## @itemx psc
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
54 ## @itemx psc2
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
55 ## Postscript (level 1 and 2, mono and color)
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
56 ## @item eps
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
57 ## @itemx eps2
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
58 ## @itemx epsc
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
59 ## @itemx epsc2
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
60 ## Encapsulated postscript (level 1 and 2, mono and color)
6739
db0a05a61d09 [project @ 2007-06-15 21:59:16 by jwe]
jwe
parents: 6727
diff changeset
61 ## @item tex
db0a05a61d09 [project @ 2007-06-15 21:59:16 by jwe]
jwe
parents: 6727
diff changeset
62 ## @itemx epslatex
db0a05a61d09 [project @ 2007-06-15 21:59:16 by jwe]
jwe
parents: 6727
diff changeset
63 ## @itemx epslatexstandalone
db0a05a61d09 [project @ 2007-06-15 21:59:16 by jwe]
jwe
parents: 6727
diff changeset
64 ## @itemx pstex
db0a05a61d09 [project @ 2007-06-15 21:59:16 by jwe]
jwe
parents: 6727
diff changeset
65 ## @itemx pslatex
db0a05a61d09 [project @ 2007-06-15 21:59:16 by jwe]
jwe
parents: 6727
diff changeset
66 ## Generate a LaTeX (or TeX) file for labels, and eps/ps for
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
67 ## graphics. The file produced by @code{epslatexstandalone} can be
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
68 ## processed directly by LaTeX. The other formats are intended to
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
69 ## be included in a LaTeX (or TeX) document. The @code{tex} device
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
70 ## is the same as the @code{epslatex} device.
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
71 ## @item ill
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
72 ## @itemx aifm
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
73 ## Adobe Illustrator
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
74 ## @item cdr
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
75 ## @itemx corel
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
76 ## CorelDraw
6965
c962cc09067a [project @ 2007-10-06 04:54:36 by jwe]
jwe
parents: 6895
diff changeset
77 ## @item dxf
c962cc09067a [project @ 2007-10-06 04:54:36 by jwe]
jwe
parents: 6895
diff changeset
78 ## AutoCAD
c962cc09067a [project @ 2007-10-06 04:54:36 by jwe]
jwe
parents: 6895
diff changeset
79 ## @item emf
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
80 ## @itemx meta
6965
c962cc09067a [project @ 2007-10-06 04:54:36 by jwe]
jwe
parents: 6895
diff changeset
81 ## Microsoft Enhanced Metafile
c962cc09067a [project @ 2007-10-06 04:54:36 by jwe]
jwe
parents: 6895
diff changeset
82 ## @item fig
7037
b1ca2c453b77 [project @ 2007-10-17 21:25:44 by jwe]
jwe
parents: 7032
diff changeset
83 ## XFig. If this format is selected the additional options
7040
1f16da18d85d [project @ 2007-10-19 18:24:19 by jwe]
jwe
parents: 7037
diff changeset
84 ## @code{-textspecial} or @code{-textnormal} can be used to control
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
85 ## whether the special flag should be set for the text in
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
86 ## the figure (default is @code{-textnormal}).
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
87 ## @item hpgl
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
88 ## HP plotter language
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
89 ## @item mf
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
90 ## Metafont
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
91 ## @item png
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
92 ## Portable network graphics
7543
b84c5cbc0812 print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents: 7540
diff changeset
93 ## @item jpg
b84c5cbc0812 print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents: 7540
diff changeset
94 ## @itemx jpeg
b84c5cbc0812 print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents: 7540
diff changeset
95 ## JPEG image
b84c5cbc0812 print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents: 7540
diff changeset
96 ## @item gif
b84c5cbc0812 print.m: handle gif and jpg devices
John W. Eaton <jwe@octave.org>
parents: 7540
diff changeset
97 ## GIF image
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
98 ## @item pbm
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
99 ## PBMplus
6965
c962cc09067a [project @ 2007-10-06 04:54:36 by jwe]
jwe
parents: 6895
diff changeset
100 ## @item svg
c962cc09067a [project @ 2007-10-06 04:54:36 by jwe]
jwe
parents: 6895
diff changeset
101 ## Scalable vector graphics
7396
0114d8cd1587 [project @ 2008-01-17 21:55:55 by jwe]
jwe
parents: 7341
diff changeset
102 ## @item pdf
0114d8cd1587 [project @ 2008-01-17 21:55:55 by jwe]
jwe
parents: 7341
diff changeset
103 ## Portable document format
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
104 ## @end table
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
105 ##
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
106 ## If the device is omitted, it is inferred from the file extension,
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
107 ## or if there is no filename it is sent to the printer as postscript.
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
108 ##
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
109 ## @item -d@var{gs_device}
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
110 ## Additional devices are supported by Ghostscript.
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
111 ## Some examples are;
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
112 ##
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
113 ## @table @code
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
114 ## @item ljet2p
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
115 ## HP LaserJet IIP
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
116 ## @item ljet3
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
117 ## HP LaserJet III
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
118 ## @item deskjet
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
119 ## HP DeskJet and DeskJet Plus
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
120 ## @item cdj550
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
121 ## HP DeskJet 550C
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
122 ## @item paintjet
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
123 ## HP PointJet
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
124 ## @item pcx24b
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
125 ## 24-bit color PCX file format
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
126 ## @item ppm
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
127 ## Portable Pixel Map file format
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
128 ## @end table
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
129 ##
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
130 ## For a complete list, type `system ("gs -h")' to see what formats
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
131 ## and devices are available.
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
132 ##
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
133 ## For output sent to a printer, the size is determined by the
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
134 ## figure's "papersize" property. For output to a file the, size
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
135 ## is determined by the "paperposition" property.
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
136 ##
8889
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
137 ## @itemx -r@var{NUM}
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
138 ## Resolution of bitmaps in pixels per inch. For both metafiles and
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
139 ## SVG the default is the screen resolution, for other it is 150 dpi.
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
140 ## To specify screen resolution, use "-r0".
8889
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
141 ##
6965
c962cc09067a [project @ 2007-10-06 04:54:36 by jwe]
jwe
parents: 6895
diff changeset
142 ## @itemx -S@var{xsize},@var{ysize}
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
143 ## Plot size in pixels for EMF, GIF, JPEG, PBM, PNG and SVG. If
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
144 ## using the command form of the print function, you must quote the
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
145 ## @var{xsize},@var{ysize} option. For example, by writing
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
146 ## @code{"-S640,480"}. The size defaults to that specified by the
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
147 ## figure's paperposition property.
6965
c962cc09067a [project @ 2007-10-06 04:54:36 by jwe]
jwe
parents: 6895
diff changeset
148 ##
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
149 ## @item -F@var{fontname}
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
150 ## @itemx -F@var{fontname}:@var{size}
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
151 ## @itemx -F:@var{size}
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
152 ## @var{fontname} set the postscript font (for use with postscript,
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
153 ## aifm, corel and fig). By default, 'Helvetica' is set for PS/Aifm,
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
154 ## and 'SwitzerlandLight' for Corel. It can also be 'Times-Roman'.
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
155 ## @var{size} is given in points. @var{fontname} is ignored for the
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
156 ## fig device.
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
157 ## @end table
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
158 ##
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
159 ## The filename and options can be given in any order.
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
160 ## @end deftypefn
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
161
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
162 ## Author: Daniel Heiserer <Daniel.heiserer@physik.tu-muenchen.de>
5362
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
163 ## Adapted-By: jwe
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
164
5362
ef053d682e42 [project @ 2005-05-23 19:21:54 by jwe]
jwe
parents: 5361
diff changeset
165 function print (varargin)
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
166
5365
c9c773d8333f [project @ 2005-05-23 20:05:15 by jwe]
jwe
parents: 5363
diff changeset
167 orientation = orient ();
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
168 use_color = 0; # 0=default, -1=mono, +1=color
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
169 force_solid = 0; # 0=default, -1=dashed, +1=solid
5363
37f62a7778c2 [project @ 2005-05-23 19:52:15 by jwe]
jwe
parents: 5362
diff changeset
170 fontsize = "";
37f62a7778c2 [project @ 2005-05-23 19:52:15 by jwe]
jwe
parents: 5362
diff changeset
171 font = "";
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
172 canvas_size = "";
5363
37f62a7778c2 [project @ 2005-05-23 19:52:15 by jwe]
jwe
parents: 5362
diff changeset
173 name = "";
37f62a7778c2 [project @ 2005-05-23 19:52:15 by jwe]
jwe
parents: 5362
diff changeset
174 devopt = "";
37f62a7778c2 [project @ 2005-05-23 19:52:15 by jwe]
jwe
parents: 5362
diff changeset
175 printer = "";
6870
e2e5425905ac [project @ 2007-09-06 20:18:20 by jwe]
jwe
parents: 6739
diff changeset
176 debug = false;
6872
bdbe9778d995 [project @ 2007-09-06 21:00:30 by jwe]
jwe
parents: 6870
diff changeset
177 debug_file = "octave-print-commands.log";
7037
b1ca2c453b77 [project @ 2007-10-17 21:25:44 by jwe]
jwe
parents: 7032
diff changeset
178 special_flag = "textnormal";
8889
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
179 resolution = "";
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
180 if (isunix ())
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
181 ghostscript_binary = "gs";
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
182 elseif (ispc ())
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
183 ghostscript_binary = "gswin23c";
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
184 endif
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
185
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
186 old_fig = get (0, "currentfigure");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
187 unwind_protect
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
188 ## Ensure the last figure is on the screen for single line commands like
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
189 ## plot(...); print(...);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
190 drawnow ();
7032
4d4197ffb09d [project @ 2007-10-15 16:31:55 by jwe]
jwe
parents: 7017
diff changeset
191
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
192 for i = 1:nargin
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
193 arg = varargin{i};
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
194 if (ischar (arg))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
195 if (strcmp (arg, "-color"))
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
196 use_color = 1;
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
197 elseif (strcmp (arg, "-mono"))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
198 use_color = -1;
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
199 elseif (strcmp (arg, "-solid"))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
200 force_solid = 1;
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
201 elseif (strcmp (arg, "-dashed"))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
202 force_solid = -1;
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
203 elseif (strcmp (arg, "-portrait"))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
204 orientation = "portrait";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
205 elseif (strcmp (arg, "-landscape"))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
206 orientation = "landscape";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
207 elseif (strcmp (arg, "-textspecial"))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
208 special_flag = "textspecial";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
209 elseif (strncmp (arg, "-debug", 6))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
210 debug = true;
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
211 if (length (arg) > 7)
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
212 debug_file = arg(8:end);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
213 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
214 elseif (length (arg) > 2 && arg(1:2) == "-d")
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
215 devopt = tolower(arg(3:end));
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
216 elseif (length (arg) > 2 && arg(1:2) == "-P")
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
217 printer = arg;
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
218 elseif ((length (arg) > 2) && arg(1:2) == "-G")
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
219 ghostscript_binary = arg(3:end);
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
220 elseif (length (arg) > 2 && arg(1:2) == "-F")
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
221 idx = rindex (arg, ":");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
222 if (idx)
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
223 font = arg(3:idx-1);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
224 fontsize = arg(idx+1:length(arg));
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
225 else
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
226 font = arg(3:length(arg));
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
227 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
228 elseif (length (arg) > 2 && arg(1:2) == "-S")
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
229 canvas_size = arg(3:length(arg));
8889
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
230 elseif (length (arg) > 2 && arg(1:2) == "-r")
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
231 resolution = arg(3:length(arg));
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
232 elseif (length (arg) >= 1 && arg(1) == "-")
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
233 error ("print: unknown option `%s'", arg);
7556
c69d4732d877 print.m: fix oops in applying last change (really, I mean it this time)
John W. Eaton <jwe@octave.org>
parents: 7555
diff changeset
234 elseif (length (arg) > 0)
c69d4732d877 print.m: fix oops in applying last change (really, I mean it this time)
John W. Eaton <jwe@octave.org>
parents: 7555
diff changeset
235 name = arg;
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
236 endif
8239
041bb0c64f07 orient.m,print.f: validate figure handle
Ben Abbott <bpabbott@mac.com>
parents: 8049
diff changeset
237 elseif (isfigure (arg))
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
238 figure (arg);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
239 else
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
240 error ("print: expecting inputs to be character string options or a figure handle");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
241 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
242 endfor
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
243
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
244 doprint = isempty (name);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
245 if (doprint)
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
246 if (isempty (devopt))
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
247 if (use_color < 0)
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
248 devopt = "ps";
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
249 printname = cstrcat (tmpnam, ".ps");
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
250 else
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
251 devopt = "psc";
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
252 printname = cstrcat (tmpnam, ".psc");
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
253 endif
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
254 else
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
255 printname = cstrcat (tmpnam, ".", devopt);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
256 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
257 name = printname;
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
258 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
259
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
260 if (isempty (devopt))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
261 dot = rindex (name, ".");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
262 if (dot == 0)
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
263 error ("print: no format specified");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
264 else
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
265 dev = tolower (name(dot+1:end));
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
266 endif
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
267 else
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
268 dev = devopt;
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
269 endif
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
270
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
271 if (strcmp (dev, "tex"))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
272 dev = "epslatex";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
273 ## gnuplot 4.0 wants ".eps" in the output name
8639
399af34bb4bf # User Ben Abbott <bpabbott@mac.com>
John W. Eaton <jwe@octave.org>
parents: 8239
diff changeset
274 if (! __gnuplot_has_feature__ ("epslatex_implies_eps_filesuffix"))
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
275 name = cstrcat (name(1:dot), "eps");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
276 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
277 elseif (strcmp (dev, "ill"))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
278 dev = "aifm";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
279 elseif (strcmp (dev, "cdr"))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
280 dev = "corel";
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
281 elseif (strcmp (dev, "meta"))
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
282 dev = "emf";
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
283 elseif (strcmp (dev, "jpg"))
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
284 dev = "jpeg";
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
285 endif
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
286
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
287 ## Check if the specified device is one that is supported by gnuplot.
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
288 ## If not, assume it is a device/format supported by Ghostscript.
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
289 dev_list = {"aifm", "corel", "fig", "png", "jpeg", ...
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
290 "gif", "pbm", "dxf", "mf", "svg", "hpgl", ...
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
291 "ps", "ps2", "psc", "psc2", "eps", "eps2", ...
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
292 "epsc", "epsc2", "emf", "pdf", "pslatex", ...
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
293 "epslatex", "epslatexstandalone", "pstex"};
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
294 if (! any (strcmp (dev, dev_list)))
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
295 ghostscript_output = name;
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
296 ghostscript_device = dev;
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
297 dev = "epsc";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
298 name = cstrcat (tmpnam, ".eps");
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
299 else
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
300 ghostscript_output = "";
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
301 endif
5363
37f62a7778c2 [project @ 2005-05-23 19:52:15 by jwe]
jwe
parents: 5362
diff changeset
302
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
303 termn = dev;
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
304
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
305 ## SVG isn't actually a bitmap, but gnuplot treats its size option as it
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
306 ## does the bitmap terminals.
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
307 bitmap_devices = {"emf", "gif", "jpeg", "pbm", "png", "svg"};
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
308
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
309 if (any (strcmp (dev, {"ps", "ps2", "psc", "psc2", "epsc", "epsc2", ...
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
310 "eps", "eps2", "pstex", "pslatex", "epslatex", ...
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
311 "epslatexstandalone"})))
6727
3d1e0a056e6e [project @ 2007-06-14 20:45:10 by jwe]
jwe
parents: 6272
diff changeset
312
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
313 ## Various postscript options
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
314 if (any (strcmp (dev, {"pstex", "pslatex", "epslatex"})))
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
315 options = "";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
316 elseif (strcmp (dev, "epslatexstandalone"))
8639
399af34bb4bf # User Ben Abbott <bpabbott@mac.com>
John W. Eaton <jwe@octave.org>
parents: 8239
diff changeset
317 if (__gnuplot_has_feature__ ("epslatexstandalone_terminal"))
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
318 termn = "epslatex";
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
319 options = "standalone ";
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
320 else
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
321 error ("print: epslatexstandalone needs gnuplot 4.2 or higher");
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
322 endif
6727
3d1e0a056e6e [project @ 2007-06-14 20:45:10 by jwe]
jwe
parents: 6272
diff changeset
323 else
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
324 if (dev(1) == "e")
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
325 options = "eps ";
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
326 else
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
327 options = cstrcat (orientation, " ");
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
328 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
329 termn = "postscript";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
330 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
331
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
332 if (any (dev == "c") || use_color > 0)
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
333 if (force_solid < 0)
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
334 options = cstrcat (options, "color dashed ");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
335 else
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
336 options = cstrcat (options, "color solid ");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
337 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
338 else
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
339 if (force_solid > 0)
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
340 options = cstrcat (options, "mono solid ");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
341 else
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
342 options = cstrcat (options, "mono dashed ");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
343 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
344 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
345
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
346 if (! isempty (font))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
347 options = cstrcat (options, "\"", font, "\" ");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
348 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
349 if (! isempty (fontsize))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
350 options = cstrcat (options, " ", fontsize);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
351 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
352
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
353 new_terminal = cstrcat (termn, " ", options);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
354
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
355 elseif (strcmp (dev, "aifm") || strcmp (dev, "corel"))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
356 ## Adobe Illustrator, CorelDraw
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
357 if (use_color >= 0)
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
358 options = " color";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
359 else
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
360 options = " mono";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
361 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
362 if (! isempty (font))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
363 options = cstrcat (options, " \"", font, "\"");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
364 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
365 if (! isempty (fontsize))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
366 options = cstrcat (options, " ", fontsize);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
367 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
368
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
369 elseif (strcmp (dev, "fig"))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
370 ## XFig
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
371 options = orientation;
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
372 if (use_color >= 0)
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
373 options = " color";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
374 else
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
375 options = " mono";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
376 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
377 options = cstrcat (options, " ", special_flag);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
378 if (! isempty (fontsize))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
379 options = cstrcat (options, " fontsize ", fontsize);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
380 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
381
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
382 elseif (strcmp (dev, "emf"))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
383 ## Enhanced Metafile format
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
384 options = " ";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
385 if (use_color >= 0)
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
386 options = " color";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
387 else
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
388 options = " mono";
6727
3d1e0a056e6e [project @ 2007-06-14 20:45:10 by jwe]
jwe
parents: 6272
diff changeset
389 endif
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
390 if (force_solid >= 0)
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
391 options = cstrcat (options, " solid");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
392 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
393 if (! isempty (font))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
394 options = cstrcat (options, " \"", font, "\"");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
395 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
396 if (! isempty (fontsize))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
397 options = cstrcat (options, " ", fontsize);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
398 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
399
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
400 elseif (any (strcmp (dev, bitmap_devices)))
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
401
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
402 if (isempty (canvas_size) && isempty (resolution)
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
403 && any (strcmp (dev, {"pbm", "gif", "jpeg", "png"})))
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
404 options = "large";
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
405 elseif (strcmp (dev, "svg"))
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
406 ## Referring to size, either "dynamic" or "fixed"
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
407 options = "fixed";
6727
3d1e0a056e6e [project @ 2007-06-14 20:45:10 by jwe]
jwe
parents: 6272
diff changeset
408 else
8889
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
409 options = "";
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
410 end
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
411 if (! isempty (canvas_size))
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
412 options = cstrcat (options, " size ", canvas_size);
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
413 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
414
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
415 elseif (any (strcmp (dev, {"dxf", "mf", "hpgl"})))
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
416 ## AutoCad DXF, METAFONT, HPGL
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
417 options = "";
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
418
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
419 elseif (strcmp (dev, "pdf"))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
420 ## Portable Document format
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
421 options = " ";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
422 if (use_color >= 0)
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
423 options = "color";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
424 else
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
425 options = "mono";
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
426 endif
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
427 if (force_solid >= 0)
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
428 options = cstrcat (options, " solid");
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
429 elseif (force_solid < 0)
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
430 options = cstrcat (options, " dashed");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
431 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
432 if (! isempty (font))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
433 options = cstrcat (options, "\"", font, "\" ");
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
434 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
435 if (! isempty (fontsize))
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
436 options = cstrcat (options, " ", fontsize);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
437 endif
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
438
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
439 endif
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
440
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
441 if (__gnuplot_has_feature__ ("variable_GPVAL_TERMINALS"))
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
442 available_terminals = __gnuplot_get_var__ (gcf, "GPVAL_TERMINALS");
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
443 available_terminals = regexp (available_terminals, "\\b\\w+\\b", "match");
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
444 gnuplot_supports_term = any (strcmp (available_terminals, termn));
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
445 elseif (strcmp (termn, "pdf"))
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
446 ## Some Linux variants do not include a "pdf" capable gnuplot.
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
447 ## To be safe, use Ghostscript.
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
448 if (isunix ())
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
449 [status, output] = system (sprintf ("which %s", ghostscript_binary));
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
450 elseif (ispc ())
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
451 status = 0;
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
452 endif
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
453 have_ghostscript = (status == 0);
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
454 if (have_ghostscript)
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
455 gnuplot_supports_term = false;
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
456 ghostscript_device = "pdfwrite";
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
457 else
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
458 gnuplot_supports_term = true;
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
459 endif
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
460 else
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
461 gnuplot_supports_term = true;
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
462 endif
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
463
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
464 if (! gnuplot_supports_term)
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
465 if (strcmp (termn, "pdf"))
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
466 ## If there the installed gnuplot does not support pdf, use Ghostscript.
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
467 ghostscript_device = "pdfwrite";
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
468 if (strfind (name, ".pdf") == numel (name) - 3)
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
469 ghostscript_output = name;
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
470 else
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
471 ghostscript_output = strcat (name, ".pdf");
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
472 endif
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
473 name = cstrcat (tmpnam, ".ps");
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
474 termn = "postscript";
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
475 options = cstrcat (options, " portrait");
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
476 ## All "options" for pdf work for postscript as well.
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
477 else
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
478 error ("print: the gnuplot terminal, \"%s\", is not available.", termn)
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
479 endif
6179
235a1b456cf4 [project @ 2006-11-17 17:33:09 by jwe]
jwe
parents: 6178
diff changeset
480 endif
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
481
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
482 new_terminal = cstrcat (termn, " ", options);
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
483
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
484 mono = use_color < 0;
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
485
8889
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
486 if (isempty (resolution))
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
487 if (any (strcmp (termn, {"emf", "svg"})))
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
488 resolution = get (0, "screenpixelsperinch");
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
489 else
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
490 resolution = 150;
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
491 endif
8889
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
492 else
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
493 resolution = str2num (resolution);
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
494 if (resolution == 0)
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
495 resolution = get (0, "screenpixelsperinch");
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
496 endif
8889
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
497 endif
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
498 figure_properties = get (gcf);
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
499 if (! isfield (figure_properties, "__pixels_per_inch__"))
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
500 addproperty ("__pixels_per_inch__", gcf, "double", resolution);
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
501 endif
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
502 set (gcf, "__pixels_per_inch__", resolution)
665b264b6a50 Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
503
9000
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
504 unwind_protect
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
505 paper_position_mode = get (gcf, "paperpositionmode");
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
506 terminals_for_prn = {"postscript", "pdf"};
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
507 restore_properties = false;
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
508 if ((! any (strncmp (termn, terminals_for_prn, numel(termn)))
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
509 || strncmp (dev, "eps", 3)) && ! doprint)
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
510 ## If not PDF or PostScript, and the result is not being sent to a printer,
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
511 ## render an image the size of the paperposition box.
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
512 restore_properties = true;
9000
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
513 p.paperunits = get (gcf, "paperunits");
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
514 p.papertype = get (gcf, "papertype");
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
515 p.papersize = get (gcf, "papersize");
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
516 p.paperposition = get (gcf, "paperposition");
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
517 p.paperpositionmode = get (gcf, "paperpositionmode");
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
518 set (gcf, "paperunits", "inches");
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
519 if (! isempty (canvas_size))
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
520 size_in_pixels = sscanf (canvas_size ,"%d, %d");
9056
b06dc393ac42 print.m: For eps output the bounding box should represent the figure's position.
Ben Abbott <bpabbott@mac.com>
parents: 9042
diff changeset
521 size_in_pixels = reshape (size_in_pixels, [1, numel(size_in_pixels)]);
b06dc393ac42 print.m: For eps output the bounding box should represent the figure's position.
Ben Abbott <bpabbott@mac.com>
parents: 9042
diff changeset
522 papersize_in_inches = size_in_pixels ./ resolution;
b06dc393ac42 print.m: For eps output the bounding box should represent the figure's position.
Ben Abbott <bpabbott@mac.com>
parents: 9042
diff changeset
523 paperposition_in_inches = [0, 0, papersize_in_inches];
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
524 else
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
525 paperposition_in_inches = get (gcf, "paperposition");
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
526 paperposition_in_inches(1:2) = 0;
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
527 papersize_in_inches = paperposition_in_inches(3:4);
9056
b06dc393ac42 print.m: For eps output the bounding box should represent the figure's position.
Ben Abbott <bpabbott@mac.com>
parents: 9042
diff changeset
528 endif
9000
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
529 set (gcf, "papertype", "<custom>");
9056
b06dc393ac42 print.m: For eps output the bounding box should represent the figure's position.
Ben Abbott <bpabbott@mac.com>
parents: 9042
diff changeset
530 set (gcf, "papersize", papersize_in_inches);
b06dc393ac42 print.m: For eps output the bounding box should represent the figure's position.
Ben Abbott <bpabbott@mac.com>
parents: 9042
diff changeset
531 set (gcf, "paperposition", paperposition_in_inches);
9000
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
532 set (gcf, "paperpositionmode", "manual");
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
533 endif
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
534 if (debug)
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
535 drawnow (new_terminal, name, mono, debug_file);
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
536 else
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
537 drawnow (new_terminal, name, mono);
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
538 endif
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
539 unwind_protect_cleanup
9056
b06dc393ac42 print.m: For eps output the bounding box should represent the figure's position.
Ben Abbott <bpabbott@mac.com>
parents: 9042
diff changeset
540 ## FIXME - it would be nice to delete "__pixels_per_inch__" property here.
9107
d0d507cbd123 Improvements to printing functionality.
Ben Abbott <bpabbott@mac.com>
parents: 9056
diff changeset
541 if (restore_properties)
9000
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
542 props = fieldnames (p);
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
543 for n = 1:numel(props)
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
544 set (gcf, props{n}, p.(props{n}))
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
545 endfor
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
546 endif
cc916241e811 print.m: Restore the old behavior for -S<num>,<num>.
Ben Abbott <bpabbott@mac.com>
parents: 8920
diff changeset
547 end_unwind_protect
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
548
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
549 if (! isempty (ghostscript_output))
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
550 ghostscript_options = "-q -dBATCH -dSAFER -dNOPAUSE -dTextAlphaBits=4";
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
551 if (! isempty (strfind (options, "eps")))
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
552 ## If gnuplot's output is an eps-file then crop at the bouding box.
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
553 ghostscript_options = sprintf ("%s -dEPSCrop", ghostscript_options);
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
554 end
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
555 if (isempty (strfind (lower (ghostscript_device), "write")))
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
556 ## If output is a bitmap then include the resolution
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
557 ghostscript_options = sprintf ("%s -r%d", ghostscript_options, resolution);
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
558 endif
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
559 ghostscript_options = sprintf ("%s -sDEVICE=%s", ghostscript_options,
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
560 ghostscript_device);
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
561 command = sprintf ("%s %s -sOutputFile='%s' '%s'", ghostscript_binary,
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
562 ghostscript_options, ghostscript_output, name);
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
563 [errcode, output] = system (command);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
564 unlink (name);
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
565 if (errcode)
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
566 fprintf ("$ %s\n", command)
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
567 disp(output)
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
568 error ("print: could not convert; %s -> %s.", name, ghostscript_output);
5625
f88f2e35ad6e [project @ 2006-02-15 18:42:22 by jwe]
jwe
parents: 5521
diff changeset
569 endif
6179
235a1b456cf4 [project @ 2006-11-17 17:33:09 by jwe]
jwe
parents: 6178
diff changeset
570 endif
6178
830235f4984f [project @ 2006-11-17 00:16:57 by jwe]
jwe
parents: 6019
diff changeset
571
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
572 if (doprint)
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
573 if (isunix ())
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
574 prn_opt = "-l";
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
575 elseif (ispc ())
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
576 prn_opt = "-o l";
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
577 else
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
578 ## FIXME - besides Unix and Windows, what other OS's might be considered.
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
579 prn_opt = "";
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
580 endif
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
581 if (isempty (printer))
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
582 prn_cmd = sprintf ("lpr %s '%s'", prn_opt, printname);
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
583 else
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
584 prn_cmd = sprintf ("lpr %s -P %s '%s'", prn_opt, printer, printname);
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
585 endif
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
586 [status, output] = system (prn_cmd);
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
587 if (status != 0)
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
588 disp (output)
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
589 warning ("print.m: printing failed.")
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
590 endif
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
591 [status, output] = unlink (printname);
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
592 if (status != 0)
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
593 disp (output)
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
594 warning ("print.m: failed to delete temporay file, '%s'.", printname)
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
595 endif
6179
235a1b456cf4 [project @ 2006-11-17 17:33:09 by jwe]
jwe
parents: 6178
diff changeset
596 endif
235a1b456cf4 [project @ 2006-11-17 17:33:09 by jwe]
jwe
parents: 6178
diff changeset
597
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
598 unwind_protect_cleanup
8239
041bb0c64f07 orient.m,print.f: validate figure handle
Ben Abbott <bpabbott@mac.com>
parents: 8049
diff changeset
599 if (isfigure (old_fig))
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
600 figure (old_fig)
6965
c962cc09067a [project @ 2007-10-06 04:54:36 by jwe]
jwe
parents: 6895
diff changeset
601 endif
7550
bffb1e2ab732 print.m: Figure handle as argument.
Ben Abbott <bpabbott@mac.com>
parents: 7543
diff changeset
602 end_unwind_protect
5363
37f62a7778c2 [project @ 2005-05-23 19:52:15 by jwe]
jwe
parents: 5362
diff changeset
603
5361
0ac38aea9f76 [project @ 2005-05-23 19:08:36 by jwe]
jwe
parents:
diff changeset
604 endfunction
9152
4c9aff0c9a61 print.m: Use Ghostscript rather than ImageMagick's 'convert'.
Ben Abbott <bpabbott@mac.com>
parents: 9107
diff changeset
605