Hello,
Thanks for your feedback.
Based on the code you provided, we found that it is not that the deep clone method is more memory efficient than instantiating a new Document object. In addition, there are some uncontrollable stylistic errors using the deep clone method, we do not recommend you to use the deep clone method. Therefore, please modify your code to the following code.
- Code: Select all
for (int i = 0; i < 701; i++) {
Document document = new Document();
InputStream inputStream = App.class.getClassLoader().getResourceAsStream("template.docx");
document.loadFromStream(inputStream, FileFormat.Docx);
//merge data
try (OutputStream outputStream = new FileOutputStream(String.format("%s.pdf", i))) {
invoiceDoc.saveToStream(outputStream, FileFormat.PDF);
} catch (Exception exception) {
exception.printStackTrace();
}
});
Sincerely,
Annika
E-iceblue support team