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

Free Support Forum - aspose.com

Pdf Document fails to open a stream

Hi, I’m trying to open a pdf document using Aspose.Pdf.Document (.Net) to generate preview images. Unfortunately the first step - when I pass the stream to the constructor - fails.


EndOfStreamException
Unable to read beyond the end of the stream.

at System.IO.BinaryReader.ReadByte()
at .?.()
at .?.?()
at .?..ctor(Stream , String , Boolean )
at .?..ctor(Stream )
at ..?(Stream )
at .…ctor(Stream )
at Aspose.Pdf.Document.?(Stream , String )
at Aspose.Pdf.Document…ctor(Stream input)

The strange thing is that it worked with the previous version of Aspose.Pdf, but after we upgraded to the latest version, it fails with all of my test files.

Any ideas?
Thanks
Mike

Hi Mike,


Thanks for contacting support.

Can you please share the resource PDF file and the code snippet which you are using so that we can test the scenario at our end. We are sorry for this inconvenience.

Hi, I encounter the same error with any pdf. I attached one of them, it is an MS spec file.

The code is simple, I try to create a document object:

var document = new Document(docStream);

I see that Aspose.Pdf reads the stream heavily (sometimes byte-per-byte, and even seeks backwards) but this should not be a problem (the stream is our custom stream implementation but it works with every other file type we need). Somehow at one point it sets the position beyond the end of the stream.

(we use Aspose.Pdf 8.2.0.0)

Thanks
Mike

Hi Mike,


Thanks for sharing the resource file.

I have tested the scenario where I have used the following code line to read the PDF document with Aspose.Pdf for .NET 8.2.0 in VisualStudio 2010 application, running over Windows 7(X64) and I am unable to notice any problem. Can you please share the code snippet which you are using to read the PDF stream, so that we can test that scenario at our end. We are sorry for your inconvenience.

[C#]

//open document<o:p></o:p>

Document pdfDocument = new
Document(new
FileStream(“c:/pdftest/%5bMS-DWSS%5d.pdf”,
FileMode.Open));