How to use Web Extensions using Java

Hello everybody,

I’d like to know whether Aspose.Words for Java supports the Webextensions in Word 2013. Can I add an Word App programmatically (e.g. as CustomPart) to an existing *.docx document? If yes, do you have an example of how can I do it?

Thank you.

Best regards,
Borislav

Hi Borislav,



Thanks for your inquiry. Please attach the following resources here for testing:

  • Your input Word document.
  • Your expected Word document (with Word App (e.g. as CustomPart) added). You can create this document using Microsoft Word.

As soon as you get these pieces of information ready, we’ll investigate this scenario and provide you more information.

Best regards,

Hello Awais,

thank you for your support.

Please find attached the files

  • “DocumentWithoutApp.docx” - a simple word file
  • "DocumentWithApp.docx" - the same file with an word app.

I’d like to be able to add this app to the DocumentWithoutApp.docx with Aspose.Words.

Best,

Borislav

Hi Borislav,


Thanks for the additional information. I have logged your requirement in our issue tracking system as WORDSNET-10593. Our development team will further look into the details of this requirement and we will keep you updated on the status. We apologize for your inconvenience.

Best regards,

The issues you have found earlier (filed as WORDSNET-10593) have been fixed in this Aspose.Words for .NET 19.12 update and this Aspose.Words for Java 19.12 update.

@westernacher

Starting from Aspose.Words 19.12, you can work with web extensions. Aspose.Words API provides the WebExtensions namespace that provides various classes to customize elements and attributes extending the XML vocabulary for representing Office Add-ins.

Please read following article for more detail.
Work with Web Extensions

The following code example shows how to create task panes and add to web extension task panes.

Document doc = new Document();

TaskPane taskPane = new TaskPane();
doc.getWebExtensionTaskPanes().add(taskPane);

taskPane.setDockState(TaskPaneDockState.RIGHT);
taskPane.isVisible(true);
taskPane.setWidth(300);

taskPane.getWebExtension().getReference().setId("wa102923726");
taskPane.getWebExtension().getReference().setVersion("1.0.0.0");
taskPane.getWebExtension().getReference().setStoreType(WebExtensionStoreType.OMEX);
taskPane.getWebExtension().getReference().setStore("th-TH");
taskPane.getWebExtension().getProperties().add(new WebExtensionProperty("mailchimpCampaign", "mailchimpCampaign"));
taskPane.getWebExtension().getBindings().add(new WebExtensionBinding("UnnamedBinding_0_1506535429545", WebExtensionBindingType.TEXT, "194740422"));
        
doc.save(dataDir + "output.docx", SaveFormat.DOCX);