使用在ubuntu上运行的Mono + Aspose.Words时抛出异常

时间:2013-03-15 06:10:44

标签: c# ubuntu mono aspose.words

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

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

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

  

未处理的异常:System.ArgumentOutOfRangeException:startIndex +   长度> this.length参数名称:长度at   System.String.Substring(Int32 startIndex,Int32 length)[0x00000] in   :0点   x6c95d9cf46ff5f25.x0d299f323d241756.x3b67e683e83cab62(System.String   xe4115acdf4fbfccc,Int32 x961016a387451f05)[0x00000] in:0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x4469479613be​​c4d8   (Aspose.Words.Node xda5bf54deb817e37)[0x00000] in:0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x7be41bff00df2c71   (Aspose.Words.Node xda5bf54deb817e37)[0x00000] in:0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x699caa1974f95d1a   (Aspose.Words.Node xda5bf54deb817e37)[0x00000] in:0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x21e4bd206d6231f8   (System.Object xa860e35844c20ac7)[0x00000] in:0
  在x4adf554d20d941a6.x50e6e6d123fa4a35.xb5ef8a04e65b87e6   (System.String x1f25abf5fb75e795,System.Object xa860e35844c20ac7)   [0x00000] in:0 at   x59d6a4fc5007b7a4.xdeb77ea37ad74c56.xbbf9a1ead81dd3a1(System.String   x1f25abf5fb75e795,System.Object xa860e35844c20ac7)[0x00000] in   :0点   x59d6a4fc5007b7a4.x487cdc969fefe3d6.xbbf9a1ead81dd3a1(System.String   x1f25abf5fb75e795,System.Object xa860e35844c20ac7)[0x00000] in   :0点   x59d6a4fc5007b7a4.x487cdc969fefe3d6.xf3a1cfbffa44728c()[0x00000] in   :0点   x59d6a4fc5007b7a4.x487cdc969fefe3d6.x47f176deff0d42e2()[0x00000] in   :0点   x59d6a4fc5007b7a4.x487cdc969fefe3d6.x83f07df6a659e05b()[0x00000] in   :0点   x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98   (Aspose.Words.Document x3664041d21d73fdc,   x59d6a4fc5007b7a4.xdeb77ea37ad74c56 xdfde339da46db651)[0x00000] in   :Aspose.Words.Document.UpdatePageLayout()上的0:   [0x00000] in:0 at   Aspose.Words.Document.x410db0f4a89a6ef1(Boolean x24af0daafcd8fb8c)   [0x00000] in:0 at   Aspose.Words.Document.get_xcde671c53995c411()[0x00000] in:0 at Aspose.Words.Document.get_PageCount()[0x00000] in   :0点   xf989f31a236ff98c.x6c74398bceb133f8.xa2e0b7f7da663553   (x28925c9b27b37a46.x8556eed81191af11 x5ac1382edb7bf2c2)[0x00000] in   :Aspose.Words.Document.xf381a641001e6830为0   (System.IO.Stream xcf18e5243f8d5fd3,System.String xafe2f3653ee64ebc,   Aspose.Words.Saving.SaveOptions xc27f01f21f67608c)[0x00000] in   :Aspose.Words.Document.Save(System.String   fileName,Aspose.Words.Saving.SaveOptions saveOptions)[0x00000] in   :Aspose.Words.Document.Save(System.String   fileName,SaveFormat saveFormat)[0x00000] in:0
  在MonoTest.MainClass.Main(System.String [] args)[0x00000]中   :0 [错误]致命未处理例外:   System.ArgumentOutOfRangeException:startIndex + length> this.length   参数名称:System.String.Substring的长度(Int32 startIndex,   Int32长度)[0x00000] in:0 at   x6c95d9cf46ff5f25.x0d299f323d241756.x3b67e683e83cab62(System.String   xe4115acdf4fbfccc,Int32 x961016a387451f05)[0x00000] in:0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x4469479613be​​c4d8   (Aspose.Words.Node xda5bf54deb817e37)[0x00000] in:0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x7be41bff00df2c71   (Aspose.Words.Node xda5bf54deb817e37)[0x00000] in:0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x699caa1974f95d1a   (Aspose.Words.Node xda5bf54deb817e37)[0x00000] in:0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x21e4bd206d6231f8   (System.Object xa860e35844c20ac7)[0x00000] in:0
  在x4adf554d20d941a6.x50e6e6d123fa4a35.xb5ef8a04e65b87e6   (System.String x1f25abf5fb75e795,System.Object xa860e35844c20ac7)   [0x00000] in:0 at   x59d6a4fc5007b7a4.xdeb77ea37ad74c56.xbbf9a1ead81dd3a1(System.String   x1f25abf5fb75e795,System.Object xa860e35844c20ac7)[0x00000] in   :0点   x59d6a4fc5007b7a4.x487cdc969fefe3d6.xbbf9a1ead81dd3a1(System.String   x1f25abf5fb75e795,System.Object xa860e35844c20ac7)[0x00000] in   :0点   x59d6a4fc5007b7a4.x487cdc969fefe3d6.xf3a1cfbffa44728c()[0x00000] in   :0点   x59d6a4fc5007b7a4.x487cdc969fefe3d6.x47f176deff0d42e2()[0x00000] in   :0点   x59d6a4fc5007b7a4.x487cdc969fefe3d6.x83f07df6a659e05b()[0x00000] in   :0点   x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98   (Aspose.Words.Document x3664041d21d73fdc,   x59d6a4fc5007b7a4.xdeb77ea37ad74c56 xdfde339da46db651)[0x00000] in   :Aspose.Words.Document.UpdatePageLayout()上的0:   [0x00000] in:0 at   Aspose.Words.Document.x410db0f4a89a6ef1(Boolean x24af0daafcd8fb8c)   [0x00000] in:0 at   Aspose.Words.Document.get_xcde671c53995c411()[0x00000] in:0 at Aspose.Words.Document.get_PageCount()[0x00000] in   :0点   xf989f31a236ff98c.x6c74398bceb133f8.xa2e0b7f7da663553   (x28925c9b27b37a46.x8556eed81191af11 x5ac1382edb7bf2c2)[0x00000] in   :Aspose.Words.Document.xf381a641001e6830为0   (System.IO.Stream xcf18e5243f8d5fd3,System.String xafe2f3653ee64ebc,   Aspose.Words.Saving.SaveOptions xc27f01f21f67608c)[0x00000] in   :Aspose.Words.Document.Save(System.String   fileName,Aspose.Words.Saving.SaveOptions saveOptions)[0x00000] in   :Aspose.Words.Document.Save(System.String   fileName,SaveFormat saveFormat)[0x00000] in:0
  在MonoTest.MainClass.Main(System.String [] args)[0x00000]中   :0

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

1 个答案:

答案 0 :(得分:3)

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

可能是由于某些原因:

  1. 2013 MS Word office。
  2. 单词
  3. 中的一些复杂元素
  4. 旧版Aspose.Words.dll。
  5. 解决方案:

    1. 尝试将Aspose.Words.dll更新为新版本。如果它仍然无法正常工作 - 请写入aspose论坛,此错误将在新版本中修复。
    2. 检查word文档本身。也许你可以找到一些叫做内部异常的东西,而不是尝试删除它并再次检查。如果这当然是可以接受的。