We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Make HTTP Call when DOCX DOC PDF Opening with Java | Ignore Client Side Java Scripts

Hi, I want to make an Http request when DOCX/DOC file open (or On some event) and handle the response of the request, based on the response we will take some decision on DOCX/DOC (hide/show). If the Internet is not working, then I will show a layer.

Can we put javascript(or another client side script) in docs/doc file using your words lib same as your PDF lib.



I believe, you can meet this requirement by implementing the IResourceLoadingCallback Interface. This interface also allows you to control how Aspose.Words loads external resources when importing a document from HTML or MHTML. Hope, this helps.


I have tried to put html,css and javascript code on doc file, html/ css are working but javascript code not working. I am sending my code,

My problem : I want to send a http to request server when document open, based no response, I will hide/show some content on page.

package asposepoc;

import java.util.logging.Level;
import java.util.logging.Logger;
import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;
import com.aspose.words.Shape;
import com.aspose.words.ShapeType;

public class AsposeOle {

  public static void main(String[] args) {
      String docPath = "/home/deepak/1.docx";
      try {
        Document doc = new Document(docPath);
        DocumentBuilder builder = new DocumentBuilder(doc);
        DocumentBuilder builder1 = new DocumentBuilder(doc);
            + "var btn = document.createElement('BUTTON');"
            + "btn.innerHTML = 'CLICK ME';"
            + "document.body.appendChild(btn);</script></head>"
            + "<body><div style='color:green'>show div</div><div style='color:green'>hide div</div></body></head>", true);
    } catch (Exception ex) {
        Logger.getLogger(AsposeOle.class.getName()).log(Level.SEVERE, null, ex);



Aspose.Words does not deal with JavaScript and no JavaScript is read, written or executed during open/load and save/convert operations. However, Aspose.Words will throw the following warning message upon loading a HTML with JavaScript Code:

[WarningType.UnexpectedContent] - HTML client-side scripts are not supported. Scripts have been ignored