10

Is it possible to convert a PostScript file to SVG?

Based on an answer in Tex.SE, I tried to use inkscape:

inkscape test.ps --export-inkscape-svg=test.svg

This indeed produced an SVG file, but changed the font and removed the spacing between letters. As a minimal working example, I created a PostScript file that includes text only (although my original files contains both text and graphics). The following image shows the PostScript file (top) and the resulting SVG file (bottom):

enter image description here

What is the correct way to convert PS to SVG?

1
  • 2
    As you see: Inskscape should be a way to do it. The fact it is failing means there is a defect in the program. So, apart of any other sugestions here, it would be nice if ou reported the problem you had to Inkscape developers - can you do that? The address is: bugs.launchpad.net/inkscape . When you do so, attach a postscript file which triggers the problem, like the one you used to the screenshot here. Free software like Inscape sometimes have no paid-for, fultime developers, and they depend on the user base to contribute to issues like finding and reporting problems.
    – jsbueno
    Commented Feb 10, 2014 at 12:10

3 Answers 3

6

Sorry - this will not answer your question: "What is the correct way to convert PS to SVG? "

There is no "correct way". There are "possible ways". It is a too complicated World this one.

as I mentioned in the comment, I'd try using Inkscape myself. You did hit a problem in the program - let me ask you: do your PS file renders properly in other places, besides where you create it? Can you attach the minimalist file to the question?

Now, another way to try: ghostscript is a powerfull postscript which has a "ps-to-ps" mode which simplifies Postscritp files, in order to get them more "simple" for other programs. If you don't have it already, I suggest you get it.

It can output SVG - but you will know if your file renders properly inside it (with spacing and font), and second, you can use Ghostscript's "ps2ps" mode to create a secondary postscript file you can try importing into inkscape. This has a chance to succeed, since it should handle less used, or non-standard, text options that Inkscape is failing to grasp.

Ghostscript itself might be quite "rough" to use - it is a developer's tool, not a designer's one (it is even used directly as Printer driver for some Operating Systems) , so you might need to dig a little bit into its documentation (or ask again) to get the postscript-to-postscript part working. Getting the "gsview" companion program, which gives Postscript a Window of sorts might help as well.

1
  • How about using the "-dNoOutputFonts" option in PostScript? It would outline all text, and hence circumvent the problem in Inkscape. Downside: it would make the resulting SVG less editable/maintanable/human-readable.
    – Ideogram
    Commented Oct 30, 2020 at 8:30
2

I would recommend opening the PostScript file in Adobe Illustrator, which laps up EPS files like mother's milk and has an SVG export function.

1. Import the element(s) or open them directly (EPS)
2. Remember to select the option "show transparency Grid" under VIEW if you want transparent background.
3. Save As - Choose SVG

I would assume you are using the SVG for the web - keep the file gamut/color settings in RGB and set the resolution of the document to screen rather than print resolutions in Raster Settings (In Effects)

The fact that these settings are in just about every corner of the app is part of what makes Adobe so absurd.

2

With help of pstoedit:

barcode -e ean -b 4003994155486 | pstoedit -q -f fig | fig2dev -L svg

In this example barcode outputs PostScript. Then pstoedit takes it and quetly (-q) converts into fig code, which is then converted into SVG by fig2dev.

When using Inkscape you would have to pass files around because Inkscape relies in the input filename in format detection:

barcode -e ean -b 4003994155486 > example.eps
inkscape -z example.eps --export-plain-svg /dev/stdout
3
  • Can you expand a bit to explain what is this tool? at least what are these options?
    – Luciano
    Commented Oct 25, 2017 at 12:24
  • @Luciano done that
    – sanmai
    Commented Oct 26, 2017 at 3:07
  • In linux, you can use the man program to read the manuals. this will tell you all the functionality of pstoedit, and fig2dev. I dont have barcode installed but I assume it would work the same way. you could type in the terminal: man fig2dev this will tell you all about fig2dev and its options. In my case I did not use the barcode utility, but used a ps file I had already created. I did the conversion and output with this command: pstoedit -q -f fig sqrsDup.ps | fig2dev -L svg > test.svg sqrsDup.ps being the file I had already created, and test.svg being the file output.
    – j0h
    Commented Feb 26, 2020 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.