Free Support Forum - aspose.com

Saving to stream and file

If I execute the following code, the pdf output is duplicated in the file save. How do I avoid this? Do I have to create a new pdf object and rebind the xml?

//create a pdf object

Pdf pdf = new Pdf();

//load the xml stream into an xml document and bind to the pdf object

XmlDocument xml = new XmlDocument();

xml.Load(xmlstream);

pdf.BindXML(xml, null);

//save pdf document to stream

pdf.Save(stream);

//save pdf document to file

filename.Append(" for " + row[m_NameField] + “.pdf”);
pdf.Save(filename.ToString());

Dear jbmeeh,

Thank you for considering Aspose.

Aspose.Pdf renders the paragraphs into pages in the “Save” method. You should not call the “Save” method more than once for one Pdf object.