Aspose-generated file size increases considerably when modified and saved in word

Hi,

I have a problem. Please, can you help me?
My system generates a word file using the Aspose library, but that file increases considerably when it is changed and saved in Microsoft Word.

Following is attached two files in a zip file, the file being generated by Aspose and the same file after being changed and saved in Word.
The difference between the files is only one character added to the text.

The file “File generated by Aspose.docx” has 2.767kb and the file “File Saved Word.docx” has 3852kb, increase of 39%! :scream:
Another file of 36mb, after save on Word, increases the size to 51mb. :roll_eyes:

Why does it happen? What can be done to solve the problem?

My method to generate the file using Aspose is:

private byte[] saveDoc(Document doc) throws Exception, IOException {
	ByteArrayOutputStream bos = new ByteArrayOutputStream();
	
	doc.cleanup();
	doc.save(bos, SaveFormat.DOCX);
	bos.flush();
	byte[] retorno = bos.toByteArray();
	bos.close();

	return retorno;
}

The Aspose Library is: aspose-words-19.9-jdk17.jar

I tried somethings from de Aspose Forum, but without success.

Regards.
Example.zip (5.8 MB)

@Daiana_Dionizio

Could you please attach your input Word document here for testing? We will investigate the issue on our side and provide you more information.

Thanks for the answer!

Both word files are in the attached zip file.
Example.zip (5.8 MB)

@Daiana_Dionizio

As per our understanding, you are creating the document using Aspose.Words. After creating the document, you re-save the document using MS Word and it increases the size of document. Please let us know if our understanding is incorrect.

Please create a simple Java application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing. We will investigate the issue and provide you more information on it. Thanks for your cooperation.

That’s exactly what’s happening! When I re-save the document using MS Word, it increases the size of document.

Ok! I will create a java project to exemplify the problem and I will post it here.

@Daiana_Dionizio

Please share the code example to reproduce this issue at our end. We will investigate the issue and provide you more information on it.

Hi!

I created a simple java project to simulate what is happening. For security reasons, the aspose license file was not included in the project.

The project contains 3 java files:

  • Generator.java - The main class
  • DocXProcessorAspose.java - Class for handling aspose objects
  • FormatNotSupportedException.java - Exception Class

How the project works:

  • Step 1 - Program reads Template.docx and Content.docx files
  • Step 2 - Then makes the merge
  • Step 3 - Finally generates the file NewFileFromAspose.docx

Aspose.png (28.9 KB)

The NewFileFromAspose.docx file generated by Aspose has 878kb. After opening it in word and re-save with the name FileSavedWord.docx, the new file has 1363kb.

All files are included in a zip file, except aspose-words-19.9-jdk17.jar. Please put the aspose-words-19.9-jdk17.jar inside libs folder to run the project.

Aspose.zip (4.4 MB)

@Daiana_Dionizio

You are using Aspose.Words in evaluation mode. Please get the 30 days temporary license and apply it to fix this issue. Please let us know if you have any more queries.

The company I work for bought the license. In production environment we are using it and unfortunately the same problem is happening. :disappointed_relieved:

@Daiana_Dionizio

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-19348. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@Daiana_Dionizio

Thanks for your patience. It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-19348) as ‘Not a Bug’.

DOCX created by Aspose.Words is smaller than re-saved DOCX using MS Word. Please unzip both documents, you will notice that the size of directories are almost same.

MS Word DOCX contains footnotes.xml (3 kb) and endnotes.xml (3 kb), which Aspose.Words does not write. Apparently Word uses an algorithm with less compression.