Free Support Forum - aspose.com

How do I escape special characters using ASPOSE.Word?

Hi,

I’m attempting to convert Word documents into HTML using ASPOSE Word (v4.0.0). Mostly it is working fine, with the exception of double quote characters (’"’) are not getting escaped to something like " Is there a way to turn this functionality on?

Regards,
Dave

In my test, I’ve surrounded selected words with double-quotes. The code used looks like this:

SaveOptions saveOptions = document.getSaveOptions();
saveOptions.setExportImagesFolder(this.getImageExportPath());
saveOptions.setHtmlExportEncoding(java.nio.charset.Charset.forName(“UTF-8”));

document.setSaveOptions(saveOptions);
System.out.println(“Set document save options.”);

try {
document.save(byteArrayOutputStream, SaveFormat.HTML);
} catch (Exception e) {
System.out.println(“Unable to save docuemnt.”);
e.printStackTrace();
throw new Exception(“Unable to save document”, e);
}

One of the resulting generated snipets:
In the “science experiment” shown here, it was
determined that when placing cold and hot water into water at room
temperature, cold water sank, while the hot water rose to the
top.

Based on this result,
which of the responses below accurately completes the
sentence?



Note the double-quotes around
the words “science experiment”. I would have expected to see something
like " replacing the double-quotes.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. It is allowed to use double quotes within text between tags.

<p><span>HTML quotes: "test"</span></p>

Double quotes should be escaped if they occur within double quotes, i.e. in tag attributes. See the following example:

<input type="text" name="Text1" value="test "test" test" />

Best regards.