Message Boards Message Boards


Export Graphics3D images to PDF preserving a good resolution?

Posted 10 months ago
11 Replies
17 Total Likes

Let's create image

g = Graphics3D[{Line[{{-2, 0, 2}, {2, 0, 2}, {0, 0, 4}, {-2, 0, 2}}]}]

and then export it by Export["test.pdf", g]. It leads to a very unsatisfactory result snapshot of resulting image in PDF

Option AllowRasterization" -> False does not help. How do I get PDF or EPS file of this image in the vector format?

11 Replies

As a hack you can turn it into a 2D Graphics object, and export that:

g = Graphics3D[{Line[{{-2, 0, 2}, {2, 0, 2}, {0, 0, 4}, {-2, 0, 2}}]}]
Export["out.pdf", Graphics[Inset[g, Automatic, Automatic, Scaled[1]]]]

Works on MacOSX with Mathematica 11.3

Posted 10 months ago

Thank you very much! Your hack works incredibly well. Of course, the file might be huge, but it is worth to some extent.

This looks like a possible bug or perhaps an undocumented limitation. I've just tried a simple example which suggests that the Export function option AllowRasterization" -> False has the expected effect if you export 2D graphics, but appears to have no effect when used to export a Graphics3D expression.

You could use the ImageResolution option with a high DPI value (say ImageResolution->1200). This improves the resolution of the exported graphic, but it remains a raster image.

Maybe it's one for Technical Support?

Hope this helps,


You can try exporting with ImageResolution -> Infinity. It has worked for me well enough.

Posted 10 months ago

Thanks a lot. It also works, but result of Plot3D is different from what I've gotten after turning it into a 2D Graphics object (suggested above by Sander Huisman). With ImageResolution -> Infinity I see a mesh. See the difference enter image description here enter image description here

The Inset trick gives a much better shading than with ImageResolution->Infinity , at the expense of a much larger file size, at least in the example that I tried.

I wonder whether the problem might lie with PDF? I don't know enough about PDF to say for sure, but if it doesn't understand 3D vector graphics then the above Export function is never going to work as intended and the vector graphics will have to be rasterised. Just a thought. Maybe someone who knows more about PDF can confirm.

All the best,


Posted 10 months ago

Image exported in EPS is also raster.

It is documented that PDF only supports 2D graphics so I would use either a high resolution or Sander's conversion to 2D graphics:

from the PDF Export Documentation it says:

Stores text, fonts, images, and 2D vector graphics in a device- and resolution-independent way.

Also, I found in the past that the export resolution depends on the original size of the graphic and that ImageResolution->Infinity undoes this. so I would fix the original size and then rasterize it with:

g = Graphics3D[{Line[{{-2, 0, 2}, {2, 0, 2}, {0, 0, 4}, {-2, 0, 2}}]}, ImageSize -> Large]
Export["out5.pdf", g, ImageResolution -> 1200]

You can move the 1200 up or down to suit your needs/ file size.



Well spotted Neil - I missed that nugget!

If you need to export 3D graphics objects in vector form, you could try using Autodesk's DXF format as per the attached notebook. This works. Although I notice that when I re-import the exported graphic back into Mathematica its attributes and display options such as axes are lost in the process (I think at the export stage).

You can also view, export and print the exported DXF file using one of several free viewers. I use Autocad's "DWG TrueView" which I find works well in most cases.

All the best,


Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract