Page 1 of 1

Exception executing custom property update

PostPosted: Tue Nov 21, 2017 3:35 am
by bs_dellacqua
We are using docx4j 3.3.3 updated with the following correction ...
We have a docx (see attached file CustomPropertyUpdateProblemTmp2.docx) which contains the following custom property
<_SUPPLIER_DATA_ELEMENT_15.10.2008 (parametr long long long long long long long/>
with value "long parameter name";
we need to convert this docx into pdf using the following code

public static void main(String[] args) throws Exception {

String regex = null;

String inputfilepath = System.getProperty("user.dir") + "/pdf/CustomPropertyUpdateProblemTmp2.docx";
String outputfilepath = System.getProperty("user.dir") + "/pdf/CustomPropertyUpdateProblemTmp2.pdf";

WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File(inputfilepath));

// Refresh the values of DOCPROPERTY fields
FieldUpdater updater = new FieldUpdater(wordMLPackage);

// All methods write to an output stream
OutputStream os = new;

System.out.println("Attempting to use XSL FO");

Mapper fontMapper = new IdentityPlusMapper();

PhysicalFont font = PhysicalFonts.get("Arial Unicode MS");

FOSettings foSettings = Docx4J.createFOSettings();
foSettings.setFoDumpFile(new File(inputfilepath + ".fo"));

Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);

System.out.println("Saved: " + outputfilepath);


but when is executed the statement
we have the following exception

Exception in thread "main" org.docx4j.model.fields.FieldValueException: No value found for DOCPROPERTY "<_SUPPLIER_DATA_ELEMENT_15.10.2008 (parametr long long long long long long long/>"
at org.docx4j.model.fields.docproperty.DocPropertyResolver.getValue(
at org.docx4j.model.fields.FieldUpdater.updateComplex(
at org.docx4j.model.fields.FieldUpdater.updatePart(
at org.docx4j.model.fields.FieldUpdater.update(
at carlo.pdf.DocxToPdfTmp.main(

The reason of the exception is that in the statement
value = docPropsCustomPart.getProperty(key);
search for the key <_SUPPLIER_DATA_ELEMENT_15.10.2008 (parametr long long long long long long long/> but the called method returns null.
The problem seems to be that the value of string key passed to getProperty is
"<_SUPPLIER_DATA_ELEMENT_15.10.2008 (parametr long long long long long long long/>"
(between starting and anding ") and this doesn't match with the original property name.

Does anyone know if it is correct the syntax of the name of the property and if it is possible to correct this wrong behavior ?

Re: Exception executing custom property update

PostPosted: Fri Nov 24, 2017 1:31 am
by bs_dellacqua
The problems seems to be a wrong management of custom properties with the name containing spaces; this can cause the exception or a wrong update of the property value;
the parsing of custom property name is done in class FldSimpleModel, method splitParameters;
to solve temporary our problem we have changed the code where we insert our custom property but we think that this could be a more general problem.