hi…
i m trying to convert multiple .document into their respective pdf…
sample code :
…
foreach ( SPListItem myDocItm in myDocItmColl)
{
if (myDocItm !=null)
{
file = myDocItm.File;
filename = file.Name;
binFile = file.OpenBinary();
bnWriter.Write(binFile);
Word wrd = new Word();
Document doc = wrd.Open(fileStream);
doc.Save (pdfStream, SaveFormat.FormatAsposePdf);
pdfStream.Seek(0, SeekOrigin.Begin);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(pdfStream); <-- Exception Occurs
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.IsImagesInXmlDeleteNeeded = true;
pdf.BindXML(xmlDoc, null);
pdf.Save(oStream);//Save To Stream
oFile = oStream.GetBuffer();
SlashPos = filename.IndexOf(’.’);
filename = filename.Substring(0,filename.Length -(filename.Length - SlashPos ));
filename = filename + “.pdf”;
myFileColl.Add((destURL + “/” + filename),oFile);
pdfStream.Flush();
}
}
Basically the code above takes document from Share Point Portal Server document library. If there is 3 Word Documents inide the Document Library…it will loop 3 times.
i encounter this exception when i run the code.
Exception Details: System.Xml.XmlException: There are multiple root elements.
Note: the 1st document on the list is converted but when the function loop the second time
it gives me the exception