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

Free Support Forum - aspose.com

Is there way that we can strip out any Javascript present in a Word?

Team,
Is there a way to strip out any JavaScript present in the Word doc using Aspose.
We are using Aspose.Word (for Java).

Sample code of what we are trying to do

Document doc = new Document(oInputStream);
bas = new ByteArrayOutputStream();
doc.save(bas,SaveFormat.HTML); //**OR** doc.save(bas,SaveFormat.TEXT);

Thanks
Nimalan

Hi
Thanks for your inquiry. It is not quite clear for me what you would like to achieve. Could you please provide me more information about your needs? I will investigate the issue and provide you more information.
Best regards.

Hey,
We are trying to provide our Users with an option of uploading a Word doc. When they do that we read the doc and display it on a Rich Text Editor.

So if they have any JavaScript in their doc, it might break our application. To prevent this i wanted to know if there is a function in Aspose.Word (for Java) which can filter out any JavaScript that is present in the document that the user is trying to upload.

Thanks
Nimalan

Hi
Thank you for additional information. I think you can achieve this using Replace function. You can try to find JavaScript and replace them with empty string. I guess you are converting your document in HTML to show them in Rich Text Editor. If so you can parse your HTML before loading.
If you need I can create code example for you, but you should attach sample document that contains JavaScript you should like to remove.
Best regards.