How to export graphics in "Working" style environment rather than "Printout"?
Asked Answered
D

1

14

I have learned recently that Export in Mathematica uses by default the "Printout" screen style environment rather than "Working" when exporting to PDF. It sometimes results in FontSize fluctuations in the resulting PDF which are very annoying.

Try for example:

Show[First@ImportString[ExportString[Style[T, 100], "PDF"], "PDF"], 
 Prolog -> Inset[Style[T, 100], FormatType -> StandardForm]]
Show[First@ImportString[ExportString[Style[T, 100], "PDF"], "PDF"], 
 Prolog -> 
  Inset[Style[T, 100, Magnification -> .8], 
   FormatType -> StandardForm]]

screenshot

You can see that the exported "T" has 80% of the size of "T" that appears in the notebook. This is how the "Printout" environment is tuned on by default.

Is there a way to force Export use the default "Working" environment?

P.S. For some reason setting a private stylesheet with Magnification->1 for the "Printout" environment does not affect Export.

Dietsche answered 23/5, 2011 at 6:25 Comment(9)
I cannot remember, what version are you using? I had to change Prolog to Epilog for your example to work in version 7.Raskind
@Raskind I use v.7.0.1 under Windows 2000. On my machine Prolog and Epilog give visually identical results in this case as they should.Dietsche
Strange, when using Prolog I see only one T; the Inset does not appear at all, as though it is occluded by an opaque layer.Raskind
@Alexey, It's worth mentioning that this does not seem to affect Graphics. Try e.g. Show[First@ ImportString[ ExportString[ Graphics[Inset[Style[T, 100]], FormatType -> StandardForm], "PDF"], "PDF"], Epilog -> Inset[Style[T, 100], FormatType -> StandardForm]]Illuminative
@Alexey, It DOES however affect graphics when exporting is done from the UI (right click the graphics, and choose Save Graphic As ... PDF). In this case the size reduction is greater than 80% though. I got ~72% in one test.Illuminative
@Illuminative With your example Export gives a file with page size 4.17x4.17 inches, but saving to PDF gives a file with page size 3.33x3.33 inches (Mathematica 7.0.1 for Windows). 3.33/4.17=80%. In both cases the size of "T" relative to the page size is the same.Dietsche
@Illuminative After evaluating SetOptions[$FrontEnd, PrintingStyleEnvironment -> "Working"] and restarting the FrontEnd Export and Save Graphic As ... PDF give identically looking files with page size 5x5 inches. In both cases the size of "T" relative to the page size is the same but is less than by default (with PrintingStyleEnvironment -> "Printout").Dietsche
@Alexey, exactly. So it seems that the size is reduced if we export either 1. part of a notebook that is not a Graphics[] 2. use save as rather than the export command. Is this correct?Illuminative
@Illuminative At the moment it is - what we can say with certainty. But the real problem lies not in changing the scale, but in an inconsistent change the size of different fonts when exporting. I have repeatedly experienced this in real life situations, and this is a serious obstacle. Now, unfortunately, I have no opportunity to investigate this dark area closely. I just recently learned that the export to PDF uses a different set of styles than the default...Dietsche
R
13

The solution appears to be:

SetOptions[$FrontEnd, PrintingStyleEnvironment -> "Working"]
Raskind answered 23/5, 2011 at 6:50 Comment(2)
Thanks, It seems working. An alternative is to set this option for $FrontEndSession: SetOptions[$FrontEndSession, PrintingStyleEnvironment -> "Working"]. Interestingly, in this case this setting affects printing and saving to PDF only newly created notebooks but not the current notebook (but Export to PDF work as expected).Dietsche
@Alexey, thanks for the check mark, and the interesting observation.Raskind

© 2022 - 2024 — McMap. All rights reserved.