Watermark text not evaluated
Watermark text is not evaluated. Placeholder is returned as it is.
docxtemplater version 3.0.2 msword 2013 node4.x
Can you give an example of input docx that gives this behaviour ?
please see the attachment. input.docx
Thing is, this data is not stored inside <w:t></w:t>, but like this in word/header1.xml and also in word/header2.xml and in word/header3.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:hdr xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 w15 wp14">
<w:p w:rsidR="00630241" w:rsidRDefault="0058538C">
<w:pPr>
<w:pStyle w:val="Header"/>
</w:pPr>
<w:r>
<w:rPr>
<w:noProof/>
</w:rPr>
<w:pict>
<v:shapetype id="_x0000_t136" coordsize="21600,21600" o:spt="136" adj="10800" path="m@7,l@8,m@5,21600l@6,21600e">
<v:formulas>
<v:f eqn="sum #0 0 10800"/>
<v:f eqn="prod #0 2 1"/>
<v:f eqn="sum 21600 0 @1"/>
<v:f eqn="sum 0 0 @2"/>
<v:f eqn="sum 21600 0 @3"/>
<v:f eqn="if @0 @3 0"/>
<v:f eqn="if @0 21600 @1"/>
<v:f eqn="if @0 0 @2"/>
<v:f eqn="if @0 @4 21600"/>
<v:f eqn="mid @5 @6"/>
<v:f eqn="mid @8 @5"/>
<v:f eqn="mid @7 @8"/>
<v:f eqn="mid @6 @7"/>
<v:f eqn="sum @6 0 @5"/>
</v:formulas>
<v:path textpathok="t" o:connecttype="custom" o:connectlocs="@9,0;@10,10800;@11,21600;@12,10800" o:connectangles="270,180,90,0"/>
<v:textpath on="t" fitshape="t"/>
<v:handles>
<v:h position="#0,bottomRight" xrange="6629,14971"/>
</v:handles>
<o:lock v:ext="edit" text="t" shapetype="t"/>
</v:shapetype>
<v:shape id="PowerPlusWaterMarkObject20687063" o:spid="_x0000_s2051" type="#_x0000_t136" style="position:absolute;margin-left:0;margin-top:0;width:442.95pt;height:166.1pt;rotation:315;z-index:-251655168;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin" o:allowincell="f" fillcolor="silver" stroked="f">
<v:fill opacity=".5"/>
<v:textpath style="font-family:"Calibri";font-size:1pt" string="{status}"/>
<w10:wrap anchorx="margin" anchory="margin"/>
</v:shape>
</w:pict>
</w:r>
</w:p>
</w:hdr>
It is in a <v:textpath style="font-family:"Calibri";font-size:1pt" string="{status}"/>
We do not do any changes in the attributes of the XML fields for now (we do only in the attributes of the XML), so it is a problem that is quite new for docxtemplater.
I need to think about this a bit, but as a workaround, you could just do a search and replace of the string {status} to the string that you want in word/header.xml
@edi9999 I can live with the suggested workaround for now. Thanks!
Could you guys share some more details about the workaround?
You can do something like :
doc.render()
const zip = doc.getZip()
const baseText = zip.file("word/header1.xml").asText();
const newText = baseText.replace(/{status}/, "My status");
zip.file("word/header1.xml", newText);
zip.generate()...
I see, thanks for the quick response!
I'm closing this since the suggested workaround works, and it would be quite complex to integrate this into docxtemplater