We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Memory Steam is not expandable error after applying lic file

If I create a license ( Aspose.Pdf.Kit.License lic = new Aspose.Pdf.Kit.License();
FileStream myStream = new FileStream("Aspose.Pdf.Kit.lic", FileMode.Open);

before or in the following method I receive an error. System.NotSupportedException (Memory Stream is not expandable)

If I don't create a license it works as it should (all be it with the demo text)

private static byte[] RenderReadOnly(byte[] incoming)

MemoryStream inStream = new MemoryStream(new byte[incoming.Length]);
inStream.Write(incoming, 0, incoming.Length);

MemoryStream outStream = new MemoryStream(new byte[incoming.Length]);

PdfFileSecurity pdfs = new PdfFileSecurity(inStream, outStream);

pdfs.SetPrivilege(DocumentPrivilege.Print); // error occures here.
catch (Exception ex)

byte[] result = outStream.ToArray();
pdfs = null;
return result;


Hello,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.

I have tested the code at my end and was able to re produce the error. But as you mentioned in your comments, if we don’t create license it works fine. I am receiving the same error in either case. If it does not violate your policy, can you please share the project with us in order for us to have more understanding.


You should modify your code like the following:

MemoryStream outStream = new MemoryStream();

Removing size from the MemoryStream constructor, does indeed resolve the issue. Thank you for the quick and accurate reply!