KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
eps2pdf.m
Go to the documentation of this file.
1 
2 
3 /* (Autoinserted by mtoc++)
4  * This source code has been filtered by the mtoc++ executable,
5  * which generates code that can be processed by the doxygen documentation tool.
6  *
7  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
8  * Except for the comments, the function bodies of your M-file functions are untouched.
9  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
10  * attached source files that are highly readable by humans.
11  *
12  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
13  * the correct locations in the source code browser.
14  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
15  */
16 
17 function eps2pdf(source,dest,crop,append,gray,quality) {
18 options = [" -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=' " dest " ' "];
19 /* Set crop option */
20 if nargin < 3 || crop
21  options = [options " -dEPSCrop "];
22 end
23 /* Set the font path */
24 fp = font_path();
25 if ~isempty(fp)
26  options = [options " -sFONTPATH=' " fp " ' "];
27 end
28 /* Set the grayscale option */
29 if nargin > 4 && gray
30  options = [options " -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray "];
31 end
32 /* Set the bitmap quality */
33 if nargin > 5 && ~isempty(quality)
34  options = [options " -dAutoFilterColorImages=false -dAutoFilterGrayImages=false "];
35  if quality > 100
36  options = [options " -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode -c '.setpdfwrite << /ColorImageDownsampleThreshold 10 /GrayImageDownsampleThreshold 10 >> setdistillerparams' "];
37  else
38  options = [options " -dColorImageFilter=/DCTEncode -dGrayImageFilter=/DCTEncode "];
39  v = 1 + (quality < 80);
40  quality = 1 - quality / 100;
41  s = sprintf(" << /QFactor %.2f /Blend 1 /HSample [%d 1 1 %d] /VSample [%d 1 1 %d] >> ", quality, v, v, v, v);
42  options = sprintf(" %s -c '.setpdfwrite << /ColorImageDict %s /GrayImageDict %s >> setdistillerparams' ", options, s, s);
43  end
44 end
45 /* Check if the output file exists */
46 if nargin > 3 && append && exist(dest, " file ") == 2
47  /* File exists - append current figure to the end */
48  tmp_nam = tempname;
49  /* Copy the file */
50  copyfile(dest, tmp_nam);
51  /* Add the output file names */
52  options = [options " -f ' " tmp_nam " ' ' " source " ' "];
53  try
54  /* Convert to pdf using ghostscript */
55  [status message] = ghostscript(options);
56  catch
57  /* Delete the intermediate file */
58  delete(tmp_nam);
59  rethrow(lasterror);
60  end
61  /* Delete the intermediate file */
62  delete(tmp_nam);
63 else
64  /* File doesn't exist or should be over-written
65  * Add the output file names */
66  options = [options " -f ' " source " ' "];
67  /* Convert to pdf using ghostscript */
68  [status message] = ghostscript(options);
69 end
70 /* Check for error */
71 if status
72  /* Report error */
73  if isempty(message)
74  error(" Unable to generate pdf. Check destination directory is writable. ");
75  else
76  error(message);
77  end
78 end
79 return
80 
81 /* Function to return (and create, where necessary) the font path */
82 }
92 function fp = eps2pdf>font_path() {
93 fp = user_string(" gs_font_path ");
94 if ~isempty(fp)
95  return
96 end
97 /* Create the path
98  * Start with the default path */
99 fp = getenv(" GS_FONTPATH ");
100 /* Add on the typical directories for a given OS */
101 if ispc
102  if ~isempty(fp)
103  fp = [fp " ; "];
104  end
105  fp = [fp getenv(" WINDIR ") filesep " Fonts "];
106 else
107  if ~isempty(fp)
108  fp = [fp " : "];
109  end
110  fp = [fp " /usr/share/fonts:/usr/local/share/fonts:/usr/share/fonts/X11:/usr/local/share/fonts/X11:/usr/share/fonts/truetype:/usr/local/share/fonts/truetype "];
111 end
112 user_string(" gs_font_path ", fp);
113 return
114 
115 }
116 
function string = user_string(string_name, string)
Definition: user_string.m:17
function fp = eps2pdf>font_path()
Definition: eps2pdf.m:92
function varargout = ghostscript(cmd)
Initialize any required system calls before calling ghostscript.
Definition: ghostscript.m:17
function eps2pdf(source, dest, crop, append, gray, quality)
Intialise the options string for ghostscript.
Definition: eps2pdf.m:17