Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further support for w:jc/w:val = start and end #608

Open
wants to merge 1 commit into
base: VERSION_11_5_2
Choose a base branch
from

Conversation

benht-nps
Copy link

Loading a docx file in docx4j with a justification style (w:jc/w:val) set to the values "start" or "end" results in the w:val attributes being removed in styles.xml, which MS Word treats as an error on startup.
Adding them to JcEnumeration is enough to fix.

@plutext
Copy link
Owner

plutext commented Mar 10, 2025

Hi Ben, do you know how such docx files are being created (ie what application inserts those values)?

@benht-nps
Copy link
Author

Hello,
The easiest way to create it is with LibreOffice. (I'm probably not on the latest admittedly, 24.2.5.2).
Styles -> Edit Style -> Options: Right, and it sets w:jc w:val to "end" in styles.xml.

I thought was a bug until I saw it's actually supported elsewhere (eg https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.justificationvalues and supported already in docx4j eg Justification.java).

I tried to trace where docx4j was stripping out the w:val, it's when we call wordprocessingMLPackage.getDrawingPropsIdTracker().generateId(); and I assume the bit in that where JaxbXmlPart.getContents() calls unmarshal which is where I lost the thread unfortunately, but adding start and end to JcEnumeration makes it work. Using docx4j-JAXB-MOXy in case that affects anything.

Thankyou for docx4j in generate btw :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants