RenderPageToGdPictureImage (PDF to TIFF) Fails unexpectedly, but works after App Restart

General discussions about GdPicture.NET.
Post Reply
mklein
Posts: 4
Joined: Thu Apr 29, 2021 11:27 pm

RenderPageToGdPictureImage (PDF to TIFF) Fails unexpectedly, but works after App Restart

Post by mklein » Thu Apr 29, 2021 11:38 pm

Any ideas why RenderPageToGdPictureImage would start to fail, but then successfully process after (the same file/files) after an App Pool restart?

Feels like it is memory related if it clears up after a restart? Any pointers or tips to look at around why it would fail over time, but succeed after a restart?

This is a Web App running in an Azure App Service

Hugo
Posts: 227
Joined: Tue Dec 18, 2018 10:09 am

Re: RenderPageToGdPictureImage (PDF to TIFF) Fails unexpectedly, but works after App Restart

Post by Hugo » Fri Apr 30, 2021 2:44 pm

Hi there

Thanks for your question however the information here is insufficient.

Feel free to contact us here with more information so we can help you:
https://orpalis.zendesk.com/hc/en-us/requests/new

Providing a code project isolating the issue for us to reproduce would be great for us to investigate the issue further.

Regards,
Hugo

mklein
Posts: 4
Joined: Thu Apr 29, 2021 11:27 pm

Re: RenderPageToGdPictureImage (PDF to TIFF) Fails unexpectedly, but works after App Restart

Post by mklein » Fri Apr 30, 2021 3:49 pm

Here is the method that fails - and it fails on RenderPageToGdPictureImage - however, after simply restarting the web app - it works again. It seems as though we have to restart 1-2x daily and we have not been able to directly replicate

Code: Select all

 protected bool ConvertPdfToTiff( Stream stream )
        {
            try
            {
                GdPictureStatus status = PdfImaging.LoadFromStream( stream );
                if( status != GdPictureStatus.OK )
                    throw new InvalidOperationException( "ConvertPdfToTiff: Does not appear to be a valid PDF stream." );

                for( int i = 1; i <= PdfImaging.GetPageCount(); i++ )
                {
                    PdfImaging.SelectPage( i );
                    int rasterizedImageId = PdfImaging.RenderPageToGdPictureImage( 200, true, PixelFormat.Format32bppPArgb, PdfRasterizerEngine.PdfRasterizerEngineGdiplus );
                    if( rasterizedImageId == 0 )
                        throw new InvalidOperationException( "ConvertPdfToTiff: Unable to render PDF page to TIFF." );

                    if( ImageId <= 0 )
                        ImageId = PictureImaging.TiffCreateMultiPageFromGdPictureImage( rasterizedImageId );
                    else
                        PictureImaging.TiffAppendPageFromGdPictureImage( ImageId, rasterizedImageId );

                    PictureImaging.ReleaseGdPictureImage( rasterizedImageId );
                }

                return ImageId > 0;
            }
            catch( Exception exception )
            {
                Logging.Logging.LogException( exception );
                return false;
            }
        }

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest