Page 1 of 1

Document size decreases after saveToZipFile

PostPosted: Wed Jan 22, 2014 6:00 am
by andyflint
Hi

Am using docx4j to update properties and fields withing documents as they are being checked into a document management system called Documentum.

Have noticed that the documents are considerably smaller after being save to zip but the document appears to be visibly the same can someone please provide a possible explanation for this and what is being lost.

Below is that code that I am using to save the file to zip and convert to a bytearray

Code: Select all
   private ByteArrayOutputStream convertToByteArray()  {

      SaveToZipFile saver = new SaveToZipFile(wordML);

      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      saver.save(baos);
      return baos;
   }

Re: Document size decreases after saveToZipFile

PostPosted: Tue May 05, 2020 8:46 am
by jason
Very belated reply, just for content curation purposes. Please see docx-java-f6/file-size-differences-t1091.html

Re: Document size decreases after saveToZipFile

PostPosted: Wed May 06, 2020 6:13 pm
by ashanaik
Hi Jason

Your second point for the issue :

2. namespaces
docx4j (JAXB) always writes all namespaces in the relevant JAXB context, which makes the file a bit bigger.

Is there any way to handle this ? Can we remove the namespaces?

Thanks !