Loading...

"image too large" and "AccessViolationException" errors

Discussions about image processing in GdPicture.NET using GdPictureImaging.

"image too large" and "AccessViolationException" errors

Postby ryancole12 » Mon Aug 15, 2011 7:53 pm

Hello again,

I'm encountering an exception that I can't seem to recover from while using .NET v8 and making a call to PdfAddGdPictureImageToPdfOCR. We're converting PDFs to image-only PDFs of itself. This involves looping over each page in PDF #1 and rendering it to gdpicture image and then saving it to PDF #2.

The exception that seems to be blowing up the program is an System.AccessViolationException from within GdPicturePro .NET's PdfAddGdPictureImageToPdfOCR function. This does not seem to be recoverable and causes the application the crash. I also see some output to the console that seems to come from within GdPicturePro itself, saying "Image too large (2102, 33042)".

The page that we are rendering to image and putting into a new PDF + OCRing it is definitely very large. We did page sizes this large in the v7 edition. At the very least, in the v7 edition we were able to catch the exception and continue to the next page. The v8 function call seems to blow up the whole thing and causes the entire operation to halt. The PDF itself also has about 600 pages, and when I remove the individual page causing the crash and PDF it alone it works, but when it comes up in the original PDF (it's page 406), it crashes.

I will paste my code below as well as attach a screenshot of the exception. Any ideas on how to prevent this?

Code: Select all
// flatten the original pdf into image only pdf
            if (the_pdf.LoadFromFile(file_original, false) == GdPictureStatus.OK)
            {
                // create the final OCRed pdf
                int ocr_id = the_imaging.PdfOCRStart(file_produced, false, "", "", "", "", "");

                int page_count = the_pdf.GetPageCount();
                for (int x = 1; x <= page_count; x++)
                {
                    Console.WriteLine("Flattening and OCRing page {0} of {1}.", x, page_count);

                    // activate the current page
                    if (the_pdf.SelectPage(x))
                    {
                        try
                        {
                            // rasterize the active page
                            int image_id = the_pdf.RenderPageToGdPictureImage(200, true);

                            if (image_id > 0)
                            {
                                the_imaging.PdfAddGdPictureImageToPdfOCR(ocr_id, image_id, "eng", dictionaries, "");
                                the_imaging.ReleaseGdPictureImage(image_id);
                            }
                            else
                            {
                                Log(String.Format("Could not rasterize page {0}.", x));
                            }
                        }
                        catch (Exception ex)
                        {
                            Log(ex.Message);
                        }
                    }
                    else
                    {
                        Log(String.Format("Could not select page {0}.", x));
                    }
                }

                // stop the OCRing
                the_imaging.PdfOCRStop(ocr_id);

                // close the original pdf
                the_pdf.CloseDocument();
            }
            else
            {
                Log(String.Format("Error opening original pdf; {0}.", file_original));
            }
Attachments
Untitled.png
ryancole12
 
Posts: 4
Joined: Tue Aug 09, 2011 5:52 pm

Re: "image too large" and "AccessViolationException" errors

Postby Loïc » Mon Aug 15, 2011 8:26 pm

Hi,

We fixed a similar problem in our current beta release.

Please create a ticket at http://support.gdpicture.com. Attach your document that raises the exception. If the document is confidential and cannot be shared, we will provide a link to the current beta release.

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


Return to Image Processing

Who is online

Users browsing this forum: No registered users and 0 guests

cron