We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert pdf to jpg slow even with page count defined

It seems to me that even though I define the page counts to be converted, it is very slow on a multi page document. It looks at though it converts the whole thing and then return just the page I want. Is it not possible to just convert the page I request? Is there something else I need to do to speed up the extraction of a single page to jpg? I am using version 4.1 of the aspose.pdf.kit dll

It seems to a similar problem to this support ticket here: http://www.aspose.com/community/forums/67380/issue-with-pdfconverter-startpage-and-endpage-properties/showthread.aspx#67380 which says is resolved but does not feel like it is.

Here is the code I am using.

PdfConverter pdfConverter = new PdfConverter();

pdfConverter.BindPdf("c:\\temp\\multi.pdf"); // an 8 page document takes approx 15 seconds to show 1 page converted

pdfConverter.StartPage = 2;

pdfConverter.EndPage = 3;

if (pdfConverter.HasNextImage())

{

pdfConverter.GetNextImage(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);

}

pdfConverter.Close();

Hi Mike,

I would like to share with you that you need to add pdfConverter.DoConvert() method after setting start and end pages. Moreover, can you please download the latest version and try it at your end? If you still find the same issue then please share the input PDF file with us, so we could test the issue at our end and see if the performance can be further improved. I would also like to add that most of the time such kind of issues depend upon the particular structure or contents of the PDF file, that’s why a sample file would be helpful.

We’re sorry for the inconvenience.
Regards,



I have added the doconvert() at the beggining without any noticeable change in performance.

1. What is the real purpose of doing that if it works without it in there?

2. I will work on getting you the sample pdf file that I am working on.

3. I will see if there is a newer version than the one I am using.

thanks.

Also, I noticed that it was much faster when i first extracted the page i wanted then converted. So, this kind of tells me that the convert is not being specific enough it would seem when the pages are specified. (still need to get back to you on some points).

Hi Mike,

I would like to inform you that DoConvert method performs some initialization tasks before conversion of pages to images. Some pages might be converted fine, however due to the variety of content types in a PDF file it is recommended to use the DoConvert method.

Moreover, please share the PDF file once it is available, so we could test the issue in detail at our end.

We’re sorry for the inconvenience.
Regards,

I have tried the latest dll 4.5 and find that it is still taking approx 20 seconds just to get one page of the document to load as a jpg. I think 20 seconds to convert one of the page seems a bit long. Not really useable at this rate.

I am attaching the document.

Here is the code I am using:

in page load:

#region Sample Converter

////create PdfConverter object and open PDF file

PdfConverter pdfConverter = new PdfConverter();

pdfConverter.BindPdf("c:\\temp\\multi2.pdf");

////set resolution

pdfConverter.StartPage = 2;

pdfConverter.EndPage = 3;

pdfConverter.DoConvert();

if (pdfConverter.HasNextImage())

{

pdfConverter.GetNextImage(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);

}

pdfConverter.Close();

#endregion

Hi Mike,

I have tested this file at my end and noticed the same situation. I have logged this issue as PDFKITNET-17759 in our issue tracking system for further investigation. Our team will look into this issue to see if the conversion speed can be further improved. You’ll be updated via this forum thread accordingly.

We’re sorry for the inconvenience.
Regards,

I have also tried this method (using pdfviewer) and found it slow as well. Are there any hints or workarounds that I could try?

PdfViewer viewer = new PdfViewer();

viewer.OpenPdfFile("c:\\temp\\multi.pdf");

Bitmap[] bmList = viewer.DecodeAllPages();

viewer.DecodePage(3).Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);

viewer.ClosePdfFile();

Oddly enough, I tried the same code on this newly attached file and it is much faster on this other pdf.

The odd thing is I am getting these results.

approx 20 seconds on the 1st file (approx 145K)

approx 7 seconds on the 2nd file (approx 445 K)

Could someone dive into this and let me know if there is something signif. different between the files?

thanks.

Hi Mike,

I would like to share with you that the conversion speed and performance relies on the type of the contents in the PDF file and the structure of the file itself. So, the files with simple structure and light contents would take less time than the ones with complex structure and content types.

I would also like to add that our team keeps improving the performance for the variety of structures and content types; the issue for this file is also logged already, and our team is working on this issue. We’ll update you once it is resolved.

We’re sorry for the inconvenience.
Regards,

The issues you have found earlier (filed as 17759) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

I'm experiencing problems using the new 4.7 version of the dlls

Here is a simplfied version of my code now:

Stream[] allFileStreams = new Stream[1]; //load all of the files inthe stream array

FileStream documentInstream = new FileStream("c:\\temp\\aspose47.pdf", FileMode.Open, FileAccess.Read);

allFileStreams[0] = documentInstream;

PdfFileEditor pdfEditor = new PdfFileEditor();

Response.ContentType = "application/pdf";

Response.AppendHeader("Accept-Ranges", "none");

pdfEditor.Concatenate(allFileStreams, Response.OutputStream);

This code used to load the pdf and output it to the browser. Now all I get is a blank window.

Has the API changed for this to work? See attached pdf for the file I am using.

Also, of note. This happens in IE8.

If I load it up in FireFox I get "File does not begin with '%PDF-'

More info:

This code works on aspose pdfkit 4.5:

PdfConverter pdfConverter = new PdfConverter();

pdfConverter.BindPdf("c:\\temp\\aspose47.pdf");

pdfConverter.StartPage = 1;

pdfConverter.EndPage = 1;

pdfConverter.DoConvert();

if (pdfConverter.HasNextImage())

{

pdfConverter.GetNextImage(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);

}

pdfConverter.Close();

AND IT does not work in version 4.7.

I get the following error with 4.7:

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:

Line 68:         PdfConverter pdfConverter = new PdfConverter();
Line 69: 
Line 70:         pdfConverter.BindPdf("c:\\temp\\aspose47.pdf");
Line 71: 

Can you help out with this asap? I'm excited to try the new "fix".

Is there any relation to this other pdf thread :

http://www.aspose.com/community/forums/249597/fileiopermission-error-when-exporting-pdf/showthread.aspx#249597

Seems to be having the similar problems as me.

Just to follow up on a chat with aspose support, please test out my code + pdf on a win 7 iis box. That is where I am having the problems.

Just to follow up with my chat with Aspose support. Please test this on a Windows 7 box. That is where I am having these issues. thanks.

Hi Mike,

We’re looking into this issue at our end. Please spare us some time and you’ll be updated with the results accordingly.

We’re sorry for the inconvenience.
Regards,

Hi Mike,

I have tested this issue on Windows 7/IIS, but couldn’t notice any problem. It looks like you’re having this issue because of insufficient permissions on the folder containing PDF file. Please assign appropriate permissions, on this folder, to the user your application is running under.

If you have any further questions, please do let us know.
Regards,

It all looks good now with the latest dlls. Thanks.