AccessViolationException - PdfReaderGetPageCount

General discussions about GdPicture.NET.
Post Reply
mmImc
Posts: 10
Joined: Wed Feb 11, 2009 9:52 pm

AccessViolationException - PdfReaderGetPageCount

Post by mmImc » Thu Oct 21, 2010 11:56 pm

I am having an issue getting the page count of a PDF file. I am running GdPic 7.1.

int pdfID = this.gdImaging.PdfReaderLoadFromStream(stream);
try { return this.gdImaging.PdfReaderGetPageCount(pdfID); } // Exception thrown here
finally { this.gdImaging.PdfReaderCloseDocument(pdfID); }

The stream is coming from a WebResponse object. I have used a similar method to count Tiff pages (using the same data retrieval through the WebResponse) with no issue.

Could you please advise on this issue?

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: AccessViolationException - PdfReaderGetPageCount

Post by Loïc » Fri Oct 22, 2010 3:47 pm

Please send us the PDF for investigation at https://www.gdpicture.com/support/getting-support-from-our-team

Kind regards,

Loïc

mmImc
Posts: 10
Joined: Wed Feb 11, 2009 9:52 pm

Re: AccessViolationException - PdfReaderGetPageCount

Post by mmImc » Fri Oct 22, 2010 4:30 pm

This is happening on every document I try, even the included GdPicture PDF documentation.

Here's some demo code I wrote up to test, it has failed on every document I have done.

Code: Select all

GdPicture.GdPictureImaging gdImaging = new GdPicture.GdPictureImaging();
gdImaging.SetLicenseNumberUpgrade(..., ...);

int pageCount = 0;

using (FileStream stream = new FileStream(@"C:\GdPicture.NET7.pdf", FileMode.Open, FileAccess.Read))
{
      int pdfID = gdImaging.PdfReaderLoadFromStream(stream);      // Error is being thrown here now
      try { pageCount = gdImaging.PdfReaderGetPageCount(pdfID); }
      finally
      {
           gdImaging.PdfReaderCloseDocument(pdfID);
           stream.Close();
      }
}

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: AccessViolationException - PdfReaderGetPageCount

Post by Loïc » Fri Oct 22, 2010 4:32 pm

OK I see,

we have a know bug with stream management in 7.1. This will be resolved in 7.2 which will be available next week.

Loïc

mmImc
Posts: 10
Joined: Wed Feb 11, 2009 9:52 pm

Re: AccessViolationException - PdfReaderGetPageCount

Post by mmImc » Tue Oct 26, 2010 10:03 pm

I've just been testing the new 7.2 release with the issues I've been having. I can now pass in local file streams without issue, but I am still having my original problem with reading from an HTTP stream. I now receive the error on opening "GDPDFPLUG_LoadFromStream - exception: OLE error 80131515". Any suggestions?

Test Code:

Code: Select all

GdPicture.GdPictureImaging gdImaging = new GdPicture.GdPictureImaging();
gdImaging.SetLicenseNumberUpgrade(..., ...);

int pageCount = 0;

WebRequest req = WebRequest.Create(@"https://www.gdpicture.com/guides/gdpicture/v7/pdf/GdPicture.NET7.pdf");
WebResponse resp = req.GetResponse();

using (Stream stream = resp.GetResponseStream())
{
    int pdfID = gdImaging.PdfReaderLoadFromStream(stream);
    try { pageCount = gdImaging.PdfReaderGetPageCount(pdfID); }
    finally { gdImaging.PdfReaderCloseDocument(pdfID); }
 }

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: AccessViolationException - PdfReaderGetPageCount

Post by Loïc » Wed Oct 27, 2010 11:35 am

Hi,

This problem come from your stream. Seek operation is not supported.

You can try the following code to verify:

Code: Select all

using (Stream stream = resp.GetResponseStream())
{
  stream.Seek(0, SeekOrigin.Begin);
    int pdfID = gdImaging.PdfReaderLoadFromStream(stream);
    try { pageCount = gdImaging.PdfReaderGetPageCount(pdfID); }
    finally { gdImaging.PdfReaderCloseDocument(pdfID); }
}
You should try to create another memory stream containing exported data of the stream object.

Hope this helps !

mmImc
Posts: 10
Joined: Wed Feb 11, 2009 9:52 pm

Re: AccessViolationException - PdfReaderGetPageCount

Post by mmImc » Wed Oct 27, 2010 5:13 pm

Thanks Loic for pointing me in the right direction. I copied the incoming stream into a seekable stream and that seems to have corrected my issue.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest