I am encountering some problems when I try to print a document that it stored in memory as a byte array.
My function is the following:
- Code: Select all
private static void Print(byte[] bytes)
{
using (var stream = new MemoryStream(bytes))
{
using (var document = new Spire.Doc.Document(stream))
{
document.PrintDocument.PrinterSettings.PrinterName = "MyPrinter";
document.PrintDocument.Print();
}
}
}
However, occasionally the function fails, even when printing always the same document (just to make sure the problem does not depend on the document itself).
What I suspect, is that the printing process is actually carried out during the OnBeginPrint event, where it tries to access resources that may have been disposed by the using statement.
Is my feeling correct? How would you suggest to address the problem?
Thanks,
Francesco