Page 1 of 1
RenderPageToGdPictureImage (PDF to TIFF) Fails unexpectedly, but works after App Restart
Posted: Thu Apr 29, 2021 11:38 pm
by mklein
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
Re: RenderPageToGdPictureImage (PDF to TIFF) Fails unexpectedly, but works after App Restart
Posted: Fri Apr 30, 2021 2:44 pm
by Hugo
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
Re: RenderPageToGdPictureImage (PDF to TIFF) Fails unexpectedly, but works after App Restart
Posted: Fri Apr 30, 2021 3:49 pm
by mklein
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;
}
}