The dirty property makes the PDF as modified when it is true and it triggers to save it before to leave.
System.Boolean dirty();
Returns the current property value.
Member of doc.