Converts a document to a given format such as text, html or sql.