Exporting Summary Boxes

I would like to Export a Summary Box in its expanded Form. How do i do this? I can Export a collapsed Summary Box by doing:

result = ConvolutionLayer[4,8] (*which is a summary Box*)
Export["testFile.pdf", result]

• Interactively you can expand the summary box and then right-click on the cell bracket and select "Save selection as", but it would be nice to be able to do that programmatically – Jason B. Feb 5 '19 at 18:00

edit: simplified code and an explanation

I could bet I already answered that in the past but can't find. The solution works as follows:

What you see is a box expression (MakeBoxes[result of evaluation]) rendered by the FrontEnd. You can inspect it via Ctrl+Shift+E or by applying ToBoxes on your expression. The latter allows you to work with boxes and modify them.

After inspection we see that it is roughly DynamicModule[{open = False}, PaneSelector[...].... So we want to replace False with True in order to make the initial pane open. You can later use RawBoxes or DisplayForm to preview results or to make Export export its rendered form instead of raw box expression.

result = ConvolutionLayer[4,8];

result //
ToBoxes //
ReplaceAll[ HoldPattern[Typesetopen = _] :> (Typesetopen = True)] //
RawBoxes //
Export["test.pdf", #] &


• Unevaluated also works for this, ReplaceAll[ HoldPattern[Typesetopen = False] :> Unevaluated[Typesetopen = True]] – Jason B. Feb 5 '19 at 18:13
• @JasonB. Good for you :p I find it hard to use Unevaluated for more than simple things so I don't use it ;) – Kuba Feb 5 '19 at 18:17
• This is in a Hold... structure so you don't even need to Hold. You can just do something like HoldPattern[Typesetopen = _] :> (Typesetopen = True) – b3m2a1 Feb 5 '19 at 21:10
• @b3m2a1 you are right, guess I shouldn't have skipped my 3rd coffee. Will correct it tomorrow. – Kuba Feb 5 '19 at 21:14
• @Kuba Thanks for giving me this insight. Do you also know how i can ommit the ConvolutionLayer[]? – Gladaed Feb 28 '19 at 17:24