Can anyone give me an example of how to get a PdfReader from a MemoryStream? I can see that the PdfReader class has a couple of methods which look likely candidates(GetStreamBytes & GetStreamBytesRaw), however these seem to want iText specific streams, mine is just a regular Byte[] or MemoryStream.
This is using C# and .net4
iTextSharp.text.pdf.PdfReader rdr = iTextSharp.text.pdf.PdfReader.GetStreamBytesRaw
Thanks in advance.
If you want to just open the pdf in browser using bytes then do this :
You can create a PdfReader from a MemoryStream, so long as the MemoryStream is a valid PDF object. If the MemoryStream is a valid PDF object, then one way to initiate the PdfReader is this way:
In the code below, the PdfReader is initialized from .Net Resource which is returned as a byte[] when called from the Properties.Resources object, so the Resource and the MemoryStream are returning the same type to the PdfReader, a byte[]. I then create a PdfStamper object from the PdfReader object, and use a MemoryStream as the resulting container for the PdfStamper.
Maybe a bit late. Try to set the streams position to 0.