27
$\begingroup$

When I used Mathematica under Windows, I could control the page size of the pdf files created by Export[...,"PDF"] by setting the paper size in the print menu to the desired size before executing the Export command. In particular, I would set the paper size to Ledger, and when I opened the resulting files in Acrobat the page size would be listed as 10.83 x 16.83 in.

Now, I'm using Mathematica under Mac OS X, and this trick doesn't work. Is there some option for Export[...,"PDF"] that allows me to control the PDF page size of the output directly?

Update

The item I'm exporting is of the form CreateDocument[{item1,item2}], where item2 is a GraphicsGrid that contains ImageSize information. Unfortunately, when that information gets wrapped inside CreateDocument, Export[...,"PDF"] seems to ignore it when setting the PDF page size.

$\endgroup$
4
  • $\begingroup$ Without much time to test, I've added another suggestion in response to your update. $\endgroup$
    – Jens
    May 23, 2012 at 6:50
  • $\begingroup$ The "trick" you describe works correctly for me. If I adjust the paper size in the Page Setup dialog on Mac then I export the notebook the size I get is the size I specified in the dialog. Note that this appears to be a per-notebook setting, so if you didn't explicitly set it for the notebook you exported you may not get the intended size. $\endgroup$
    – ragfield
    May 23, 2012 at 15:33
  • $\begingroup$ I'm programmatically creating ~100 notebooks and exporting them immediately with a command of the form Export[filename,CreateDocument[...],"PDF"], so I can't really go to the Page Setup dialog for each individual notebook. Under Windows, setting the paper size once for the parent notebook sets the page size of the PDF exports of the notebooks it spawns. It doesn't work that way for me under Mac OS X (v. 10.7.4; MMA v. 8.0.1.0). $\endgroup$ May 23, 2012 at 18:57
  • $\begingroup$ I can set the "PageSize" and/or "PaperSize" of a notebook I'm creating with a command like Export[filename, CreateDocument[{...}, PrintingOptions -> {"PaperSize" -> {11*72, 17*72}, "PageSize" -> {11*72, 17*72}}]] and the Option Inspector does indicate that these options are set, but they don't affect the page size of the exported PDF. $\endgroup$ May 23, 2012 at 19:45

1 Answer 1

14
$\begingroup$

One possible solution is to do as I suggested in this MathGroup post (see also the follow-ups). I think one can simplify it by doing the following:

g = Graphics[{Inset[
   Plot[10^5 x^2, {x, -2, 2}, Frame -> True, Axes -> None], 
   ImageScaled[{0, 0}], ImageScaled[{0, 0}], ImageScaled[1]]}, 
 ImageSize -> {400, 400}, PlotRange -> {{0, 1}, {0, 1}}]

Export["g.pdf", g]

The ImageSize setting here is in points. You have to multiply the desired inches by 72 to get the length in points.

You may also find this cropping function useful.

Update

In response to the updated question, one could try to set the following option in the Advanced tab of the Preferences:

screenshot

Here I have changed "PageWidth" under ExportMultipleCellsOptions from the original Infinity to PaperWidth.

$\endgroup$
2
  • $\begingroup$ Do you mind commenting where the "PageWidth" values comes from? I tried setting both PaperSize and PageSize of the current Notebook, but neither seem to effect the output of the exported pdf? $\endgroup$
    – William
    Dec 21, 2013 at 19:26
  • $\begingroup$ One danger with this is that the PaperWidth value can cause odd bugs with copy-and-paste of chunks of text. $\endgroup$
    – b3m2a1
    Dec 2, 2018 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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