We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Performance degradation in export PDF, in docx with customXml

Hi,

We open with Aspose a docx with many placeholders, and then we load a customXml containing many values, the bind is quite fast 300 millis, but the export in pdf format in so slow 25 sec. If we make the same test, with the same docx but without placeholders TAGS, the export run more fast: 2 sec.

We want to ask, if threre are any parameter in Document to “normalize” the docx (remove placeholders with the values)? Or any PdfSaveOptions for fasterize the export?

Aspose: aspose-words-21.4.0-jdk17.jar

with javaSE 1.8.41
VM Arguments: -Xms1g -Xmx1g -XX:NewRatio=3 -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:G1HeapRegionSize=4m
documentTemplate.docx
load docx template: (1010 millis)
load customXml: (13 millis)
bind values: (357 millis)
export pdf: (24584millis)
total: (25964 millis)

with jdk15.0.1.9 timing is better
VM Arguments: -Xms1g -Xmx1g -XX:NewRatio=3 -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:G1HeapRegionSize=4m
documentTemplate.docx
load docx template: (1563 millis)
load customXml: (6 millis)
bind values: (150 millis)
export pdf: (16742 millis)
total: (18463 millis)

If anyone want more info, I will replay.

Cordially, Pierfrancesco

@p.caporello,

Please upgrade to the latest (21.6) version of Aspose.Words for Java and see how it goes on your end? In case the problem still remains, then please compress the following resources into ZIP format and attach the .zip file here for testing:

  • Your simplified source Word document
  • Custom XML containing values for placeholders
  • Please also create a standalone simplified Java Application (source code without compilation errors) that helps us to reproduce this performance issue on our end and attach it here for testing. Please do not include Aspose.Words JAR files in it to reduce the ZIP file size.

As soon as you get these pieces of information ready, we will then start investigation into your issue and provide you more information.

Ciao @awais.hafeez,

I’ve tried with 21.6 Aspose version, but I’ve not found significative differences.

I upload a simple java application to reproduce the issue.
docxtemplate2pdf.zip (1.2 MB)

I attend your answer.

Pierfrancesco

@p.caporello,

We are working on your query and will get back to you soon.

Hi @awais.hafeez, there are news about this query?

Have you had the chance to test the application I sent you?

A greeting,
Pierfrancesco

@p.caporello,

You are right; the entire processing of “DDS-CBI-PA.final.final.docx” document takes 21 second on our end on a Windows 10 machine when running your code with latest (21.6) version of Aspose.Words for Java over JDK 1.8. We have logged this problem in our issue tracking system. Your ticket number is WORDSJAVA-2610. We will further look into the details of this problem and will keep you updated here on the status. We apologize for your inconvenience.

Thanks for your reply @awais.hafeez,

while we wait for your solution, I wanted to ask you if you know the way to “normalize” the docx, replacing the placeholders with their respective values, that is, eliminating any reference to customXml, and importing the final values instead of the StructuredDocumentTag.

I tried to write this code, but I still haven’t succeeded:

NodeCollection<StructuredDocumentTag> stdList =
		docxFinal.getChildNodes(NodeType.STRUCTURED_DOCUMENT_TAG, true);
		
// TODO: normalize docx, removing placeholders
stdList.forEach(std -> {
	try {
	        CompositeNode parent = std.getParentNode();

		Node firstChild = std.getFirstChild();

		if (firstChild != null)
			parent.insertBefore(firstChild, std);
		std.remove();
	} catch (RuntimeException e) {
		log.error(e.getLocalizedMessage(), e);
	}
});

this implementation could be a temporary workaround to reduce pdf save time.

let us know, thanks

Pierfrancesco

@p.caporello,

We have logged you query in our issue tracking system and will keep you posted here on any further updates.