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

Free Support Forum - aspose.com

High RAM when converting PDF to JPG

Hi,

I have used Aspose PDF (11.8.0.0) to convert the attached infected pdf to jpg. While converting, my computer's memory (RAM) reached at least 60 MBs although input file's size is small (< 0.6 MB).

These attached files is opened by Foxit with no error. Is there any way to optimize CPU and RAM usage when converting from PDF to JPG? My code is

public bool ConvertToImage(String input, String output)
{
try
{
Document pdfDocument = new Document(input);
// Create Resolution object
Resolution resolution = new Resolution(100);
String extension = Path.GetExtension(output);
// Create folder fileName to contains all converted images (output_1.*, output_2.*)
Directory.CreateDirectory(output);
ImageDevice imageDevice = null;
imageDevice = new JpegDevice(resolution, 100);
for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
{
try
{
using (FileStream imageStream = new FileStream(Path.Combine(output, "page" + '_' + pageCount + extension), FileMode.Create))
{
// High load
imageDevice.Process(pdfDocument.Pages[pageCount], imageStream);
imageStream.Close();
}
}
catch
{
continue;
}
}
}
catch (Exception e)
{
Console.WriteLine("ERROR: Failed to convert PDF file to " + targetType + ". " + e.Message);
return false;
}
return true;
}

Hi long,


Thanks for using our API’s.

I have tested the scenario and have managed to reproduce same problem. For the sake of correction, I have logged it as PDFNET-41271 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

Hello,

I have been having the same problem when converting PDF to JPG. Has this problem been fixed yet?
If not, that is fine. However, if this is the case, do you know of some way that I can detect when this will be an issue so that I can have the program skip over it instead of the program just failing?
Thank you!
Rachel

Hi Rachel,


Thanks for contacting support.

The high memory consumption may occur when we are try to use a PDF document of high complexity and it also depends upon the structure of input document. Now concerning to earlier reported issue, it is pending for review and is not yet resolved. However we request you to please share the input document, so that we can test the scenario in our environment. We are sorry for this inconvenience.

Hello!


Thank you for your quick response!

What is the best way to share a 12 MB document with you?

Please let me know if you can find a way to detect that this will be a problem before it actually does.

Thank you!
Rachel

Hi Rachel,


Thanks for contacting support.

You can upload the input document within this forum thread or you may consider uploading it to some free file sharer and share the link with us.


Hi,

I have attached the file.

I have also tried to optimize it, the file is too big to do this as well.

Please let me know what you find out!

Thanks!
Rachel

caterm51:
Hi,
I have attached the file.

I have also tried to optimize it, the file is too big to do this as well.

Please let me know what you find out!

Thanks!
Rachel
Hi,

Thanks for using our API’s.

I have tested the scenario and have managed to reproduce same problem. For the sake of correction, I have logged it as PDFNET-42831 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

Thank you for you cooperation!


Please let me know if you make any headway!

Hi,


As soon as we have some definite updates, we will let you know.