How can I convert .eps to .pdf inside Mathematica (perhaps using GhostScript?)?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
After installing GhostScript and setting appropriate environment variables (for Windows you should add gs\bin and gs\lib to the PATH, where gs is the top-level Ghostscript directory) you can use for converting .eps to .pdf (all the glyphs will be outlined):
gsEPS2PDF[epsPath_String, pdfPath_String] := Run["gswin64c.exe -sDEVICE=pdfwrite -dNOCACHE -sOutputFile=\"" <> pdfPath <> "\" -q -dbatch -dNOPAUSE \"" <> epsPath <> "\" -c quit"] Here gswin64c.exe is the name of GhostScript executable for 64bit Windows systems, for Linux replace it with gs.
Another method based on Kurt Pfeifle' code (without font outlining):
gsEPS2PDFEmbedFonts[epsPath_String, pdfOutputPath_String] := Run["gswin64c.exe -sFONTPATH=c:/windows/fonts -o \"" <> pdfOutputPath <> "\" -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress \"" <> epsPath <> "\""] Here c:/windows/fonts is the directory where fonts are located. See also here for information about GhostScript command line parameters.
回答2:
gr = Import["file.eps", "eps"] Export["file.pdf", gr, "pdf"]