Here is my piece of code:
- Code: Select all
{
//save the document as Word
var ms = new MemoryStream();
document.SaveToStream(
ms,
Spire.Doc.FileFormat.Docx
);
// ...
}
{
//save the document as PDF
var ms = new MemoryStream();
document.SaveToStream( //<-- throws here
ms,
Spire.Doc.FileFormat.PDF
);
// ...
}
It throws an exception on the SaveToStream method when the target format is PDF:
Unhandled Exception: System.ArgumentException: Parameter is not valid.
However, a similar snippet works fine if I use the SaveToFile method to save files directly on disk rather using streams.
- Code: Select all
//save the document as Word
document.SaveToFile(
@"C:\Users\Mario\Documents\SampleReport.docx",
Spire.Doc.FileFormat.Docx
);
//save the document as PDF
document.SaveToFile(
@"C:\Users\Mario\Documents\SampleReport.pdf",
Spire.Doc.FileFormat.PDF
);
By looking your documentation about the SaveToStream method, you describe that it manages only XML and Word formats. I wonder what's the "XML" format, since AFAIK the Word format is XML based.
http://www.e-iceblue.com/api_documents/53f3fce5d821b6-00532457/res/html/24f027f6-4a59-de9c-4a48-56a66c7ba7ec.htm
Is it a typo on the documentation, or is there any (easy) way to save a document against a stream in the PDF format?
Thanks
Mario