We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ConvertFdfToXml without actually using files?

Hi, this piece of code works as intended:


byte[] byteArray = Encoding.UTF8.GetBytes(ssFDF);
using (MemoryStream fdfStream = new MemoryStream(byteArray))
{
tmpFile = Path.GetTempFileName();
using (FileStream fos = new FileStream(tmpFile, FileMode.Create, FileAccess.ReadWrite))
{
FormDataConverter.ConvertFdfToXml(fdfStream, fos);
}
using (StreamReader sr = new StreamReader(tmpFile))
{
ssXML = sr.ReadToEnd();
}
}

in the finally clause i do delete the file, but still
I really don’t want to use any file at all. they have a habit to stay put in tmp folder…

so I came up with another solution:
byte[] byteArray = Encoding.UTF8.GetBytes(ssFDF);
using (MemoryStream fdfStream = new MemoryStream(byteArray))
{
using (MemoryStream xmlStream = new MemoryStream())
{
FormDataConverter.ConvertFdfToXml(fdfStream, xmlStream);
xmlStream.Position = 0;
using (StreamReader sr = new StreamReader(xmlStream))
{
ssXML = sr.ReadToEnd();
}
}
}

but now i get the exception "Cannot access a closed Stream"
which is funny, because I did not close streams yet…

Hi Joost,


Thanks for your inquiry. I am afraid I am unable to execute your sample code. Can you please confirm the Aspose.PDF API version and namespaces used for the the FormDataConverter.

We are sorry for the inconvenience caused.

Best Regards,