Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
$\begingroup$I asked AI and it said to select all cells with GraphicsBox. Once selected, you can map over each cell and print it or export. This is what AI said to try. outputCells = Cells[CellStyle -> "Output"]; cellsWithGraphics = Select[outputCells, ! FreeQ[NotebookRead[#], GraphicsBox] &]; MapIndexed[ Export[ToString[#2[[1]]] <> ".png", #1] &, cellsWithGraphics ] Never tried it. But you can try it yourself and see. Change the Export command above to Print if that is what you want. Note, AI sometimes gives buggy or invalid code.$\endgroup$
$\begingroup$Just saw what looks like duplicate question how-to-export-all-graphics-from-a-notebook , just change the Export to Print if needed. My guess also is that gogle AI just used the answer above in its answer.$\endgroup$
$\begingroup$Following up on @Nasser's comment, I'm voting to close as a duplicate as the solution of just extracting the cells with Graphics objects to print is the correct one and may easily be extended to include the surrounding section cells$\endgroup$
A quick and easy way would be to select all output cells with Option-click (on Mac) and then "Print Selection..." from the File menu. That's assuming that output cells only contain plots.
outputCells = Cells[CellStyle -> "Output"]; cellsWithGraphics = Select[outputCells, ! FreeQ[NotebookRead[#], GraphicsBox] &]; MapIndexed[ Export[ToString[#2[[1]]] <> ".png", #1] &, cellsWithGraphics ]Never tried it. But you can try it yourself and see. Change theExportcommand above to Print if that is what you want. Note, AI sometimes gives buggy or invalid code. $\endgroup$Graphicsobjects to print is the correct one and may easily be extended to include the surrounding section cells $\endgroup$