Aspose.PDF - PDF to image is really slow

SCAN0196.PDF (3.2 MB)

Hi,

We’re trying to convert uploaded PDF document to an image (for generating thumbnails). This conversion is really SLOW. It takes almost 13s to convert the PDF (2 pages) to 2 images :frowning:

The PDF is probably coming from a scanner in very high resolution. Other products (like MagicK only need 1 second to do the same)

We’re using following code:

using (var pdfDocument = new Aspose.Pdf.Document(@"c:\temp\portima_STD.pdf"))
            {
                //Aspose.Pdf.Optimization.OptimizationOptions optimizationOptions = new Aspose.Pdf.Optimization.OptimizationOptions()
                //{
                //    RemoveUnusedObjects = true,
                //    RemoveUnusedStreams = true,
                //    AllowReusePageContent = true,
                //    LinkDuplcateStreams = true
                //};

                ////Deze optie heeft een impact op de kwaliteit van de images. Hier mee spelen heeft een enorme impact op de grootte van de PDF
                //optimizationOptions.ImageCompressionOptions.CompressImages = true;
                //optimizationOptions.ImageCompressionOptions.ImageQuality = 100;
                //optimizationOptions.ImageCompressionOptions.MaxResolution = 300;
                //optimizationOptions.ImageCompressionOptions.ResizeImages = true;
                //optimizationOptions.ImageCompressionOptions.Version = Aspose.Pdf.Optimization.ImageCompressionVersion.Fast;
                //pdfDocument.OptimizeResources(optimizationOptions);

                pdfDocument.RemoveMetadata();
                pdfDocument.Flatten();
                pdfDocument.RemovePdfaCompliance();

                for (int i = 1; i <= pdfDocument.Pages.Count; i++)
                {
                    //pdfDocument.Pages[i].Flatten();
                    //pdfDocument.Pages[i].SendTo(new JpegDevice(83, 100, new Resolution(100), 50), @"c:\temp\image_" + i + ".jpg");

                    //or
                    using (FileStream ms = new FileStream(@"c:\temp\image_" + i + ".jpg", FileMode.Create))
                    //using (MemoryStream ms = new MemoryStream())
                    {
                        Resolution resolution = new Resolution(100);
                        //PngDevice jpegDevice = new PngDevice(45, 59, resolution);
                        //JpegDevice jpegDevice = new JpegDevice(45,59,resolution, 100);
                        JpegDevice jpegDevice = new JpegDevice(83, 100, resolution, 100);

                        jpegDevice.RenderingOptions = new RenderingOptions()
                        {
                            BarcodeOptimization = false,
                            ConvertFontsToUnicodeTTF = false,
                            ScaleImagesToFitPageWidth = false,
                            UseNewImagingEngine = true,
                            InterpolationHighQuality = false,
                        };

                        jpegDevice.Process(pdfDocument.Pages[i], ms);
                    }
                }
            }

Can you help?

Thx

@lagaffe

Thank you for contacting support.

We have worked with the data shared by you and have been able to reproduce the issue in our environment. A ticket with ID PDFNET-46454 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.