Page 1 of 1

Word 2013 invoice sample broken?

PostPosted: Sat Apr 23, 2016 3:31 am
by jason.r.berk
I'm trying to setup a simple binding with conditionals using the OpenDope authoring tool in Word 2013 (see screen shot below). I was reading the getting started doc from docx4j and it referenced the invoice samples here: https://github.com/plutext/docx4j/tree/master/sample-docs/word/databinding and the sample code here: https://github.com/plutext/docx4j/blob/master/src/samples/docx4j/org/docx4j/samples/ContentControlBindingExtensions.java

when I try to use the invoice2013 file (which I assume I need to use given my Word version), it appears Word considers the file corrupt. when I tried to use the invoice.docx file, the same errors occur.

I have a case where I need to show something like:

{{business name}}
{{doing business as}} // conditionally, if this company has a "DBA" field in the DB
{{mailing address}}

if the business is not DBA, then I would expect output like this (notice there is no blank line....the content is removed...not just invisible):

{{business name}}
{{mailing address}}

I can't seem to find anything online that deals with the version of Word I'm using along with the authoring tool. As I understand it, I need to use the OpenDope stuff to make use of conditionals. I'm very confused and just need some help getting started

my "template" docx is bound to custom XML like so:
Code: Select all
<bind>
    <hasDba>true</hasDba>
    <legalName>{{legal name}}</legalName>
    <dba>{{doing business as}}</dba>
    <address>{{mailing address one line}}</address>
</bind>


at run time I'm replacing the xml with either
Code: Select all
<bind>
    <hasDba>true</hasDba>
    <legalName>some business name</legalName>
    <dba>foo business</dba>
    <address>123 fake street</address>
</bind>
-- or
<bind>
    <hasDba>false</hasDba>
    <legalName>{{legal name}}</legalName>
    <dba></dba>
    <address>{{mailing address one line}}</address>
</bind>


thanks for any help!

Re: Word 2013 invoice sample broken?

PostPosted: Mon Apr 25, 2016 6:51 pm
by jason
Hi there Jason

Don't use the Word 2013 invoice sample; its just a proof of concept: http://www.docx4java.org/blog/2015/01/w ... rime-time/

The authoring tools work in Word 2010, 2013 etc; there is nothing special required for Word 2013, hence your Googling turning up nothing.

Have you installed the authoring Word AddOm?

The first (and oldest) is available from http://www.opendope.org/downloads/autho ... /setup.exe or as an MSI. This Add-In is aimed at a developer audience, as it assumes familiarity with XML and XPath. For usage instructions, see the walkthrough.

An authoring tool aimed at less technical users is available from http://www.opendope.org/downloads/autho ... /setup.exe This tool uses the drag/drop approach Microsoft has introduced in Word 2013.