Problem: when we use Aspose output to save word files or PDF files, the memory will continue to increase and cannot be released. We used two versions of Aspose, Java and .Net, respectively
Project scenario: output HTML content to word file or PDF file. HTML content includes text, table, picture, SVG and other content. The content will be larger and there will be multiple output situations. The project program runs continuously in the form of service, and the output method is called when the output task is passed.
Version:Java v18.8 .Net v18.8
Demo(Java):
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(“”);
doc.save(“……/test.docx”);// doc.save(“……/test.pdf”)
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(“”);
Saveoptions saveoption = SaveOptions.createSaveOptions(SaveFormat.DOCX);
//Saveoptions saveoption = SaveOptions.createSaveOptions(SaveFormat.PDF);
saveoption.setMemoryOptimization(true);
doc.save(“……/test.docx”,saveoption);// doc.save(“……/test.pdf”,saveoption)
sos