Timeout on image creation

I originally posted this on the PDF forum but got no responses.


Basically, can you add a feature to all image/thumbnail creation functions throughout Aspose (Excel, Word, Slides, PDF, etc) to set a TIMEOUT value? If the operation takes longer than the timeout, no data is returned, or perhaps an exception is thrown.

The problem we have is that some of our documents have extremely large bitmaps or vector images, and the library can take hours to create the images. We just want a timeout.

The original post asked if there were any suggestions as to implementing a workaround.

Thanks,
JM

Hi Joseph,

Thank you for contacting support. What is your development platform? You can create threads and stop the execution of code after the specified time span. Please refer to these help topics: Stop the executing of code in a thread after 30s and Create and Terminate Threads (C#)

In case, this does not help, then please provide us your code samples for each Aspose API along with the details. You may also suggest the expected code lines for each Aspose API. We’ll investigate and reply you appropriately.

Our requirement is a timeout for Java.

The code below works fine, but for some files it takes way too long. We are OK with skipping those files, or running separately.
Thanks for the help!
Here’s the PDF code:

try {
ByteArrayOutputStream output_stream = new ByteArrayOutputStream();
JpegDevice jpg_device = new JpegDevice(300,(int)(300h_to_w_ratio),
new Resolution(180,(int)(180h_to_w_ratio)),70);
jpg_device.process(page, output_stream);
byte[] imageInByteArray = output_stream.toByteArray();
output_stream.close();
thumbnail_data = javax.xml.bind.DatatypeConverter.printBase64Binary(imageInByteArray);
} catch (IOException e) {}

Hi Joseph,


Thank you for the details. You can set timeout for the code of lines in Java. There are various ways. Please refer to these help topics: Simple Timeout in the Java and Set Timeout on a Certain Block of Code

Thanks - yes that was what I was going to try.

I was curious if an enhancement to the library could be added to simplify the operation.
Also - I was wondering if the library could be put in a corrupt state if such a wrapper was implemented.
I will assume it’s ok…

Thanks - JM
Hi Joseph,

Thank you for the details. My fellow worker has already logged a feature request in perspective of the Aspose.Pdf API in this forum thread. In reference to the other Aspose APIs, please provide code snippet for each Aspose API which you're actually using in your application projects. It'll help us to incorporate the features which you really required. Your response is awaited.