comparison scripts/plot/util/print.m @ 18746:29f00c0d0657

Fix double '-P' in print command to printer (bug #41957). * print.m: Expand documentation of latex and latexstandalone options. Change some of the documentation examples to use more useful, modern devices (jpg instead of HP DeskJet 550C). Use isempty to determine in there is a figure to print. Remove extra '-P' from print command going directly to printer.
author Michael Godfrey <michaeldgodfrey@gmail.com>
date Tue, 25 Mar 2014 17:00:41 +0000
parents 13c80c3e9660
children 7bbe3658c5ef
comparison
equal deleted inserted replaced
18744:70d9db29db6f 18746:29f00c0d0657
101 ## @itemx epsc 101 ## @itemx epsc
102 ## @itemx epsc2 102 ## @itemx epsc2
103 ## Encapsulated PostScript (level 1 and 2, mono and color). The FLTK 103 ## Encapsulated PostScript (level 1 and 2, mono and color). The FLTK
104 ## graphic toolkit generates PostScript level 3.0. 104 ## graphic toolkit generates PostScript level 3.0.
105 ## 105 ##
106 ## @item tex 106 ## @item pslatex
107 ## @itemx epslatex 107 ## @itemx epslatex
108 ## @itemx pdflatex
109 ## @itemx pslatexstandalone
108 ## @itemx epslatexstandalone 110 ## @itemx epslatexstandalone
109 ## @itemx pstex 111 ## @itemx pdflatexstandalone
110 ## @itemx pslatex 112 ## Generate a @LaTeX{} file @file{@var{filename}.tex} for the text
111 ## @itemx pdflatex 113 ## portions of a plot and a file @file{@var{filename}.(ps|eps|pdf)} for the
112 ## Generate a @LaTeX{} (or @TeX{}) file for labels and eps/ps/pdf 114 ## remaining graphics. The graphics file suffix .ps|eps|pdf is determined
113 ## for graphics. The file produced by @code{epslatexstandalone} can be 115 ## by the specified device type. The @LaTeX{} file produced by the
114 ## processed directly by @LaTeX{}. The other formats are intended to 116 ## @samp{standalone} option can be processed directly by @LaTeX{}. The file
115 ## be included in a @LaTeX{} (or @TeX{}) document. The @code{tex} device 117 ## generated without the @samp{standalone} option is intended to be included
116 ## is the same as the @code{epslatex} device. The @code{pdflatex} device 118 ## from another @LaTeX{} document. In either case, the @LaTeX{} file
117 ## is only available for the FLTK graphics toolkit. 119 ## contains an @code{\includegraphics} command so that the generated graphics
120 ## file is automatically included when the @LaTeX{} file is processed. The
121 ## text that is written to the @LaTeX{} file contains the strings
122 ## @strong{exactly} as they were specified in the plot. If any special
123 ## characters of the @TeX{} mode interpreter were used, the file must be
124 ## edited before @LaTeX{} processing. Specifically, the special characters
125 ## must be enclosed with dollar signs (@code{$ @dots{} $}), and other
126 ## characters that are recognized by @LaTeX{} may also need editing (.e.g.,
127 ## braces). The @samp{pdflatex} device, and any of the @samp{standalone}
128 ## formats, are not available with the Gnuplot toolkit.
118 ## 129 ##
119 ## @item tikz 130 ## @item tikz
120 ## Generate a @LaTeX{} file using PGF/TikZ@. For the FLTK toolkit 131 ## Generate a @LaTeX{} file using PGF/TikZ@. For the FLTK toolkit
121 ## the result is PGF. 132 ## the result is PGF.
122 ## 133 ##
173 ## @item -d@var{ghostscript_device} 184 ## @item -d@var{ghostscript_device}
174 ## Additional devices are supported by Ghostscript. 185 ## Additional devices are supported by Ghostscript.
175 ## Some examples are; 186 ## Some examples are;
176 ## 187 ##
177 ## @table @code 188 ## @table @code
189 ## @item pdfwrite
190 ## Produces pdf output from eps
191 ##
178 ## @item ljet2p 192 ## @item ljet2p
179 ## HP LaserJet @nospell{IIP} 193 ## HP LaserJet @nospell{IIP}
180 ## 194 ##
181 ## @item ljet3
182 ## HP LaserJet III
183 ##
184 ## @item deskjet
185 ## HP DeskJet and DeskJet Plus
186 ##
187 ## @item cdj550
188 ## HP DeskJet 550C
189 ##
190 ## @item paintjet
191 ## HP PointJet
192 ##
193 ## @item pcx24b 195 ## @item pcx24b
194 ## 24-bit color PCX file format 196 ## 24-bit color PCX file format
195 ## 197 ##
196 ## @item ppm 198 ## @item ppm
197 ## Portable Pixel Map file format 199 ## Portable Pixel Map file format
198 ##
199 ## @item pdfwrite
200 ## Produces pdf output from eps
201 ## @end table 200 ## @end table
202 ## 201 ##
203 ## For a complete list, type @code{system ("gs -h")} to see what formats 202 ## For a complete list, type @code{system ("gs -h")} to see what formats
204 ## and devices are available. 203 ## and devices are available.
205 ## 204 ##
252 ## @var{fontname} is ignored for some devices: dxf, fig, hpgl, etc. 251 ## @var{fontname} is ignored for some devices: dxf, fig, hpgl, etc.
253 ## @end table 252 ## @end table
254 ## 253 ##
255 ## The filename and options can be given in any order. 254 ## The filename and options can be given in any order.
256 ## 255 ##
257 ## Example: Print to a file using the svg device. 256 ## Example: Print to a file using the pdf device.
258 ## 257 ##
259 ## @example 258 ## @example
260 ## @group 259 ## @group
261 ## figure (1); 260 ## figure (1);
262 ## clf (); 261 ## clf ();
263 ## surf (peaks); 262 ## surf (peaks);
264 ## print -dsvg figure1.svg 263 ## print figure1.pdf
265 ## @end group 264 ## @end group
266 ## @end example 265 ## @end example
267 ## 266 ##
268 ## Example: Print to an HP DeskJet 550C. 267 ## Example: Print to a file using jpg device.
269 ## 268 ##
270 ## @example 269 ## @example
271 ## @group 270 ## @group
272 ## clf (); 271 ## clf ();
273 ## surf (peaks); 272 ## surf (peaks);
274 ## print -dcdj550 273 ## print -djpg figure2.jpg
274 ## @end group
275 ## @end example
276 ##
277 ## Example: Print to printer named PS_printer using ps format.
278 ##
279 ## @example
280 ## @group
281 ## clf ();
282 ## surf (peaks);
283 ## print -dpswrite -PPS_printer
275 ## @end group 284 ## @end group
276 ## @end example 285 ## @end example
277 ## 286 ##
278 ## @seealso{saveas, hgsave, orient, figure} 287 ## @seealso{saveas, hgsave, orient, figure}
279 ## @end deftypefn 288 ## @end deftypefn
286 opts.fig2dev_cmd = @fig2dev; 295 opts.fig2dev_cmd = @fig2dev;
287 opts.latex_standalone = @latex_standalone; 296 opts.latex_standalone = @latex_standalone;
288 opts.lpr_cmd = @lpr; 297 opts.lpr_cmd = @lpr;
289 opts.epstool_cmd = @epstool; 298 opts.epstool_cmd = @epstool;
290 299
291 if (! isfigure (opts.figure)) 300 if (isempty (opts.figure) || ! isfigure (opts.figure))
292 error ("print: no figure to print"); 301 error ("print: no figure to print");
293 endif 302 endif
294 303
295 orig_figure = get (0, "currentfigure"); 304 orig_figure = get (0, "currentfigure");
296 set (0, "currentfigure", opts.figure); 305 set (0, "currentfigure", opts.figure);
412 set (hlist(! haxes), "fontsize", fontsize); 421 set (hlist(! haxes), "fontsize", fontsize);
413 set (hlist(haxes), "fontsize", fontsize); 422 set (hlist(haxes), "fontsize", fontsize);
414 endif 423 endif
415 endif 424 endif
416 425
417 ## call the graphcis toolkit print script 426 ## call the graphics toolkit print script
418 switch (get (opts.figure, "__graphics_toolkit__")) 427 switch (get (opts.figure, "__graphics_toolkit__"))
419 case "gnuplot" 428 case "gnuplot"
420 opts = __gnuplot_print__ (opts); 429 opts = __gnuplot_print__ (opts);
421 otherwise 430 otherwise
422 opts = __fltk_print__ (opts); 431 opts = __fltk_print__ (opts);
687 cmd = opts.lpr_binary; 696 cmd = opts.lpr_binary;
688 if (! isempty (opts.lpr_options)) 697 if (! isempty (opts.lpr_options))
689 cmd = sprintf ("%s %s", cmd, opts.lpr_options); 698 cmd = sprintf ("%s %s", cmd, opts.lpr_options);
690 endif 699 endif
691 if (! isempty (opts.printer)) 700 if (! isempty (opts.printer))
692 cmd = sprintf ("%s -P %s", cmd, opts.printer); 701 cmd = sprintf ("%s %s", cmd, opts.printer);
693 endif 702 endif
694 elseif (isempty (opts.lpr_binary)) 703 elseif (isempty (opts.lpr_binary))
695 error ("print:nolpr", "print.m: 'lpr' not found in PATH"); 704 error ("print:nolpr", "print.m: 'lpr' not found in PATH");
696 endif 705 endif
697 if (opts.debug) 706 if (opts.debug)