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.

Fri Jun 05, 2026 3:17 pm

Good Day Spire Team

We have a question in regards to pdfDocument.SaveAsImage(pageNumber, PdfImageType).
We are using Spire to load PDF files and then render the resulting Bitmap using WPF.

Depending on what is loaded, the SaveAsImage method takes quite a bit of time, especially when using a vector PDF (construction plan specifically).

What are your recommendations to optimize the performance?
Would there be a better option to render the PDF in WPF?

If required I can provide a PDF file that takes about 6 seconds to load.

All the best

sgerber
 
Posts: 32
Joined: Tue Nov 07, 2017 10:21 am

Mon Jun 08, 2026 3:12 am

Hello,

Thank you for reaching out to us.

Could you please let us know which version of Spire.PDF you are currently using? Also, to help us reproduce and investigate the performance issue, please share the specific PDF document along with the code you're using for the rendering.

Your assistance with this is greatly appreciated.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3043
Joined: Wed Jun 27, 2012 8:50 am

Mon Jun 08, 2026 5:23 am

Good Morning

The Spire.PDF Version used is 12.5.8.

I am able to supply a PDF, however I cannot upload it to the forum.
Is there any way to provide it more directly?

The test code is available below.

Code: Select all
var stopwatch = new System.Diagnostics.Stopwatch();
stopwatch.Start();

using (var pdfDocument = new PdfDocument(openFileDialog.FileName))
{
    var bitmapImage = pdfDocument.SaveAsImage(0, Spire.Pdf.Graphics.PdfImageType.Bitmap, 96, 96);
}

stopwatch.Stop();
System.Diagnostics.Debug.WriteLine($"Variant 1:   {stopwatch.ElapsedMilliseconds} ms    /    {stopwatch.ElapsedTicks} ticks");

sgerber
 
Posts: 32
Joined: Tue Nov 07, 2017 10:21 am

Mon Jun 08, 2026 5:38 am

Hello,

Thank you for your prompt reply.

Please send the requested PDF document and your code to our support email at mailto:[email protected].

Thank you for your assistance.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3043
Joined: Wed Jun 27, 2012 8:50 am

Mon Jun 08, 2026 6:31 am

Hi Amy,

I have sent an email containing code, short description and 3 PDFs attached.

sgerber
 
Posts: 32
Joined: Tue Nov 07, 2017 10:21 am

Mon Jun 08, 2026 8:29 am

Hello,

I’ve received your email. Thank you.

I tested the processing time for your three PDF documents using version 12.5.8.1360 in my local Windows 10 environment.

Here are the results:
00-erdgeschoss.pdf: 47ms to load the PDF; 947ms from loading to completing the image conversion.
PDF-Performance-Default.pdf: 50ms to load the PDF; 9,047ms from loading to completing the image conversion.
PDF-Performance-RGB.pdf: 45ms to load the PDF; 9,169ms from loading to completing the image conversion.

In your email, you mentioned that it took 700ms just to load the 00-erdgeschoss.pdf document. Could you please clarify if this 700ms refersonly to the execution time of var pdfDocument = new PdfDocument(file), or does it include the total time from loading the document all the way to completing the image conversion?

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3043
Joined: Wed Jun 27, 2012 8:50 am

Mon Aug 03, 2026 7:17 am

Hi Amy

Just to be sure that the reply has reached you:

In the email I sent the code that I measured.
Code: Select all
using (var pdfDocument = new PdfDocument(openFileDialog.FileName))
{
   var stopwatch = new System.Diagnostics.Stopwatch();
   stopwatch.Start();

    var bitmapImage = pdfDocument.SaveAsImage(0, Spire.Pdf.Graphics.PdfImageType.Bitmap, 96, 96);

    stopwatch.Stop();
    System.Diagnostics.Debug.WriteLine($"Variant 1:   {stopwatch.ElapsedMilliseconds} ms    /    {stopwatch.ElapsedTicks} ticks");
}

Only the pdfDocument.SaveAsImage() is measured by the Stopwatch.

All the best,

sgerber

sgerber
 
Posts: 32
Joined: Tue Nov 07, 2017 10:21 am

Mon Aug 03, 2026 7:57 am

Hi sgerber,

I received your email on June 8th and replied with the following:

Using your code, I tested the time it takes to convert the documents to images, and the results are as follows:
    00-erdgeschoss.pdf: 836ms
    PDF-Performance-Default.pdf: 8860ms
    PDF-Performance-RGB.pdf: 8813ms

Additionally, I have logged an optimization task for the image conversion process under the ticket number SPIREPDF-8090. Our development team will conduct a detailed investigation to optimize this. I will keep you updated on any progress.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3043
Joined: Wed Jun 27, 2012 8:50 am

Mon Aug 03, 2026 8:00 am

Regarding SPIREPDF-8090, our developers have achieved an initial optimization of approximately 15%. Please note that further significant improvements will require more time. Would you like us to provide you with this 15% optimized version first?


Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3043
Joined: Wed Jun 27, 2012 8:50 am

Mon Aug 03, 2026 9:04 am

Hi Amy

Thanks a lot for your very quick response, very glad to hear.

No need for the initial optimizations, we will wait.
I assume these improvements will find their way into one of the updates in the near future, so no need to create an extra bundle.

Best regards,

sgerber

sgerber
 
Posts: 32
Joined: Tue Nov 07, 2017 10:21 am

Tue Aug 04, 2026 8:51 am

Hi sgerber,

Thank you for your prompt reply.
We will keep you posted as soon as the update is available. Please feel free to reach out if you have any other questions in the meantime.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3043
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF

cron