How can I convert .eps file to .pdf in Mathematica?

£可爱£侵袭症+ 提交于 2020-01-13 06:14:06

问题


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 Jens Nöckel's method 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"]


来源:https://stackoverflow.com/questions/18647607/how-can-i-convert-eps-file-to-pdf-in-mathematica

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!