Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Jan 13, 2021 10:39 am

Hi
I am using spire pdf to convert pdf pages to images. one page is one image.
For that I am using SaveAsImage function, but it is taking long time to convert whole pdf.
Any suggestions, how can I improve the performance.

ExtractImages will not work if I need to convert 1 page to 1 image.

raman123
 
Posts: 4
Joined: Wed Jan 13, 2021 10:20 am

Thu Jan 14, 2021 8:55 am

Hello,

Thanks for your inquiry.
To help us further analyze, please provide us with your input file and your OS information (e.g. Windows7, 64bit). Also, please tell us how long it took you to convert your whole file to images.
You could send your file to us (support@e-iceblue.com) via email. Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Jan 22, 2021 9:50 am

Hello,

Has your issue been resolved? If not, could you please provide your input file to us for further investigation?

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Tue Apr 20, 2021 7:50 am

I had the same problem.
SaveAsImage method is very slow.
env: windows 2008 r2 64bit,windows 10 64bit ,spire.pdf version:7.4.5
but,if i use 5.12.15 verion,it's very fast.

pdf doc have only some simple text,only two or three pages,not exist picture

yonkerzhang
 
Posts: 2
Joined: Tue Apr 20, 2021 7:39 am

Tue Apr 20, 2021 10:16 am

Hello,

Thanks for your message.
I created a .netCore project, installed our Spire.Pdf 4.7.5 Nuget package and tested a simulated PDF, the conversion performance indeed is not as good as the older version 5.12.15. We have posted this issue to our Dev team, they will do further investigations to check if there is any approach to improve the performance. Once there is any progress, I will let you know immediately.
Meanwhile, you also can refer to the following sample code to do the conversion by using our Spire.PDF.NETCore 7.4.5 dll. It has a better performance when converting my simulated PDF file. If the performance still is not good when you test your file, please share us with it to help do a further investigation.
Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile("input.pdf");
//Save to images
for (int i = 0; i < doc.Pages.Count; i++)
{     
        String fileName = String.Format("ToImage-img-{0}.png", i);   
        Image image = doc.SaveAsImage(i);
        image.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
    }
}


Sincerely,
Sofia
E-iceblue support team
User avatar

Sofia.Yang
 
Posts: 84
Joined: Tue Jul 14, 2020 1:41 am

Wed Apr 21, 2021 2:05 am

thanks Sincerely.
i used Spire.PDF.NETCore replace Spire.PDF, indeed ,It has a better performance when i use SaveAsImage method.

yonkerzhang
 
Posts: 2
Joined: Tue Apr 20, 2021 7:39 am

Wed Apr 21, 2021 5:52 am

Hello,

Thanks for your feedback.
If you encounter any issues related to our products in the future, just feel free to contact us. Have a nice day!

Sincerely,
Sofia
E-iceblue support team
User avatar

Sofia.Yang
 
Posts: 84
Joined: Tue Jul 14, 2020 1:41 am

Fri Dec 03, 2021 5:16 am

Hello all!

I was faced with a similar issue. SaveAsImage method is converting pdf file with single page approximately 1 minute. It's so long. Could you help me to make this process much faster? I have a license so I would like to continue using this library.

Version of Spire.PDF: 7.11.1

I attached the pdf to this message. Look at NP0-16904_1.7z, please.

Example of my code:
var pdfDocument= new PdfDocument();
pdfDocument.LoadFromStream(input);
var image = pdfDocument.SaveAsImage(0, PdfImageType.Bitmap);

Other librares:
1) I tried to use NReco.PdfRenderer. It converted to image the same pdf file in 10 seconds.
2) pdfRender from itext7 also converted to image the same pdf file in 13 seconds.

A.Repnin
 
Posts: 2
Joined: Fri Dec 03, 2021 4:49 am

Fri Dec 03, 2021 6:28 am

Hello,

Thanks for your inquiry!

I tested with the file you provided, but it just cost 11 seconds for our Spire.PDF to convert PDF page to image. Here I attached my testing code and the result on my side.

To help us reproduce your issue quickly and efficiently, please provide us with your target framework(E.g. netframework 4.8.0), your system information (E.g. Win7, 64 bit) and region setting (E.g. China, Chinese) for reference. Thanks in advance.

Code: Select all
            var pdfDocument = new PdfDocument();
            FileStream stream = new FileStream(@"E:\testdoc\NP0-16904_1\NP0-16904_1.pdf", FileMode.Open);
            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();
            pdfDocument.LoadFromStream(stream);
            stopWatch.Stop();
            long times1 = stopWatch.ElapsedMilliseconds;
            Console.WriteLine("Load cost: " + times1);

            stopWatch.Restart();
            var image = pdfDocument.SaveAsImage(0, PdfImageType.Bitmap);
            stopWatch.Stop();
            times1 = stopWatch.ElapsedMilliseconds;
            Console.WriteLine("convert cost: " + times1);


testtime.png


Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Fri Dec 03, 2021 9:03 am

Thank you for the quick reply.

Additional info:
1) Target framework: netstandard2.1
2) System: win 10, 64bit
3) Hardware: 32GB RAM, Intel Core i7-6700HQ 2.6GHz
4) Region: Europe

A.Repnin
 
Posts: 2
Joined: Fri Dec 03, 2021 4:49 am

Fri Dec 03, 2021 10:06 am

Hello,

Thanks for sharing more information!

Kindly note that our .NET Standard dll relies on the SkiaSharp to handle images, however, SkiaSharp itself is slower in processing images. We have been optimizing the speed of converting to PDF page to image, but due to SkiaSharp itself has many restrictions, it is complex and difficult to optimize it.

I recommend that you can change the framework to .net core, .net framework, net, or move the part of converting to image to the project under these frameworks to improve the speed of converting to images. Hope you can understand.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Sat May 06, 2023 4:52 am

Marcia.Zhou wrote:Hello,

Thanks for sharing more information!

Kindly note that our .NET Standard dll relies on the SkiaSharp to handle images, however, SkiaSharp itself is slower in processing images. We have been optimizing the speed of converting to PDF page to image, but due to SkiaSharp itself has many restrictions, it is complex and difficult to optimize it.

I recommend that you can change the framework to .net core, .net framework, net, or move the part of converting to image to the project under these frameworks to improve the speed of converting to images. Hope you can understand.

Sincerely,
Marcia
E-iceblue support team

After moving, I found it even more unusable because the. net6 version cannot run under Linux

henandcy
 
Posts: 4
Joined: Thu May 04, 2023 6:00 am

Sat May 06, 2023 9:41 am

henandcy wrote:After moving, I found it even more unusable because the. net6 version cannot run under Linux


Hi,

Thanks for your feedback.
Could you please share us with your test project? So that we can do a further investigation and find out a solution for you. You can send it to us via email (support@e-iceblue.com) or attach it here. Thanks for your assistance.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.PDF