Click here to Skip to main content
15,889,315 members

Comments by Member 11316500 (Top 1 by date)

Member 11316500 17-Dec-14 1:38am View    
I am also using ItextSharp and even I am getting the same error at the line of PdfReader initialization -

using (Stream pdfStream = [HttpPostedFile from File upload control].InputStream)
{
pdfStream.Position = 0;
using (iTextSharp.text.pdf.PdfReader pdfReader = new iTextSharp.text.pdf.PdfReader(pdfStream))
{
}
}

Here the pdfStream is a Stream object created from the InputStream of FileUpload control.

The same code is running fine in console application when I am reading the data from a FileStream object as given below.

using (Stream pdfStream = new FileStream(pData.Files[0], FileMode.Open))
{
iTextSharp.text.pdf.PdfReader pdfReader = new iTextSharp.text.pdf.PdfReader(pdfStream);
}

Don't really know if reading from a posted file InputStream is an issue over FileStream or not (which any way is not possible to be converted from postedfile's inputstream). I am really going nuts..!!
The PDF file is not corrupted as the same file is getting processed very well in console application with the code shown above in the second place.