Add encoding flag to document preparation