# Exporting PDF with large PaperSize

Bug present in 10.2 and fixed in 11.2
Exporting to eps still produces a crash, but that is another bug.

Suppose I create a new Notebook:

nb = CreateDocument[{TextCell["PDF Test", "Section"],
Table[PieChart@Range@5, {7}]}];


And set a big paper size so that all my charts fit in a single line:

SetOptions[nb, PrintingOptions -> {"PaperSize" -> 72 {18, 12}}];
SetOptions[nb, ScreenStyleEnvironment -> "Printout"];


An then I want to export this as PDF. So I issue this command:

Export["test6.pdf", nb]


The result is that my notebook becomes:

and the generated PDF looks like this:

And the "PaperSize" property is reverted to its default value

Options[nb, PrintingOptions]

{PrintingOptions -> {"EmbedExternalFonts" -> True,
"EmbedStandardPostScriptFonts" -> True, "FacingPages" -> True,
"FirstPageFace" -> Right, "FirstPageFooter" -> True,
"GraphicsPrintingFormat" -> "Automatic",
"IncludePostScriptResourceDirectives" -> True,
"IncludeSpecialFonts" -> True,
"InnerOuterMargins" -> {Automatic, Automatic},
"Magnification" -> 1., "OpacityRenderingMethod" -> Automatic,
"PageFooterMargins" -> {Automatic, Automatic},
"PageSize" -> {Automatic, Automatic},
"PaperOrientation" -> "Portrait",
"PaperSize" -> {612, 792},
"PostScriptOutputFile" -> Automatic, "PrintCellBrackets" -> False,
"PrintMultipleHorizontalPages" -> False,
"PrintRegistrationMarks" -> False,
"PrintSelectionHighlighting" -> False,
"PrintingMargins" -> {{54, 54}, {72, 72}},
"RasterizationResolution" -> "Automatic",
"RestPagesFooter" -> True, "RestPagesHeader" -> True,
"UnixShellPrintingCommand" -> Automatic,
"UsePostScriptOutputFile" -> False,
"UseUnixShellPrintingCommand" -> False,
"VertexColorRenderingMethod" -> Automatic}}


If I reset the PaperSize and use the File->Save As.. and used the PDF format, exactly the same happens. If one again I reset the PaperSize and print a PDF file using my new Adobe Acrobat licence, exactly the same happens (but it is slower).

So my question is: How can I get a PDF will all these charts in one row without changing their ImageSize? Is this a bug? Isn't the "Printout" screen environment supposed to match the PDF printout of a notebook? Why is the PaperSize notebook property changed when you Export or print a PDF? Can it be prevented?

I am using Mathematica 10.2 under Windows 7.

• it works if you export to .tiff. Perhaps you can find some intermediate format that works and use an external converter. (.eps crashed on me by the way ) – george2079 Oct 1 '15 at 16:02
• .eps crashed on me too. In my real application the notebook is several pages long, so I don't think that .tiff is an option. Maybe .rtf – Gustavo Delfino Oct 1 '15 at 17:23

You need to set the page size as well as the paper size. I can only test this in V10.1 but it works:

nb = CreateDocument[{TextCell["PDF Test", "Section"],Table[PieChart@Range@5, {7}]}];
SetOptions[nb, PrintingOptions -> {"PaperOrientation"->"Landscape","PageSize" -> {1296, 864},
"PaperSize" -> {1296, 864}}];
SetOptions[nb, ScreenStyleEnvironment -> "Printout"];


As an FYI if you set the toolbar to display the ruler you will see why setting the page size is required.

• Unfortunately with version 10.2 this does not work: after Export["test6.pdf", nb] I obtain a PDF file which looks like this: i.stack.imgur.com/DuoyS.jpg – Alexey Popkov Oct 2 '15 at 7:29
• It did not work on my Win7 Mathematica 10.2, and I got a different result than Alexey Popkov: i.stack.imgur.com/KZ9f0.png – Gustavo Delfino Oct 2 '15 at 13:40
• @GustavoDelfino you are using landscape dimensions but a portrait orientation. Try it again using Landscape. You may need to tweek the margins. – Mike Honeychurch Oct 2 '15 at 23:35

If you highlight all the brackets on the right side of what you want, and then do File->Save Selection As you should get this.

nb = CreateDocument[{TextCell["PDF Test",
"Section"], {Table[PieChart@Range@5, {7}]} // TableForm}];


I transposed the list so it reads left to right and put it in table form to get rid of the brackets.

nb = CreateDocument[{TextCell["PDF Test",
"Section"], {Table[PieChart@Range@5, {7}]} // TableForm}];


I'm not sure if I had to do this or not, but I made the mathematica window really large and stretched it off my screen so there was plenty of white space to the right of the image before selecting and saving. I think it might matter because my earlier saves still had brackets showing on the right side of the image.

EDIT: Just to be as clear as possible, this is what I meant by "highlight all the brackets."

Mathematica 10.0.0 Mac

With some modifications.

nb = CreateDocument[
Column[{TextCell["PDF Test", "Section"],
GraphicsRow[Table[PieChart@Range@5, {7}], ImageSize -> 700]}]];

• Thanks, but this is a trick to reduce the content so that it fits in a letter sized paper. When you open the generated PDF and open the properties windows, you can see that the size is reported as 8.5x11" and not the specified PaperSize. – Gustavo Delfino Oct 1 '15 at 18:01