11
$\begingroup$

I am wondering if there is any possible solution to exporting equations from Mathematica to Corel. I was trying first to export an equation as pdf from Mathematica and then to import .pdf to Corel, but many characters are missed. Maybe someone had success with this kind of problem.

$\endgroup$
1
  • $\begingroup$ Does it work if you use the function in this answer? Just say outlinedExport["output.pdf", g, ImageSize -> 600] or something similar. $\endgroup$
    – Jens
    Commented Jun 3, 2013 at 3:58

1 Answer 1

10
$\begingroup$

There is a similar problem with Adobe Illustrator, too. For that purpose, I use the following function (see my web site for more info):

toPDF[x_, opts : OptionsPattern[]] := 
  If[! ImageQ[x], 
   First@ImportString[
     ExportString[
      Pane[Style[TraditionalForm[HoldForm[x]], 
        FilterRules[{opts}, Options[Style]]], 
       FilterRules[{opts}, ImageSize], 
       BaseStyle -> {FontFamily -> "Times New Roman", 
         Background -> (Background /. {opts} /. {Background -> 
              None})}], "PDF"], "PDF", "TextMode" -> "Outlines"]];
SetAttributes[toPDF, HoldFirst]

Example:

toPDF[Integrate[1 + Sin[x]^2, {x, 0, Pi}], FontSize -> 18]

screenshot

Now you can either highlight the result (as I did above) and copy it as PDF (on Mac), or type Export["eq.pdf", %] in the next cell, to save to a file.

The reason I added the attribute HoldAll above is that I wanted to be able to export expressions like integrals without having them be evaluated. So the purpose of this function is really geared toward typesetting equations, and then copying them to Illustrator. Maybe this is also what you want for your drawing application.

I use Pane as a wrapper for the equation in order to be able to control the bounding box of the PDF. The function also accepts a Background option in case you want to add a color behind the equation.

Edit for version 10.1:

Due to added bugs in Import with PDF format, the example above won't work properly anymore. Another solution that still does work is the function gsExport from my answer here. You have to make sure that ghostscript is installed and in the search path. If the linked code doesn't find your gs command, you could add the path directly in the code, as in /path/to/gs. After invoking gsExport["filename.pdf", HoldForm[Integrate[1 + Sin[x]^2, {x, 0, Pi}]]], you can do Import["filename.pdf"].

$\endgroup$
5
  • $\begingroup$ Thank you very much Jens. This I was trying to get. Quality of image-equation is very nice in corel. Thank you Jens a lot, hope that your "papers" look perfect. $\endgroup$
    – Pipe
    Commented Jun 3, 2013 at 11:16
  • 1
    $\begingroup$ Same problem with BoundaryDiscretizeGraphics in v10.2. $\endgroup$
    – Szabolcs
    Commented Jul 24, 2015 at 17:41
  • $\begingroup$ Since v9.16, you can use the following with GhostScript: gs -o out.pdf -dNoOutputFonts -sDEVICE-pdfwrite in.pdf. This won't involve any conversions to EPS. It goes directly from PDF to PDF. $\endgroup$
    – Szabolcs
    Commented Jul 24, 2015 at 17:43
  • $\begingroup$ @Szabolcs Great, thanks, I'll add that to my linked answer! (I checked that the old syntax also still works in 9.16, though). I'll also have to file another bug report for the Import issue, I guess. Although I believe I reported stuff like that a couple of times already. New issues keep popping up... $\endgroup$
    – Jens
    Commented Jul 24, 2015 at 17:49
  • $\begingroup$ @Szabolcs Reported the Import bug to Wolfram [CASE:3391590]. $\endgroup$
    – Jens
    Commented Jul 24, 2015 at 18:16

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.