I am using a function like the one below to expose a pdf as a stream. PDFDoc is a PdfDocument object that was opened using a file-path pointing to a PDF created by Crystal Reports 2008. In debug mode everything works fine, but at runtime the Pages collection is null so the save operation fails. It seems like a stream buffer needs to be flushed. Am I doing something wrong?
Code:
public override System.IO.Stream GetData()
{
System.IO.Stream pStream;
System.IO.MemoryStream mStream;
if (IsOpen)
{
mStream = new System.IO.MemoryStream();
pStream = (System.IO.Stream)mStream;
PDFDoc.Save(pStream,false);
return pStream;
}
return null;
}
TIA,
Using PdfSharp 1.2.1269