Convert multiple .doc to .pdf files

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

What’s your pdfStream variable? I think you should recreate it or at least truncate to zero, not reuse like you do now.

System.IQ.MemoryStream pdfStream = new MemoryStream ();
how do i truncate or reuse...
any suggestion.

Just move this line to be inside the loop.

ummm…thx it did work…
sorry to bother again.
umm…instead of converting the 2 .doc to .pdf
it keeps covertign the same document to pdf…

e.g
doc 1 content --> " Manchester United bt Arsenal 2-0 Yahooo!"
doc 2 content --> " Blah Blah Blah Blah Blah Blah Blah Blah "

the content of the pdf generated is

pdf 1 content --> " Manchester United bt Arsenal 2-0 Yahooo!“
pdf 2 content --> " Manchester United bt Arsenal 2-0 Yahooo!”