ActiveX controls in Words 10 for Java

Hi guys,

I am looking for a working example for Words 10 that will allow me to list all ActiveX checkboxes inside a document, and inspect the form field names assigned to each checkbox.

Then, I would like to see an example of how to set a given checkbox to checked or unchecked.

Are these tasks even possible? Thanks in advance for your guidance.

I figure the key is something like this, but this is about as far as I can get.

NodeCollection shapes = getChildNodes(NodeType.SHAPE, true, false);
Iterator it2 = shapes.iterator();
while (it2.hasNext())
{
    Shape shape = it2.next();
    if (shape.getOleFormat().getProgId().equals("Forms.CheckBox.1"))
    {
        // I have a checkbox...
    }
}

Hi Eric,
Thanks for your request. ActiveX checkboxes are stored in the document as embedded OLE objects. Unfortunately, at the moment Aspose.Words does not allow changing state of these objects (check and uncheck). We will consider adding this feature in future. Your request has been linked to the appropriate issue. You will be notified as soon as it is resolved.
As a workaround, you can use FormField checkboxes instead of ActiveX.
Best regards,

There seems to be a bug with Words 10 using the legacy checkbox control instead of ActiveX, and outputting to PDF. My sample program is shown. It takes 3 args: the source .doc, the destination .pdf, and destination .doc. I was expecting the 2 checkboxes to be checked. Maybe it is an issue with my fonts? I attached my input .doc file, and a sample output pdf. Output to .doc works as expected by the way.

package com.lincdoc.sourcedoc;

import com.aspose.words.Document;
import com.aspose.words.NodeCollection;
import com.aspose.words.FormField;
import com.aspose.words.NodeType;
import com.aspose.words.FieldType;
import com.aspose.words.FontSettings;
import com.aspose.words.SaveFormat;
import java.util.Iterator;

public class TestCase2 extends Document
{
    private static final String FONTS_FOLDER = System.getenv("LINCDOC_HOME") + "/product/fonts";
    
    public TestCase2(String sourceFile) throws Exception
    {
        super(sourceFile);
    }
    
    public static void main(String[] args)
    {
        try
        {
            TestCase2 tc = new TestCase2(args[0]);
            tc.testCase(args[1], args[2]);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
    
    public void testCase(String outputPdf, String outputDoc)
    {
        NodeCollection formFields = getChildNodes(NodeType.FORM_FIELD, true, false);
        Iterator it = formFields.iterator();
        while (it.hasNext())
        {
            FormField ff = it.next();
            if (ff.getType() != FieldType.FIELD_FORM_CHECK_BOX)
            {
                continue;
            }
            System.out.println("got legacy form field=" + ff.getName());
            ff.setChecked(true);
            System.out.println("getChecked=" + ff.getChecked());
        }
        
        try
        {
            FontSettings.setFontsFolder(FONTS_FOLDER);
            save(outputPdf, SaveFormat.PDF);
            System.out.println("saved to " + outputPdf);
            
            save(outputDoc, SaveFormat.DOC);
            System.out.println("saved to " + outputDoc);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

Hi
Thank you for additional information. The problem with FormField checkboxes might occur because Wingdings2 font is not installed on the server. This font is not actually used in the document, but it is used for rendering checkboxes. So please try installing Wingdings2 font (see the attachment) on the server and let me know if this helps.
Best regards.

That solved it Alexey, thanks for your help.

Hi Eric,

Thanks for being patient. It is to update you that we are planning to release a limited version of this feature in next Aspose.Words 15.12.0 - Dec 2015 version i.e. there will be Read-Only access to ActiveX data (WORDSNET-1877).

Eric:
how to set a given checkbox to checked or unchecked.

However, the above feature will still not be possible in 15.12.0. To address this problem we have logged a separate issue in our issue tracking system. The ID of this issue is WORDSNET-12826. Your thread has been linked to the appropriate issues and you will be notified via this thread as soon as the fixes of these issues are available publicly.

Best regards,

The issues you have found earlier (filed as WORDSNET-1877) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(12)

The issues you have found earlier (filed as WORDSNET-12826) have been fixed in this Aspose.Words for .NET 24.7 update also available on NuGet.