again me with a problem A few weeks ago i tried to bind checkboxes in my docx-document. Worked fine...
Yesterday i created a bigger document (6 pages) with many bound fields (texts and checkboxes). I did the bind with docx4j but all my checkboxes have been replaced with "true" or "false" texts
So, back to the tests a few weeks ago... they still worked. I created another testdocument and it didn't work there too... after some tests and many trials i have two nearly ident docx-files, the ident xml data file and the ident sourcecode but one time the checkbox bind works fine, another time not.
Here is the source:
- Code: Select all
String input_DOCX = "C:/tmp/doctest/checkboxtest.docx";
//String input_DOCX = "C:/tmp/doctest/checkboxtest2.docx";
String input_XML = "C:/tmp/doctest/xmldatawritertest.xml";
// resulting docx
String OUTPUT_DOCX = "C:/tmp/doctest/OUT_test.docx;
// Load input_template.docx
WordprocessingMLPackage wordMLPackage = Docx4J.load(new File(input_DOCX));
// Open the xml stream
FileInputStream xmlStream = new FileInputStream(new File(input_XML));
Docx4J.bind(wordMLPackage, xmlStream, Docx4J.FLAG_BIND_INSERT_XML | Docx4J.FLAG_BIND_BIND_XML);
// Save the document as docx
Docx4J.save(wordMLPackage, new File(OUTPUT_DOCX), Docx4J.FLAG_NONE);
checkboxtest.docx works fine, checkboxtest2.docx doesn't. The funny thing is, if i click in generated docx of checkboxtest2.docx on the left side of the checkbox MS Word 2010 crashes or switches the text to a checkbox?!
Very strange... any idea? Is there a better way to bind checkboxes?