AccessViolationException - PdfReaderGetPageCount
AccessViolationException - PdfReaderGetPageCount
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?
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?
Re: AccessViolationException - PdfReaderGetPageCount
Please send us the PDF for investigation at https://www.gdpicture.com/support/getting-support-from-our-team
Kind regards,
Loïc
Kind regards,
Loïc
Re: AccessViolationException - PdfReaderGetPageCount
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.
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();
}
}
Re: AccessViolationException - PdfReaderGetPageCount
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
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
Re: AccessViolationException - PdfReaderGetPageCount
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:
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); }
}
Re: AccessViolationException - PdfReaderGetPageCount
Hi,
This problem come from your stream. Seek operation is not supported.
You can try the following code to verify:
You should try to create another memory stream containing exported data of the stream object.
Hope this helps !
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); }
}
Hope this helps !
Re: AccessViolationException - PdfReaderGetPageCount
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.
Who is online
Users browsing this forum: No registered users and 1 guest