Aspose.words for JAVA word转PDF文档报错

Aspose.words for JAVA v22.10 word转PDF文档报如下错误

Caused by: com.aspose.words.internal.zzZey: Unexpected character ’ ’ (code 32) (missing name?)
at [row,col {unknown-source}]: [359,104]
at com.aspose.words.internal.zzY28.zzY7R(Unknown Source)
at com.aspose.words.internal.zzY28.zzZb8(Unknown Source)
at com.aspose.words.internal.zzY28.zz7M(Unknown Source)
at com.aspose.words.internal.zzY28.zzXmk(Unknown Source)
at com.aspose.words.internal.zzX7y.zzY25(Unknown Source)
at com.aspose.words.internal.zzX7y.next(Unknown Source)
at com.aspose.words.internal.zzY55.read(Unknown Source)
… 21 more
Caused by: java.lang.IllegalStateException: XMLStreamException: Unexpected character ’ ’ (code 32) (missing name?)
at [row,col {unknown-source}]: [359,104]
at com.aspose.words.internal.zzY55.zzWwL(Unknown Source)
at com.aspose.words.internal.zzY55.read(Unknown Source)
at com.aspose.words.internal.zzWh6.zzWwL(Unknown Source)
at com.aspose.words.internal.zzWh6.zzWwL(Unknown Source)
at com.aspose.words.internal.zzWh6.zzWwL(Unknown Source)
at com.aspose.words.internal.zzWh6.zzWwL(Unknown Source)
at com.aspose.words.internal.zzWh6.zzWwL(Unknown Source)
at com.aspose.words.internal.zzWh6.zzWwL(Unknown Source)
at com.aspose.words.internal.zz6w.zzWwL(Unknown Source)
at com.aspose.words.internal.zz6w.zzYrI(Unknown Source)
at com.aspose.words.internal.zzZpq.zzWWH(Unknown Source)
at com.aspose.words.internal.zzZpq.zzZ2I(Unknown Source)
at com.aspose.words.internal.zzZpq.zzYSy(Unknown Source)
at com.aspose.words.internal.zzZpq.(Unknown Source)
at com.aspose.words.zzYs0.zzYtd(Unknown Source)
at com.aspose.words.zzYs0.zzVSi(Unknown Source)
at com.aspose.words.zzYs0.zzXHb(Unknown Source)
at com.aspose.words.zzYs0.zzWWH(Unknown Source)
at com.aspose.words.Document.zzWWH(Unknown Source)
… 4 more

请问这个是什么地方错误了呢?

@Gavin_Zhang, 如果没有您尝试转换为 PDF 的 Word 文档,很难判断导致异常的原因。 您能否附上导致异常的文件?

@dshvydkiy
你好,请查收
测试文书.zip (8.6 KB)

@Gavin_Zhang,即使您的 Word 文档具有 .doc 扩展名,它实际上是一个 XML 文件。 Microsoft Word 和 Aspose.Words 无法打开此 XML 文档,因为它格式错误。

第 355 行包含未转义的“&”字符。

要转义“&”字符,应将其替换为“&”。

之后,文档可以通过 Microsoft Word 和 Aspose.Words 打开。

测试文书.fixed.zip (9.0 KB)

您可以在此处阅读有关应转义的字符的更多信息:escaping - What characters do I need to escape in XML documents? - Stack Overflow