Loading...

AccessViolationException - PdfReaderGetPageCount

General discussions about GdPicture.NET.

AccessViolationException - PdfReaderGetPageCount

Postby 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?
mmImc
 
Posts: 10
Joined: Wed Feb 11, 2009 9:52 pm

Re: AccessViolationException - PdfReaderGetPageCount

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

Please send us the PDF for investigation at http://support.gdpicture.com

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4442
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: AccessViolationException - PdfReaderGetPageCount

Postby 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();
      }
}
mmImc
 
Posts: 10
Joined: Wed Feb 11, 2009 9:52 pm

Re: AccessViolationException - PdfReaderGetPageCount

Postby 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
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4442
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: AccessViolationException - PdfReaderGetPageCount

Postby 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(@"http://guides.gdpicture.com/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); }
 }
mmImc
 
Posts: 10
Joined: Wed Feb 11, 2009 9:52 pm

Re: AccessViolationException - PdfReaderGetPageCount

Postby 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 !
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4442
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: AccessViolationException - PdfReaderGetPageCount

Postby 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.
mmImc
 
Posts: 10
Joined: Wed Feb 11, 2009 9:52 pm


Return to General discussions

Who is online

Users browsing this forum: No registered users and 1 guest