Aspose PDF save method stuck permanently

Hi,
I am struggling with the ASPOSE pdf, document.save method, here its getting saved to a stream.
For the below code whenever the html fragment gets added in document object the doc.save method gets stuck forever.
Here processedHtml is a string html.
Document doc = new Document();
HtmlFragment htmlFragment = new HtmlFragment(processedHtml);
HtmlLoadOptions options = new HtmlLoadOptions();
// Set Print or Screen mode
options.setHtmlMediaType(HtmlMediaType.Screen);
htmlFragment.setHtmlLoadOptions(options);
doc.getPages().add().getParagraphs().add(htmlFragment);
doc.getPages().get_Item(1).getPageInfo().setHeight(11000);
// Save the document to a memory stream
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
doc.save(outputStream);
The control never gets beyond doc.save method, the program is stuck at doc.save method.
// Get the byte array from the output stream
byte[] pdfBytes = outputStream.toByteArray();

I am using java 17, -Xms3000m -Xmx3500m, it’s part of spring boot. The aspose version for pdf that I have tried : 23.12, 23.7, 21.1, for all of these versions the control is getting stuck when doc object is copying the data to memory stream. I have tried increasing the memory, codec buffer nothing helped.

My most of the productivity time gets into fixing such ASPOSE ISSUES.

PLEASE SUGGEST THE FIX ASAP.

@arindam.mishra

We tested the code snippet with both JDK 17 and JDK 1.8 but could not reproduce the issue that you mentioned. We used 24.1 version of the API. Can you please try using it and if issue persists, please share a sample console application for our reference in .zip format so that we can again test and address it accordingly.

I can see the very latest version is 23.12, at Aspose.PDF | Java PDF Document Processing Class Library. I am using aspose-pdf api.

@arindam.mishra

Please check and download the latest version from this link. You can also update your pom.xml accordingly.

Im actually seeing the same issue, but its very sporadic.
im using Aspose.PDF 24.2 for .NET Framework.

Aspose.Pdf.Document and the method Save just get stuck in the process and no exception or anything occurs.

its also HTML to PDF saving.

@xSuiteNordic

It would be great if you could provide a sample console application with the sample source file. We will use it to replicate the issue in our environment and address it accordingly.

Sadly I can not re-produce this error it happens once a day.
If I restart my job of HTML to PDF conversion then it works again.

we load the HTML file into the pdfdocument
pdfDocument = new Aspose.Pdf.Document(_htmldocumentStream, loadOptions);

and the system stops responding when calling save
pdfDocument.Save(pdfDocumentStream, saveFormat);

@xSuiteNordic

Is it possible that you are calling some other program routine in the meanwhile as well that could cause stop the execution of the main thread? Please try to log the process at as many levels as you can to find out the actual root cause. Maybe it is some specific HTML? If so, please share that with us so that we can proceed accordingly.

I have been doing a lot of logging and also checked other processes running in the background, but as long as I cant re-produce this problem, I cant catch the error.
the problem still exists at the client and after processing of 100->400 conversions it suddenly stops working.

im not sure what else to do here other than creating an task await, calling the pdf.document. save method and use a timeout solution. not a proper solution but so far the only way to handle this issue.

@xSuiteNordic

As far as the issue is concerned, it is quite hard for us to suggest any workaround or solution without replicating it in our environment. If there is slight a chance that you could share some steps with us to reproduce the issue in our environment, we would definitely generate an investigation ticket to address it accordingly.

A post was split to a new topic: Save call is stuck while adding Html Fragment