New interface for writing PDF files

Generalizes incremental updates
and PDF generating
Update example
Update other example