# Export all open notebooks and change font size

Is there a simple way to export all open notebooks to pdfs? Also, when I export notebooks the font looks too big / the margins are too big. Can I change these settings when exporting?

-

This could be a basic code for this:

(* SetDirectory[] ??? Here you could set a directory to write the files... *)
Do[
name=Check[NotebookFileName[nb], "NotSaved.nb", NotebookFileName::nosv];
(* Set the stylesheet that fit your needs *)
iniStyle = StyleDefinitions /. Options[nb];
SetOptions[nb,StyleDefinitions->"Default.nb"];
Export[FileBaseName[name],nb,"PDF"];
SetOptions[nb,StyleDefinitions->iniStyle];
,{nb,Notebooks[]}
]

-
How do I change the font size? And this looks like it will change my working notebook styles. I don't want to change those. I just want the font size smaller in the exported pdf, but not in the actual notebook while I am working in mathematica. –  nullUser Dec 4 '13 at 17:42
I edited the code so that leaves the initial stylesheet. I don't know the exact style that you want to modify. The easy way could be edit the actual stylesheet a save as new one (you should change "Default.nb" for this) a edit the "printout" style that you need. –  SMiranda Dec 4 '13 at 18:16

If you evaluate this:

SetOptions[EvaluationNotebook[],
StyleDefinitions ->
Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]],
Cell[StyleData[All, "Printout"], Magnification -> 1,
FontSize -> 12]},
StyleDefinitions -> "PrivateStylesheetFormatting.nb"]]


You can adjust magnification and font size accordingly (and include cell margins if needed). For this to work you need to have your printing environment set to "Printout". The fact that your fonts are too big makes me think your printing environment is set to another mode. Ideally your would adjust this in your stylesheet.

-