VariablePrepare cause trouble in a new doc
Posted: Mon Jun 19, 2017 7:26 pm
Hi,
Sorry Jason I duplicate my topic from Stackoverflow: https://stackoverflow.com/questions/44458760/docx4j-variable-prepare-cause-trouble-when-open-a-saved-docx but I will add more info here.
So I need to use variablePreapre() to regroup my variable (they look like that: $variable$), and when I open my new docx there is a Word error:
But Word can repear easily, so it's not a big problem.
After that I tried with a blank document, juste created and saved without any change the document is attached at this post (test.docx).
This is my code:
And I attach also the created docx at this post (result.docx).
At the end I try my code without the
I don't know how to fix it, at the beginning I think the problem was my variable but it doesn't work with the any document ..
Thank's you for your help
Sorry Jason I duplicate my topic from Stackoverflow: https://stackoverflow.com/questions/44458760/docx4j-variable-prepare-cause-trouble-when-open-a-saved-docx but I will add more info here.
So I need to use variablePreapre() to regroup my variable (they look like that: $variable$), and when I open my new docx there is a Word error:
We're sorry. We can't open result.docx because we found a problem with its contents.
The XML data is invalid according to the schema.
Location: Part:/word/document.xml, Line: 0, Column: 0
But Word can repear easily, so it's not a big problem.
After that I tried with a blank document, juste created and saved without any change the document is attached at this post (test.docx).
This is my code:
- Code: Select all
WordprocessingMLPackage wordMLPackage = Docx4J.load(new File(directory+fileName));
VariablePrepare.prepare(wordMLPackage);
wordMLPackage.save(new java.io.File("result.docx") );
And I attach also the created docx at this post (result.docx).
At the end I try my code without the
- Code: Select all
VariablePrepare.prepare(wordMLPackage)
I don't know how to fix it, at the beginning I think the problem was my variable but it doesn't work with the any document ..
Thank's you for your help