Hi,
I convert the stream of a pdf viewer into a string:
string text = Convert.ToBase64String(ReadFully(pdfViewerControl.InputFileStream));
private static byte[] ReadFully(Stream input)
{
byte[] buffer = new byte[16 * 1024];
using (MemoryStream ms = new MemoryStream())
{
int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, read);
}
return ms.ToArray();
}
}
That's work fine, but when i try to do the inverse process, i have this error:
Stream str = new MemoryStream(Convert.FromBase64String(text));
pdfViewerControl.InputFileStream = str;
Syncfusion.Pdf.PdfException: 'Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.'
What is the solution for this?
Thanks.
PD: The objective is can save the string, and in any moment, can convert it into a stream and print it in a pdf viewer.