Hello Aspose,
We have following simple code to open/initialize PDF document using Aspose.Pdf.Document constructor with a stream for PDF document.
this.pdf = string.IsNullOrEmpty(password) ? new Aspose.Pdf.Document(fileStream) : new Aspose.Pdf.Document(fileStream, password);
Our metrics around this code indicates that simple opening of PDF document like this can take up more than 35 minutes. We have also seen a case where this process doesn’t finish for hours. Is it possible to pass down cancellation token down to this process so that we can cancel this process if timeout limit has been reached? I saw documentation on “Interruption Token” but I wasn’t sure if this was possible with PDFs.
If not, do you have any suggestion for working around this? We understand that it’s difficult for Aspose to open up certain big/complex PDF files quickly but just want to know if we can avoid forever hanging process.
Thanks,
Jung
@jungsun.park,
Can you provide the document and the password to test this?
If this was an issue, the forum would be flooded with people complaining about this.
So my initial idea is to investigate the document. Maybe is a really big document running on a really slow machine with not enough memory. But first, I want to open the document myself and see if it takes as long as you mention.
Thank you @carlos.molina. Unfortunately, we don’t have access to the document, as typically these documents contain confidential data that can’t be shared. We just have timed metric around this call, and it shows that there were several (i.e. 5 separate PDF documents) that each took more than 25 mins.
So, are you thinking new Aspose.Pdf.Document(fileStream)
should not take this long? What happens behind the scene when we call PDF Document constructor like this?
@jungsun.park,
I have open document up to 700 mb and they do not take that long. It does take more but I would say less than a couple of minutes.
If you manage to get your hands on one of this document, you can edit the content and replace everything that is confidential and send it to me. I doubt that the text content is what is making the process slow.
Also, sadly I am not a developer, so I cannot tell you what happends behind the scene.
Edit: While helping a another user that wanted to download a 500 mb video attachment, loading the document took a bit more than a minute and saving the attachment took 12(saving attachment to disc is a slow process). So you get in perspective the time of loading a document.
Also, you maybe want to start logging the Length
of the streams before opening them to see what is the size of them. Maybe the issue has nothing to do why the size of them. Maybe is a bad encoding of the stream. Maybe the stream gets corrupted. Maybe there is a memory leak in your app and as time pass by the process gets slower and slower and it finally collapse.
I have no idea what is going on in the process prior to opening a stream but I can tell you a regular or big pdf does not take that long.
@carlos.molina
Even I don’t have easy access to these PDF files. But, I will get back to you on getting a PDF file that takes very long time to open up.
Thanks for suggestion extra logging on additional details of streams. I will look to include things like length and encoding.
In the mean time, is there any way to reach out to developer team in Aspose to know whether Aspose PDF supports taking in cancellation/interruption token when initializing/opening up a document?
1 Like
@jungsun.park,
Let me try to figure out that. I have not so far, but let you know ASAP.
@jungsun.park,
From an expert:
At this moment, Aspose.PDF does not offer this feature to interrupt the document loading if it is taking time.
I can create an investigation ticket to see if this is even feasible, but it won’t be a priority in the queue since it is not a bug. Are you interested in me doing that?
If you need this soon, you can always request Paid support which is a different team.
1 Like
Thanks for the follow up @carlos.molina
Good to know that it’s not possible to interrupt the process. We will try to investigate at different angle to see if there is another issue in the process that is causing Aspose.PDF to hang. I don’t think we need ot create an investigate ticket atm.