6
$\begingroup$

This question is regarding interoperability between Adobe Illustrator and Mathematica.

Illustrator has a File → Place... function which can insert complete figures inside Illustrator documents. "Placing" has some advantages when assembling several Mathematica-exported figures:

  • Illustrator keeps a link to the source file that was placed. When the source file changes, it automatically updates the document. This lets me quickly re-generate part of the figure with Mathematica based on modified data, and the result automatically appears in the Illustrator document.

  • Illustrator has problems with fonts in Mathematica-exported PDFs. When files as "placed" instead of inlined, these problems don't come up.

The disadvantage of placing is that the figure is placed as a whole and cannot be edited (without inlining).

There appears to be a bug in Illustrator which causes problems with Mathematica-generated PDF files: if I place such a file in an Illustrator document, then export it to PDF again, the placed file simply doesn't show. Compare how the document shows in Illustrator (top) vs Preview.app (bottom):

enter image description here

This does not happen with most PDF files, but it does happen with all PDFs exported from Mathematica.

Is there a workaround that will let me keep working with placed figures in Illustrator while allowing me to export the result as PDF?

$\endgroup$
  • $\begingroup$ Let me know if you disagree that this is on-topic. The bug seems to be in Illustrator, not Mathematica, which might raise concerns about this. But it is Mathematica users who are the most affected by it, and the question is about a Mathematica-based workflow. $\endgroup$ – Szabolcs Jul 23 '15 at 9:38
1
$\begingroup$

It looks like setting Compatibility: Acrobat 4 (PDF 1.3) in the Save Adobe PDF dialog in Illustrator solves the issue (checked with Illustrator 17):

screenshot

In the resulting PDF file the transparency is flattened without rasterization (here "Untitled-1.pdf" is PDF file generated by Illustrator from blank document where the Exported file "pl.pdf" was Placed):

(* Generate and Export a graphics with transparency *)
pl = Graphics[{Opacity[0.5], Red, Disk[], Green, Disk[{1, 0}]}, Frame -> True]
Export["pl.pdf", pl];

(* Import and inspect the contents of the PDF file generated by Illustrator
   with Compatibility: Acrobat 4 (PDF 1.3) *)
Cases[Import["Untitled-1.pdf", "TextOutlines" -> False][[1]], 
 fc_FilledCurve :> Graphics[{fc}], Infinity, 3]

screenshot

$\endgroup$
  • $\begingroup$ Thank you. It works with Illustrator CC 2015. $\endgroup$ – Szabolcs Jul 24 '15 at 9:52
5
$\begingroup$

On OS X, a simple workaround is to re-save the Mathematica-exported PDF with Preview.app before placing it. Simply open it in Preview and press -S.

I did try processing the PDF through several other programs, but Preview was the only one that worked with all files I tried without destroying them. Some others worked only with PDFs containing no transparent elements.

The disadvantage of using Preview is that I'm not sure how to automate it. I would have preferred having a way to export usable PDFs from Mathematica directly (e.g. call some command line tool upon export which fixes them).

It would be nice to have an automatable, cross-platform workaround.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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