Message Boards Message Boards

Export 2D graph without losing text information?

Posted 9 years ago

I am new to mathematica, and using 10.3. I have an issue with the export file as SVG. as in matlab it export axis labeling as text which are easily detected by inkscape for pdf-tex mode. but here in matematica I find no font information after exporting as SVG. Can someone help me to sortout the problem of exporting SVG with FONT included as font rather than a graphic

POSTED BY: asimullah khan
2 Replies

The following workaround did. You could wrap it up in a script if it works for you:

plot1 = Plot[Sinc[x], {x, -10, 10}, 
  BaseStyle -> {FontSize -> 18, FontFamily -> "Courier"}, 
  ImageSize -> 450, Frame -> True, Axes -> False]
Export["plot1.pdf", plot1]
Export["plot1.svg", plot1, "SVG"]

enter image description here

As you know, the svg file renders the text perfectly, but only as a path, not as editable text. The pdf, however, does keep the font information. But when you try to import the pdf into inkscape, you now have editable text, but it is all rendered in the Cairo font. Very frustrating!

So I use the command-line version of inkscape to convert the pdf to an svg, then use sed to do a search and replace to fix the font.

inkscape -D -z --file=plot1.pdf --export-plain-svg=plot1b.svg
sed -i 's/CairoFont-0/Courier/g' plot1b.svg
sed -i 's/CairoFont-1/Courier/g' plot1b.svg

And as you can see in the screenshot below, I now have an svg with editable text in the desired font:

enter image description here

POSTED BY: Jason Biggs
Posted 9 years ago

I used the following code to export as PDF-latex, as in pdf it export the ext as font rather than string and than usign commandline excess to external program like inkscape i converted it into two files pdf and latex textfiles with text only

str=NotebookDirectory[];

Export[str <> ".pdf", file, "PDF"];

Run [inkscape, "-D -z --file=" str <> ".pdf --export-pdf=" <> str <> ".pdf --export-latex"];

POSTED BY: asimullah khan
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract