Prevent checkboxes from being editable in converted document?

We are using Word.Java to convert documents into HTML (from RTF) and some of the documents have checkboxes. When the document is converted to HTML, the checkboxes are clickable. For our use cases, we don’t want users to be able to change the checked state of the converted document because we want faithful representation of the original.

Is it possible to control this with Aspose.Words? E.g. using something in HtmlSaveOptions, etc?

@jballing I am afraid there is no such option yet.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-26137

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

As a workaround you can replace checkbox form fields with text before converting the document to HTML. For example see the following code:

Document doc = new Document(@"C:\Temp\in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
foreach (FormField ff in doc.Range.FormFields)
{
    if (ff.Type == FieldType.FieldFormCheckBox)
    {
        builder.MoveToBookmark(ff.Name, false, true);
        builder.Font.Name = "Wingdings";
        builder.Write(ff.Checked ? "\u00FE" : "\u00A8");
    }
}
// Remove firm fields.
doc.Range.Fields.Where(f => f.Type == FieldType.FieldFormCheckBox).ToList()
    .ForEach(f => f.Remove());

doc.Save(@"C:\Temp\out.html");

Thanks for sharing this workaround. I think it will work for our needs.

1 Like