Memorystream pdfDocument

Aug 2, 2012 at 2:10 PM

Hi all,

I started with the SilverPdf library which is equal to the PdfSharp library and I

wanted to executed twice the same code with the different libraries. But soon I

had an issue.

The value "encodedData" in this code below (in Silverlight) is different when I

execute the same code in a console application. Later on I save the stream,

and when I open the pdf it gives an error. When copy the encodedData from

the console application into this code, it works.


Is there a difference between the Save functionality of the PdfSharp and SilverPdf.

Or is their another way to generate the same encodedData in Silverlight as in the Console application?


Many thanks in advance!


MemoryStream stream = new MemoryStream();

PdfDocument pDoc = new PdfDocument();
PdfPage page = new PdfPage();

pDoc.Save(stream, false);

var byteData = new byte[stream.Length];
stream.Read(byteData, 0, byteData.Length);

var encodedData = Convert.ToBase64String(byteData);