Differences between .docx rendering between Ubuntu and Mac OSX

We have automated test cases comparing docx files generated by Aspose.Words Java and compared by using Aspose.Words Java as well (the document comparison features which gives you the number of revisions). They fail when run on mac osx (they were created on an ubuntu system).

Testcode:

try
{
    final var doc = new Document();
    final var builder = new DocumentBuilder(doc);
    builder.startTable();
    builder.insertCell();
    builder.write("test");
    builder.endRow();
    builder.endTable();
    doc.save("document.docx");
}
catch (Exception e)
{
    throw new RuntimeException(e);
}

Running this code on an Ubuntu system results in document_ubuntu.xml (see attached zip file). Running this code on a Mac OSX system results in document_macosx.xml (see attached zip file). If you diff those two files you’ll see that w:pgMar, w:cols and w:gridCol have different values. Why is that? Is there a workaround perhaps for running tests on both operating systems without them failing?

Mac system:
Java: Zulu 11.0.19
MacOS: 13.4.1
Chip: Apple M2 Max

Linux system:
Java: openjdk 11.0.19 2023-04-18
Ubuntu 22.04.2 LTS

documents.zip (15.0 KB)

@inventageaspose Unfortunately, I cannot reproduce the problem on my side. I have checked on Windows, Linux and Mac on my side and the output is the save as your Ubuntu output. I have inspected your documents and noticed DOCX generated on Mac has different page margins, that affects the table grid calculation. Could you make sure your code does not change page margins? The difference is also seen in MS Word.

Did you test on a Mac that has a newer ARM based processor? Perhaps that’s the issue?

Okay, I’ll try to set the page margins explicitly. I didn’t do anything more than the code I sent you does.

@inventageaspose I have tested on Mac with Intel processor. Unfortunately, I do not have a device with ARM processor to test the scenario. I will consult with our Java developers and provide you more information.

Yes, please do. If you need us to run some test code on our ARM Mac books, feel free to say so.

@inventageaspose Thank you for cooperation. One of my colleagues from Aspose.Words for Java sub-team owns a Mac on M2 CPU. It might take some time to configure it for testing, we will keep in touch with you and let you know the results.

1 Like

@inventageaspose We have tested the scenario on MacOS with M2 CPU and unfortunately, we still cannot reproduce the problem. Here is DOCX document produced on our side: out.docx (7.3 KB)
The document is identical with the document generated on Ubuntu on your side.

The documents look identical but using Document.compare() and printing the revisions leads to at least one difference.

Here’s the diff of the extracted documents, the document.xml to be exact:

Comparing our ubuntu document.xml with the one you just uploaded gives back 5 revisions, e.g. 5 differences, when there should be none.

@inventageaspose I see the different in document.xml between the attached output DOCX produced on M2 and document.xml from document_macosx.docx, but see no difference with document_ubuntu.docx.
Anyways we will continue testing Aspose.Words on M2 CPU.

I’m not sure I understand. I download your document, extracted the document.xml and diffed it by using IntelliJ and the screenshot I pasted is the result. There’s clearly a difference int he values in the sectPr. Unless I’m missing something?

@inventageaspose You understood correctly, I do the same, but compare using SVN Diff tool: the document.xml extracted from the document generated by Aspose.Words on M@ CPU on our side and document.xml extracted from your document_ubuntu.docx are the same.

My bad, I must have used the wrong file for comparison.

Can you share your environment maybe? What Java Version did you use?

@inventageaspose The developer, who tested the scenario on M2 CPU is currently on vacation. I will let you know the configuration once I get response from him. Please accept our apologies for the inconvenience.

Hi @inventageaspose

I checked my Mac system:
Java: Zulu 11.0.19
MacOS: 13.4.1
Chip: Apple M2
Aspose Words: 23.6