I am trying to implement a Signature Block in a docx file using DocX4J. We have already implemented the rest of the document generation based on content using DocX4J and now we would like to add signature blocks. In docx a signature block looks like the following:
<w:p w:rsidR="00A82DB1" w:rsidRDefault="006071C7">
<w:r>
<w:pict>
<v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype>
<v:shape id="_x0000_i1025" type="#_x0000_t75" alt="Microsoft Office Signature Line..." style="width:192pt;height:96pt">
<v:imagedata r:id="rId8" o:title=""/>
<o:lock v:ext="edit" ungrouping="t" rotation="t" cropping="t" verticies="t" text="t" grouping="t"/>
<o:signatureline v:ext="edit" id="{923ef6ed-871e-4024-8365-0c7ba97a28fe}" provid="{00000000-0000-0000-0000-000000000000}"
o:suggestedsigner="Dynamic Name" o:suggestedsigner2="Dynamic Title" o:suggestedsigneremail="email" issignatureline="t"/>
</v:shape>
</w:pict>
</w:r>
</w:p>
The picture has a shape which contains the image data with a relationship to an Image part stored at "\word\media" within the docx archive. I used the webapp to decompose this but the portion that has to do with the imagedata tag just had the following:
CTImageData imagedata = vmlObjectFactory.createCTImageData();
JAXBElement<org.docx4j.vml.CTImageData> imagedataWrapped = vmlObjectFactory.createImagedata(imagedata);
shape.getEGShapeElements().add( imagedataWrapped);
imagedata.setTitle( "");
imagedata.setId( "rId8");
While this creates the tag and sets the Id, it doesn't load the image that it refers too which is a bitmap that I create dynamically with the name and title on it. I have looked and found ImageBmpPart which extends BinaryPartAbstractImage. I have found many examples of how to use this to create an inline image but I don't think that will work here. Is using ImageBmpPart the right approach to use here to import the image, store it in "\word\media\", create the relationship Id and relationship, and then input that Id into the above code so that the imagedata tag correctly points to the signature line bitmap that I have created? What is the correct order of calls to do the above?