annotate scripts/plot/util/private/__ghostscript__.m @ 30564:796f54d4ddbf stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021. In all .txi and .texi files except gpl.txi and gpl.texi in the doc/liboctave and doc/interpreter directories, change the copyright to "Octave Project Developers", the same as used for other source files. Update copyright notices for 2022 (not done since 2019). For gpl.txi and gpl.texi, change the copyright notice to be "Free Software Foundation, Inc." and leave the date at 2007 only because this file only contains the text of the GPL, not anything created by the Octave Project Developers. Add Paul Thomas to contributors.in.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Dec 2021 18:22:40 -0500
parents 0a5b15007766
children 5d3faba0342e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3 ## Copyright (C) 2010-2022 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27632
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
7 ##
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 11014
diff changeset
8 ## This file is part of Octave.
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 11014
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24221
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 11014
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24221
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22517
diff changeset
13 ## (at your option) any later version.
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 11014
diff changeset
14 ##
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 11014
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 11014
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22517
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22517
diff changeset
18 ## GNU General Public License for more details.
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 11014
diff changeset
19 ##
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24221
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
25
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20721
diff changeset
27 ## @deftypefn {} {} __ghostscript__ (@var{@dots{}})
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
28 ## Undocumented internal function.
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
29 ## @end deftypefn
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
30
22767
212333a97d8d maint: Remove dangling ';' from m-file function declarations.
Rik <rik@octave.org>
parents: 22755
diff changeset
31 function [gs_cmd, cleanup_cmd] = __ghostscript__ (varargin)
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
32
19679
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
33 dos_shell = (ispc () && ! isunix ());
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
34
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
35 opts.binary = "";
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
36 opts.source = "-";
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
37 opts.output = "-";
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
38 opts.device = "";
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
39 opts.epscrop = false;
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19725
diff changeset
40 opts.antialiasing = false;
22517
34f98c1e4d56 Disable anti-aliasing for graphics in raster outputs (bug #48873).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
41 opts.antialiasing_textalphabits = 4;
34f98c1e4d56 Disable anti-aliasing for graphics in raster outputs (bug #48873).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
42 opts.antialiasing_graphicsalphabits = 1;
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
43 opts.resolution = 150;
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
44 opts.papersize = "";
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
45 opts.pageoffset = [0 0];
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
46 opts.debug = false;
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
47 opts.level = [];
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
48 opts.prepend = "";
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
49
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
50 offsetfile = "";
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
51 offset_ps = {};
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
52 cleanup_cmd = "";
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
53
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
54 args = varargin;
12931
cefd568ea073 Replace function handles with function names in cellfun calls for 15% speedup.
Rik <octave@nomad.inbox5.com>
parents: 12460
diff changeset
55 n = find (cellfun ("isclass", args, "struct"));
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
56 if (! isempty (n))
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
57 f = fieldnames (args{n});
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
58 for m = 1:numel (f)
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
59 opts.(f{m}) = args{n}.(f{m});
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
60 endfor
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
61 args(n) = [];
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
62 endif
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
63 for n = 1:2:numel (args)
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
64 opts.(args{n}) = args{n+1};
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
65 endfor
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
66
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
67 if (isempty (opts.binary))
27069
0a62d9a6aa2d Place Octave's warning and error IDs in to the "Octave" namespace (bug #56213).
Rik <rik@octave.org>
parents: 27059
diff changeset
68 error ("Octave:print:nogs", "__ghostscript__: 'gs' (Ghostscript) binary is required for specified output format, but binary is not available in PATH");
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
69 endif
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
70
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
71 if (isempty (opts.papersize))
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
72 format_for_printer = false;
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
73 else
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
74 format_for_printer = true;
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
75 endif
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
76
20721
234589c84d4a Fix rotated graphics when printing through ghostscript (bug #46435).
Rik <rik@octave.org>
parents: 19833
diff changeset
77 gs_opts = ["-dQUIET -dNOPAUSE -dBATCH -dSAFER -dAutoRotatePages=/None -sDEVICE=" opts.device];
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
78
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
79 if (! isempty (opts.level) && ismember (opts.level, [1, 2, 3]))
19725
5f2c0ca0ef51 Ensure that numbers passed to integer *printf format codes are integers (bug #44245).
Rik <rik@octave.org>
parents: 19697
diff changeset
80 gs_opts = sprintf ("%s -dLanguageLevel=%d", gs_opts, opts.level);
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
81 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
82
25626
306e2ce55f27 Use compression by default for printing TIFF images (bug #54290).
Rik <rik@octave.org>
parents: 25054
diff changeset
83 if (strfind (opts.device, "tiffscaled"))
306e2ce55f27 Use compression by default for printing TIFF images (bug #54290).
Rik <rik@octave.org>
parents: 25054
diff changeset
84 gs_opts = [gs_opts " -sCompression=lzw"];
306e2ce55f27 Use compression by default for printing TIFF images (bug #54290).
Rik <rik@octave.org>
parents: 25054
diff changeset
85 endif
306e2ce55f27 Use compression by default for printing TIFF images (bug #54290).
Rik <rik@octave.org>
parents: 25054
diff changeset
86
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
87 if (opts.antialiasing && isempty (strfind (opts.device, "write")))
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
88 ## Apply anti-aliasing to all bitmap formats/devices
14774
0d6dae0f6bc2 Allow setting of ghostscript TextAlphaBits and GraphicsAlphaBits.
John Hunt <huntj@gmx.us>
parents: 14768
diff changeset
89 gs_opts = sprintf ("%s -dTextAlphaBits=%d -dGraphicsAlphaBits=%d",
19725
5f2c0ca0ef51 Ensure that numbers passed to integer *printf format codes are integers (bug #44245).
Rik <rik@octave.org>
parents: 19697
diff changeset
90 gs_opts, fix (opts.antialiasing_textalphabits),
5f2c0ca0ef51 Ensure that numbers passed to integer *printf format codes are integers (bug #44245).
Rik <rik@octave.org>
parents: 19697
diff changeset
91 fix (opts.antialiasing_graphicsalphabits));
5f2c0ca0ef51 Ensure that numbers passed to integer *printf format codes are integers (bug #44245).
Rik <rik@octave.org>
parents: 19697
diff changeset
92 gs_opts = sprintf ("%s -r%dx%d", gs_opts, fix ([1, 1] * opts.resolution));
19568
f88ee85d4da9 Restore valid uses of pswrite device in cset a402493c0605.
Rik <rik@octave.org>
parents: 19567
diff changeset
93 elseif (any (strcmp (opts.device, {"pswrite", "ps2write", "pdfwrite"})))
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
94 gs_opts = sprintf ("%s -dEmbedAllFonts=true", gs_opts);
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
95 if (strcmp (opts.device, "pdfwrite"))
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
96 ## Optimize for loading
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
97 gs_opts = sprintf ("%s -dOptimize=true", gs_opts);
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
98 endif
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
99 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
100
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
101 if (opts.epscrop)
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
102 ## papersize is specified by the eps bbox
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
103 gs_opts = sprintf ("%s -dEPSCrop", gs_opts);
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
104 endif
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
105 if (format_for_printer)
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
106 if (ischar (opts.papersize))
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
107 gs_opts = sprintf ("%s -sPAPERSIZE=%s", gs_opts, opts.papersize);
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
108 elseif (isnumeric (opts.papersize) && numel (opts.papersize) == 2)
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10919
diff changeset
109 gs_opts = sprintf ("%s -dDEVICEWIDTHPOINTS=%d -dDEVICEHEIGHTPOINTS=%d",
19725
5f2c0ca0ef51 Ensure that numbers passed to integer *printf format codes are integers (bug #44245).
Rik <rik@octave.org>
parents: 19697
diff changeset
110 gs_opts, fix (opts.papersize));
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
111 if (opts.papersize(1) > opts.papersize(2))
10954
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10919
diff changeset
112 ## Lanscape mode: This option will result in automatic rotation of the
ee9d74048827 Consolidate gs code into print.m.
Ben Abbott <bpabbott@mac.com>
parents: 10919
diff changeset
113 ## document page if the requested page size matches one
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
114 ## of the default page sizes
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
115 gs_opts = sprintf ("%s -dNORANGEPAGESIZE", gs_opts);
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
116 endif
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
117 else
27069
0a62d9a6aa2d Place Octave's warning and error IDs in to the "Octave" namespace (bug #56213).
Rik <rik@octave.org>
parents: 27059
diff changeset
118 error ("Octave:print:badpapersize", "__ghostscript__.m: invalid 'papersize'");
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
119 endif
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
120 gs_opts = sprintf ("%s -dFIXEDMEDIA", gs_opts);
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
121 ## "pageoffset" is relative to the coordinates, not the BBox LLHC.
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
122 str = sprintf ("%s [%d %d] %s", "<< /Margins [0 0] /.HWMargins [0 0 0 0] /PageOffset",
19725
5f2c0ca0ef51 Ensure that numbers passed to integer *printf format codes are integers (bug #44245).
Rik <rik@octave.org>
parents: 19697
diff changeset
123 fix (opts.pageoffset), ">> setpagedevice");
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
124 offset_ps = {"%!PS-Adobe-3.0", str, "%%EOF"};
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
125 if (isfield (opts, "offsetfile"))
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
126 offsetfile = opts.offsetfile;
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
127 cleanup_cmd = "";
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
128 else
19278
6ca096827123 Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents: 18857
diff changeset
129 offsetfile = [tempname() ".ps"];
19679
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
130 if (dos_shell)
27622
df8942d19b7b Allow printing with Octave installed in path with parenthesis (bug #49718)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27069
diff changeset
131 cleanup_cmd = sprintf ('del "%s"', strrep (offsetfile, '/', '\'));
19679
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
132 else
27632
2f38c2681b3e fix incorrect path separator in __ghostscript__ command strings (bug #49718)
Mike Miller <mtmiller@octave.org>
parents: 27622
diff changeset
133 cleanup_cmd = sprintf ('rm "%s"', offsetfile);
19679
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
134 endif
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
135 endif
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
136 unwind_protect
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
137 fid = fopen (offsetfile, "w");
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
138 if (fid == -1)
27069
0a62d9a6aa2d Place Octave's warning and error IDs in to the "Octave" namespace (bug #56213).
Rik <rik@octave.org>
parents: 27059
diff changeset
139 error ("Octave:print:fopenfailed", "__ghostscript__.m: fopen () failed");
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
140 endif
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11588
diff changeset
141 fprintf (fid, "%s\n", offset_ps{:});
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
142 unwind_protect_cleanup
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
143 status = fclose (fid);
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
144 if (status == -1)
27069
0a62d9a6aa2d Place Octave's warning and error IDs in to the "Octave" namespace (bug #56213).
Rik <rik@octave.org>
parents: 27059
diff changeset
145 error ("Octave:print:fclosefailed", "__ghostscript__.m: fclose () failed");
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
146 endif
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10854
diff changeset
147 end_unwind_protect
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
148 if (opts.debug)
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11588
diff changeset
149 fprintf ("---- begin %s ----\n", offsetfile);
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11588
diff changeset
150 fprintf ("%s\n", offset_ps{:});
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11588
diff changeset
151 fprintf ("----- end %s -----\n", offsetfile);
10854
d5a7db05d591 Add PS and PDF output for the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10834
diff changeset
152 endif
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
153 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
154
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
155 if (isempty (opts.output))
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
156 cmd = sprintf ("%s %s", opts.binary, gs_opts);
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
157 else
23991
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
158 cmd = sprintf ('%s %s -sOutputFile="%s"',
fcf7543e0d49 Only print warning messages about missing print tools when needed (bug #44152).
Rik <rik@octave.org>
parents: 23220
diff changeset
159 opts.binary, gs_opts, opts.output);
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
160 endif
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
161 if (! isempty (opts.prepend)
19568
f88ee85d4da9 Restore valid uses of pswrite device in cset a402493c0605.
Rik <rik@octave.org>
parents: 19567
diff changeset
162 && any (strcmpi (opts.device, {"pswrite", "ps2write", "pdfwrite"})))
18857
7bbe3658c5ef maint: Use "FIXME:" coding convention in m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
163 ## FIXME: Fonts get may be mangled when appending ps/ps2.
7bbe3658c5ef maint: Use "FIXME:" coding convention in m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
164 ## See "How to concatenate several PS files" at the link,
7bbe3658c5ef maint: Use "FIXME:" coding convention in m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
165 ## http://en.wikibooks.org/wiki/PostScript_FAQ
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
166 cmd = sprintf ("%s %s", cmd, opts.prepend);
11014
92bb25c0da9e When appending, delete temporary files at the end of the ghostscript pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 11009
diff changeset
167 if (isempty (cleanup_cmd))
19679
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
168 if (dos_shell)
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
169 cleanup_cmd = ["del " strrep(opts.prepend, '/', '\')];
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
170 else
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
171 cleanup_cmd = ["rm " opts.prepend];
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
172 endif
11014
92bb25c0da9e When appending, delete temporary files at the end of the ghostscript pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 11009
diff changeset
173 else
19679
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
174 if (dos_shell)
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
175 cleanup_cmd = sprintf ("%s & del %s", cleanup_cmd,
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
176 strrep (opts.prepend, '/', '\'));
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
177 else
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
178 cleanup_cmd = sprintf ("%s ; rm %s", cleanup_cmd, opts.prepend);
f1270e5a3117 __ghostscript__.m: Use del to remove files on Windows machines (bug #44186).
Rik <rik@octave.org>
parents: 19569
diff changeset
179 endif
11014
92bb25c0da9e When appending, delete temporary files at the end of the ghostscript pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 11009
diff changeset
180 endif
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
181 endif
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
182 if (! isempty (offsetfile) && format_for_printer)
27622
df8942d19b7b Allow printing with Octave installed in path with parenthesis (bug #49718)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27069
diff changeset
183 cmd = sprintf ('%s "%s"', cmd, offsetfile);
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
184 endif
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
185 if (! isempty (opts.source))
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
186 cmd = sprintf ("%s %s", cmd, opts.source);
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
187 endif
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
188
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
189 if (opts.debug)
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
190 fprintf ("Ghostscript command: '%s'\n", cmd);
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
191 endif
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
192
11009
064aaf82222f Print via a pipeline.
Ben Abbott <bpabbott@mac.com>
parents: 10954
diff changeset
193 gs_cmd = cmd;
10834
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
194
05ba991794d4 Improvements for fltk printing.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
195 endfunction