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.

Mon Jul 14, 2014 5:23 pm

Most PDF's convert to images quickly.

The currently attached PDF takes a very long time (a few minutes per page). Is there anything that can be done?

Here is the code I'm using:

using (var doc = new PdfDocument())
{
doc.LoadFromStream(stream);

for (var pageCount = 0; pageCount < doc.Pages.Count; pageCount++)
{
using (var img = doc.SaveAsImage(pageCount, PdfImageType.Metafile, 150, 150))
{
using (var ms = new MemoryStream())
{
if (rpt.Watermark)
{
using (Graphics G = Graphics.FromImage(img))
{
G.DrawString(rpt.WatermarkText, footFont, new SolidBrush(Color.FromArgb(opacity, Color.Black)), 0, img.Height - 20);
img.Save(ms, ImageFormat.Png); //saving before Graphics is disposed
}
}
else
{
img.Save(ms, ImageFormat.Png);
}
}
}
}
}

patness
 
Posts: 10
Joined: Tue Jul 08, 2014 12:15 am

Tue Jul 15, 2014 1:36 am

Hello,

Thanks of your inquiry.
Sorry that there is no file in the attachment. kindly note that please zip it before uploading or you can send it to our Email(support@e-iceblue.com).
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue Jul 15, 2014 4:33 pm

When I try to attach the zip, I get this message:

Sorry, the board attachment quota has been reached.

You can try getting it from here:
https://www.dropbox.com/s/obyjxuwdi28wm ... 29.pdf.zip

patness
 
Posts: 10
Joined: Tue Jul 08, 2014 12:15 am

Wed Jul 16, 2014 3:18 am

Hello,

Thanks for your valuable information. The issue has been posted to our Dev team, once there is any update, we will let you know.
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Sun Aug 11, 2019 1:44 pm

Hello, thanks!

Ellenvusia
 
Posts: 1
Joined: Sun Aug 11, 2019 12:45 pm

Mon Aug 12, 2019 2:20 am

Hi Ellenvusia,

Thanks for your inquiry.
The issue patness reported was already solved. If you encounter the similar issue, please download the latest Spire.PDF Pack(Hot Fix) Version:5.8.2 and have a try.
If the issue still happens, please provide your input PDF and the code you were using.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Sep 18, 2019 12:38 pm

Dear support team

I just downloaded the latest Spire.PDF Pack(Hot Fix) (5.9.6) but unfortunately I can still reproduce this issue.
The attached PDF takes several minutes to convert.

My code:

Code: Select all
//...
var image = pdfDocument.SaveAsImage(0, 300, 300);
var bitmap = new System.Drawing.Bitmap(image);
//...


Could you please have a look at this?

Thanks and regards

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

Thu Sep 19, 2019 2:29 am

Hi,

Thanks for your inquiry.
After further investigation, we found there is an error when saving your document to images directly via Adobe. And the image in your file is too big, I am afraid at present there is no good way to improve the speed of conversion. Anyway, if there is any good news in the future, we will let you know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu Sep 19, 2019 6:18 am

Okay, thank you anyway.

Workaround:
I printed the PDF with a PDF-Printer and after that step, the resulting PDF was "normal" and could be converted to an image.

Regards

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

Thu Sep 19, 2019 9:58 am

Hi,

Thanks for sharing the workaround.
Could you please provide your "normal" PDF so that we could check the speed of the conversion?

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu Sep 19, 2019 11:16 am

Please see the attached PDF (created with PDFCreator).

Thanks and Regards

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

Fri Sep 20, 2019 1:52 am

Hi,

Thanks for sharing.
Your new file will not throw the error when saving with Adobe. After testing your new file with Spire, I found the conversion cost about 5 seconds, it is faster. Please use this new file.
If there is any other question, welcome to get it back to us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF