0

I have been trying to convert a pdf vector graphic to eps. I tried two commands from the following answer: https://stackoverflow.com/a/44737018/5661667

The inkscape command inkscape input.pdf --export-eps=output.eps or rather, since --export-eps is deprecated now,

inkscape input.pdf --export-filename=output.eps

nicely converts to a vectorized eps. However, it strangely converts my Times New Roman fonts (the graphic was originally created using matplotlib) to some sans serif font (looks like Arial or something).

The ghostscript version of the conversion from the linked answer

gs -q -dNOCACHE -dNOPAUSE -dBATCH -dSAFER -sDEVICE=eps2write -sOutputFile=output.eps input.pdf

keeps my fonts nicely. However, the eps seems to be rasterized despite the -dNOCACHE option.

Is there any way to get one of these to just convert my pdf to eps without modifying it?

Further info: I am using Mac OS. For the first part, my suspicion is that I only have an Arial Unicode.tff installed in /Library/Fonts/. I tried installing some other fonts, but no success for my conversion.

Wolpertinger
  • 1,169
  • 2
  • 13
  • 30
  • -dNOCACHE has nothing to do with rasterisation; it's a debugging flag which has been (ab)used to prevent fonts being emitted in the output, and having them turn into paths instead. There can be multiple reasons why the EPS is rasterised, the most likely being the presence of transparency in the original PDF file. Without seeing the PDF file I can't tell why it has been done (if it has). Your PDF 'probably' doesn't embed the Times New Roman fonts that it uses, and so the EPS won't contain them either so when you render the EPS you will get the default font, usually Courier or Helvetica. – KenS Jul 14 '22 at 13:35
  • @KenS interesting. I was just referring to the comment in the linked answer "Note: -dNOCACHE is needed to prevent GhostScript from rastering the fonts.". From that I expected that at least the fonts would not be rasterized, but they are. Also since inkscape seems to be able to give a vector output for this particular pdf, such that I don't understand why GhostScript shouldn't be able to. Could I tell it to ignore transparency if that can be an issue? – Wolpertinger Jul 14 '22 at 14:25
  • Yes you can use -dNOTRANSPARENCY, but there can be other reasons. (e)ps2write only supports level 2 PostScript output which means it does not support CIDFonts, shading patterns and a number of other features. The presence of those will cause at least some of the output to degenerate to images. I don't wish to denigrate inkscape, and it is possible it is doing a better job than ps2write, but it is also possible that it is missing (for example) the presence of transparency and outputting something which is (at least technically) incorrect. Again I'd need to see the PDF file to have any clues. – KenS Jul 14 '22 at 15:57
  • 1
    As for the comment about -dNOCACHE, well I wouldn't trust everything you read in Stack Overflow ;-) – KenS Jul 14 '22 at 15:58
  • @KenS thanks a lot for the -dNOTRANSPARENCY hint! I tried that and it indeed gives a vectorized image then :) The only problem is that the colors are different then. You wouldn't happen to know if there is a simple way to translate colors with transparency into normal colors with GhostScript? That's the part Inkscape seems to manage. – Wolpertinger Jul 15 '22 at 11:53
  • You simply can't do that, sorry. Transparency in PDF is not at all simple, and the only way to get the correct output is to actually render it. I've no idea what Inkscape is doing, possibly it is decomposing the filled areas by calculating the intersection of all the objects in a transparency stack and working out the final colour, then filling the area of the intersection with that colour, repeat for every object on the page.... Or something similar. There's no realistic way to do that with Ghostscript. – KenS Jul 15 '22 at 12:23
  • @KenS I see... thanks a lot for your help! I guess I'll have to teach Inkscape Times New Roman then ;) – Wolpertinger Jul 18 '22 at 10:26
  • @KenS I have voted to close my question, since it is not specific enough. If you have the time, here is a follow-up question with a concrete pdf example generated by Matplotlib: https://stackoverflow.com/questions/73022163/inkscape-pdf-to-eps-conversion-with-matplotlib-generated-font – Wolpertinger Jul 18 '22 at 12:15
  • I don't see the PDF file on that question (I may be missing it of course). I'm afraid I can't use Matplotlib to generate it :-( – KenS Jul 18 '22 at 14:49
  • @KenS apologies, since stackoverflow doesn't allow pdf upload, this was the easiest solution. There is a solution at the other question now which works for me. In case you're interested, I also found out what Inkscape does: It rasterizes only the part of the pdf which contains the transparency. With Ghostscript, everything is rasterized. – Wolpertinger Jul 19 '22 at 09:40
  • Yes, there's no way for the eps2write device to do otherwise. Interesting to note that Inkscape still rasterises the transparency of course. – KenS Jul 19 '22 at 10:14
  • @KenS thanks for your help again! I will close this question as a duplicate as soon as I can. – Wolpertinger Jul 19 '22 at 10:27

1 Answers1

0

I had the same problem when trying to convert a powerpoint generated pdf to eps format using inkscape.

After trying with gs and disabling the transparency I noticed some areas turned black after eps conversion.

gs -q -dNOCACHE -dNOPAUSE -dBATCH -dSAFER -dNOTRANSPARENCY -sDEVICE=eps2write -sOutputFile=output.eps input.pdf

Coming back to inkscape I noticed that Powerpoint added some transparent objects in these areas that turned black. So I manually removed them using inkscape and when converting to eps again the result was perfect!

In short: if there are transparent elements in your pdf, the fonts will probably be rasterized during eps conversion. So, you need to remove these elements.

Maybe there is an easier way to identify them in inkscape. In my case I was able to use Find/Replace (Ctrl+F) to search objects with string "clipPath" and with 'Search option = Properties'. Then I open the Objects Tab (Menu Object->Objects...) and use that to delete each transparent object generated by Powerpoint.

Luciano Ribas
  • 309
  • 2
  • 4