0

我在 ubuntu 上使用 Aspose.Words 将 doc/docx 文件转换为 pdf 文件。Mono 运行时已安装。我的代码如下:

Document doc = new Document ("/data/upfile/test.docx");
doc.Save ("/data/upfile/test.pdf", SaveFormat.Pdf);

不知何故,当执行第二行代码时,抛出了一个错误。详情如下:

未处理的异常:System.ArgumentOutOfRangeException:startIndex + length > this.length 参数名称:System.String.Substring 的长度(Int32 startIndex,Int32 长度)[0x00000] in :0 at x6c95d9cf46ff5f25.x0d299f323d241756.x3b67e683e83cab62 (System.String xe4115acdf4, x961016a387451f05)[0x00000]中:0在x4adf554d20d941a6.x50e6e6d123fa4a35.x4469479613bec4d8(Aspose.Words.Node xda5bf54deb817e37)[0x00000]中:0在x4adf554d20d941a6.x50e6e6d123fa4a35.x7be41bff00df2c71(Aspose.Words.Node xda5bf54deb817e37)[0x00000]中:0在x4adf554d20d941a6 .x50e6e6d123fa4a35.x699caa1974f95d1a(aspose.words.node xda5bf54deb817e37):0:0在x4adf554d20d941a6.x50e6231f8(system.object x860e35844c20ac7)[0x00000]中:0
在x4adf554d20d941a6.x50e6e6d123fa4a35.xb5ef8a04e65b87e6(System.String x1f25abf5fb75e795,System.Object的xa860e35844c20ac7)[0x00000]中:0在x59d6a4fc5007b7a4.xdeb77ea37ad74c56.xbbf9a1ead81dd3a1(System.String x1f25abf5fb75e795,System.Object的xa860e35844c20ac7)[0x00000]中:0在x59d6a4fc5007b7a4.x487cdc969fefe3d6 .xbbf9a1ead81dd3a1(System.String x1f25abf5fb75e795,System.Object的xa860e35844c20ac7)[0x00000]中:0在x59d6a4fc5007b7a4.x487cdc969fefe3d6.xf3a1cfbffa44728c()[0x00000]中:0在x59d6a4fc5007b7a4.x487cdc969fefe3d6.x47f176deff0d42e2()[0x00000]中:0在x59d6a4fc5007b7a4。 x487cdc969fefe3d6.x83f07df6a659e05b () [0x00000] in :0 at x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98 (Aspose.Words.Document x3664041d21d73fdc, x5941d21d73fdc, x594d.xdeb77ea37ad74c56 xdfde339da46db651) [0x00000] in :0 at Aspose.Words.Document.UpdatePageLayout () [0x00000] in :0 at Aspose.Words.Document.x410db0f4a89a6ef1 (Boolean x24af0daafcd8fb8c) [0x00000] in :0 atDocument Aspose. get_xcde671c53995c411()[0x00000]中:0在Aspose.Words.Document.get_PageCount()[0x00000]中:0在xf989f31a236ff98c.x6c74398bceb133f8.xa2e0b7f7da663553(x28925c9b27b37a46.x8556eed81191af11 x5ac1382edb7bf2c2)[0x00000]中:0在Aspose.Words.Document。 xf381a641001e6830 (System.IO.Stream xcf18e5243f8d5fd3, System.String xafe2f3653ee64ebc, Aspose.Words.Saving.SaveOptions xc27f01f21f67608c) [0x00000] 在 Aspose.Words.Document.Save (System.String fileName, Aspose.Words.SaveOptions xc27f01f21f67608c) [0x00000] saveOptions) [0x00000] in :0 at Aspose.Words.Document.Save (System.String fileName,SaveFormat saveFormat) [0x00000] in :0
在 MonoTest.MainClass.Main (System.String[] args) [0x00000] in :0 [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: startIndex + length > this.length 参数名称:长度在 System.String.Substring (Int32的startIndex,的Int32长度)[0x00000]中:0在x6c95d9cf46ff5f25.x0d299f323d241756.x3b67e683e83cab62(System.String xe4115acdf4fbfccc,的Int32 x961016a387451f05)[0x00000]中:0在x4adf554d20d941a6.x50e6e6d123fa4a35.x4469479613bec4d8(Aspose.Words.Node xda5bf54deb817e37)[0x00000]在:0在x4adf554d20d941a6.x50e6e6d123fa4a35.x7be41bff00df2c71(Aspose.Words.Node xda5bf54deb817e37)[0x00000]中:0在x4adf554d20d941a6.x50e6e6d123fa4a35.x699caa1974f95d1a(Aspose.Words.Node xda5bf54deb817e37)[0x00000]中:0在x4adf554d20d941a6.x50e6e6d123fa4a35.x21e4bd206d6231f8(系统.对象 xa860e35844c20ac7) [0x00000] 在:0
在x4adf554d20d941a6.x50e6e6d123fa4a35.xb5ef8a04e65b87e6(System.String x1f25abf5fb75e795,System.Object的xa860e35844c20ac7)[0x00000]中:0在x59d6a4fc5007b7a4.xdeb77ea37ad74c56.xbbf9a1ead81dd3a1(System.String x1f25abf5fb75e795,System.Object的xa860e35844c20ac7)[0x00000]中:0在x59d6a4fc5007b7a4.x487cdc969fefe3d6 .xbbf9a1ead81dd3a1(System.String x1f25abf5fb75e795,System.Object的xa860e35844c20ac7)[0x00000]中:0在x59d6a4fc5007b7a4.x487cdc969fefe3d6.xf3a1cfbffa44728c()[0x00000]中:0在x59d6a4fc5007b7a4.x487cdc969fefe3d6.x47f176deff0d42e2()[0x00000]中:0在x59d6a4fc5007b7a4。 x487cdc969fefe3d6.x83f07df6a659e05b () [0x00000] in :0 at x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98 (Aspose.Words.Document x3664041d21d73fdc, x5941d21d73fdc, x594d.xdeb77ea37ad74c56 xdfde339da46db651) [0x00000] in :0 at Aspose.Words.Document.UpdatePageLayout () [0x00000] in :0 at Aspose.Words.Document.x410db0f4a89a6ef1 (Boolean x24af0daafcd8fb8c) [0x00000] in :0 atDocument Aspose. get_xcde671c53995c411()[0x00000]中:0在Aspose.Words.Document.get_PageCount()[0x00000]中:0在xf989f31a236ff98c.x6c74398bceb133f8.xa2e0b7f7da663553(x28925c9b27b37a46.x8556eed81191af11 x5ac1382edb7bf2c2)[0x00000]中:0在Aspose.Words.Document。 xf381a641001e6830 (System.IO.Stream xcf18e5243f8d5fd3, System.String xafe2f3653ee64ebc, Aspose.Words.Saving.SaveOptions xc27f01f21f67608c) [0x00000] 在 Aspose.Words.Document.Save (System.String fileName, Aspose.Words.SaveOptions xc27f01f21f67608c) [0x00000] saveOptions) [0x00000] in :0 at Aspose.Words.Document.Save (System.String fileName,SaveFormat saveFormat) [0x00000] in :0
在 MonoTest.MainClass.Main (System.String[] args) [0x00000] in :0

任何建议表示赞赏。谢谢。

4

1 回答 1

3

通常,内部异常是通过 Aspose 转换 PDF 中的单词文档时非常常见的问题。

这可能是由于一些原因,例如:

  1. 2013 微软 Word 办公室。
  2. word中的一些复杂元素
  3. 旧版本的 Aspose.Words.dll。

解决方案:

  1. 尝试将 Aspose.Words.dll 更新到新版本。如果它仍然不起作用 - 写信给 aspose 论坛,这个错误将在新版本中修复。
  2. 检查word文档本身。可能你可以找到一些叫做这个内部异常的东西,而不是尝试删除它并再次检查。如果这是当然可以接受的。
于 2013-03-15T06:46:36.290 回答