It seems that there isn't any perfect solution for this problem in a closely realted: Is there a way to hide or toggle the visibility of code?
Here are alternatives:
Quick fix
If you don't want to play with styles and want a quick solution you can just clone a notebook and delete "Input"
cells before printing:
NotebookDelete @ Cells[
NotebookPut @ NotebookGet[ notebook ]
, CellStyle -> {"Input"}
]
Persiting solution
If you want this to be a fixed property of a notebook then we can combine
how to affect style for PDF exported notebook with
how to create an invisible cell
and create private styles for our notebook (or edit alterady existing private styles if that is the case)
SetOptions[
EvaluationNotebook[]
, StyleDefinitions -> Notebook[{
Cell[StyleData[StyleDefinitions -> "Default.nb"]]
, Cell[
StyleData["Input", "Printout"]
, CellElementSpacings -> {"CellMinHeight" -> 0, "ClosedCellHeight" -> 0}
, Background -> Hue[.8]
, CellMargins -> -2
, CellOpen -> False
, CellFrame -> 0
, ShowCellBracket -> False
]
}]
]
SetOptions[nb, ShowCellBracket -> False];
$\endgroup$