17 function
eps2pdf(source,dest,crop,append,gray,quality) {
18 options = [
" -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=' " dest
" ' "];
21 options = [options
" -dEPSCrop "];
26 options = [options
" -sFONTPATH=' " fp
" ' "];
30 options = [options
" -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray "];
33 if nargin > 5 && ~isempty(quality)
34 options = [options
" -dAutoFilterColorImages=false -dAutoFilterGrayImages=false "];
36 options = [options
" -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode -c '.setpdfwrite << /ColorImageDownsampleThreshold 10 /GrayImageDownsampleThreshold 10 >> setdistillerparams' "];
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);
46 if nargin > 3 && append && exist(dest,
" file ") == 2
50 copyfile(dest, tmp_nam);
52 options = [options
" -f ' " tmp_nam
" ' ' " source
" ' "];
66 options = [options
" -f ' " source
" ' "];
74 error(
" Unable to generate pdf. Check destination directory is writable. ");
99 fp = getenv(
" GS_FONTPATH ");
105 fp = [fp getenv(
" WINDIR ") filesep
" Fonts "];
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 "];
function string = user_string(string_name, string)
function fp = eps2pdf>font_path()
function varargout = ghostscript(cmd)
Initialize any required system calls before calling ghostscript.
function eps2pdf(source, dest, crop, append, gray, quality)
Intialise the options string for ghostscript.