2

When I export a plot to a PDF with something like

Export["test.pdf", Plot[Sin[x], {x, 0, 2 Pi}], "PDF"]

I get a file in which the axes have been separated from the rest of the plot in some editors and viewers (e.g., OmniGraffle):

enter image description here

Why is this happening? Is there a way to prevent it?

kglr
  • 394,356
  • 18
  • 477
  • 896
orome
  • 12,819
  • 3
  • 52
  • 100
  • This is certainly platform related... Which Mathematica version and operating system are you using? (Well the OS one can guess... :) – sebhofer Jan 16 '13 at 21:34
  • Oh and another thing... have you tried opening the pdf in another viewer? A possible workaround could be to export to some other vector forma (svg, ps,...) and try to convert from there. Also, there are 2 other ways to export plots: 1) "Save Graphic As..." from the context menu and 2) "Save Selection As..." from "Edit". It's always a delight to see the different graphics these 3 methods produce! – sebhofer Jan 16 '13 at 21:36
  • Mathematica 9.0.0.0; OS 10.8.2. – orome Jan 16 '13 at 21:36
  • 1
    @sebhofer: In some viewers it looks fine. Exporting to SVG is not an option. The whole reason for exporting to PDF is actually that it's the only way to end up with a decent SVG. Mathematica's SVG export omits size and font information. – orome Jan 16 '13 at 21:39
  • Unfortunately the pdf export is pretty flawed too... – sebhofer Jan 16 '13 at 21:41
  • @sebhofer: Yes, the lesser of two evils; or at least the more easily repaired. – orome Jan 16 '13 at 21:42
  • If the PDF displays fine in Adobe Reader but not in the editor you use, then this is a problem with the graphics editor, not Mathematica's PDF export. These plots open fine in Illustrator. – Szabolcs Jan 16 '13 at 21:44
  • 2
    @Szabolcs I don't know... I would trust most pdf viewers more than Mathematica's pdf export. – sebhofer Jan 16 '13 at 21:46
  • @sebhofer: Agreed. Mathematica is the culprit here. I have no problem opening any other PDFs. – orome Jan 16 '13 at 21:49
  • @sebhofer The comparison here is between mainstream PDF viewers such as Adobe Reader, Preview, etc. and OmniGraffle (not M and OmniGraffle). If the former all display it differently than OmniGraffle, then there must be something wrong with OmniGraffle. – Szabolcs Jan 16 '13 at 21:50
  • @Szabolcs I don't mean to be nitpicking here, but not all viewers might be equally strict with the implementation of the pdf standard, so your conclusion might not be correct. However, it seems that Acrobat Reader is actually a reference implementation (at least up to pdf version 1.7). Nevertheless, I have seen Mathematica mess up the pdf export too many times, at least on Linux. So I'm really not surprised by the above picture. – sebhofer Jan 16 '13 at 21:57
  • 2
    Did you send the PDF to the Omnigroup? They're a pretty responsive bunch and I wouldn't be surprised if you get an answer. – Cassini Jan 16 '13 at 22:32
  • @DavidSkulsky: Good point. Will do. – orome Jan 16 '13 at 22:33
  • @sebhofer If that is the case (i.e. that some viewers automatically correct a broken PDF and some don't), perhaps re-saving the PDF (completely reprocessing it) will fix the problem. It's worth trying even if the PDF is not really broken. – Szabolcs Jan 16 '13 at 22:35
  • @Szabolcs Yup that is definitely worth a try! – sebhofer Jan 16 '13 at 22:45
  • 2
    I finally have time to look this up and post this. There's a very nice open source tool that can reprocess PDFs for you, but unfortunately it's a bit difficult to get the older version that still supports this functionality. Get Multivalent from here (not from the official site---latest version is no good), and follow the instructions here to reprocess the PDF. If you have Acrobat, it's simpler to try 'optimizing' the PDF using it first. – Szabolcs Jan 17 '13 at 02:23
  • Does this fix the problem? I do not have OmniGraffle to test. All four software I tried display the PDFs correctly (and all four use independent engines). – Szabolcs Jan 17 '13 at 02:24

1 Answers1

2

This looks like a bug in OmniGraffle, but you can avoid it (at least for display) by copy/pasting the PDF (from the Finder) rather than Opening it.

orome
  • 12,819
  • 3
  • 52
  • 100
cormullion
  • 24,243
  • 4
  • 64
  • 133
  • It looks to me like that just embeds a PDF as a single monolithic, uneatable object. – orome Jan 17 '13 at 14:15
  • 1
    Yes, that's true - it's uneditable (and uneatable, too)... I'll bet you an up/down vote it's an OmniGraffle bug though... :) – cormullion Jan 17 '13 at 15:03
  • I'd agree. This won't answer it for me though. I've got to open it in a different viewer, save it, and then open that in OmniGraffle, where I can edit it. I've sent the file to Omni. – orome Jan 17 '13 at 15:25
  • Can you start the answer with "This looks like a bug in OmniGraffle, but you can avoid it (at least for display) by...". Then I'll accept. – orome Jan 17 '13 at 21:50