saveRewritten

fun saveRewritten(useObjectStreams: Boolean = false): ByteArray

Serialize a fresh, self-contained PDF containing only the objects reachable from the catalog (and /Info), with staged edits applied and objects renumbered densely. Unlike saveIncremental, the original bytes are NOT retained and unreachable objects (e.g. content streams replaced by an edit) are dropped, which is what makes it the correct method for redaction (the removed content is truly gone, not just superseded).