Show/hide of static content in a document


Hi
possibility of show/hide of static content in a document based on the merge field selection

Thanks,
RaviKumar

Hi Ravi,


Thanks for your inquiry. Yes this is possible. Please see input/output Word documents and try running the following code:
Document doc = new Document(getMyDir() + “input.docx”);

doc.getMailMerge().setFieldMergingCallback(new HandleMergeField());
doc.getMailMerge().execute(new String[] { “HideIt” }, new Object[] { “Y” });

doc.save(getMyDir() + “15.8.0.docx”);


static class HandleMergeField implements IFieldMergingCallback
{
public void fieldMerging(FieldMergingArgs e) throws Exception
{
if(e.getFieldValue().equals(“Y”)){
Document doc = (Document) e.getDocument();
Paragraph para = doc.getFirstSection().getBody().getFirstParagraph();
para.getRuns().get(0).getFont().setHidden(true);
}
}
<font color="RED"><b>public</b></font> <font color="RED"><b>void</b></font> imageFieldMerging<font color="BLUE"><b>(</b></font>ImageFieldMergingArgs args<font color="BLUE"><b>)</b></font> <font color="RED"><b>throws</b></font> Exception
<font color="BLUE"><b>{</b></font>
    <font color="GREEN"><i>// Do nothing.

}
}


I hope, this helps.

Best regards,