Support printing generated document

Fixed #277