1

I have several thousand d3 charts and my client wants to print them for a report. The client needs them in EPS. I have bought Illustrator to convert them but when I open the SVG file the formatting has disappeared. This holds even when I put the CSS into the html page itself and not externally. Is there any way I can turn CSS + SVG into an EPS?

halfer
  • 19,824
  • 17
  • 99
  • 186
emma
  • 784
  • 2
  • 9
  • 23
  • Have you tried putting the CSS inside the `` node itself and saving it? Something like [this](http://imgur.com/3S8Y7kD) maybe – zgood Jan 21 '16 at 15:02

1 Answers1

1

I just tried this approach in my illustrator and it does honor the CSS declarations inside the <svg /> element.

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width=".." height=".." viewBox="..">
 <style type="text/css">
     <![CDATA[
        polygon{
            fill:none;
        }
        #myPath{
          /*styles here*/
        }
     ]]>
 </style>
  <!-- SVG content -->
</svg>

I was then able to save my SVG as an EPS with the CSS styles applied.

zgood
  • 12,181
  • 2
  • 25
  • 26
  • This sounds extremely helpful!! I've just been googling and wonder if you know: how do you add this CDATA – emma Jan 21 '16 at 16:26
  • I would just open the SVG file (ex: `chart.svg`, or whatever file you adding using JS) in a text editor and just manually create this style section, then copy and paste your styles in it then save the SVG file and open it in Illustrator and save as EPS. Does that make sense? – zgood Jan 21 '16 at 16:35
  • Yes it makes sense but I have 20 nearly identical documents using the same CSS so was hoping to be able to maintain it dynamically. Doesn't matter - just got the illustrator import of svg to work. Thank you so much!! – emma Jan 21 '16 at 17:22
  • 1
    If you have to apply the same styles to thousands of SVG's you would need some server-side language like php or c# to save all the SVGs as EPS files to disk. JS can't interact with the filesystem (_meaning you can't create, update or delete files_). There are programs like [InkScape](https://inkscape.org/en/) (_free_) which you can call via the command line that might help. – zgood Jan 22 '16 at 01:06