【问题标题】:Exception thrown when using Mono+Aspose.Words running on ubuntu使用在 ubuntu 上运行的 Mono+Aspose.Words 时引发异常
【发布时间】:2013-03-03 18:48:33
【问题描述】:

我在 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 参数名称:length at System.String.Substring (Int32 startIndex, Int32 长度) [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] 在 :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] 在 :0 在 x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98 (Aspose.Words.Document x3664041d21d73fdc, x59d6a4fc5007b7a4.xdeb77ea37ad74c56 xdfde339da46db651) [0x00000] 在 :0 在 Aspose.Words.Document.UpdatePageLayout () [0x00000] 在 :0 处 Aspose.Words.Document.x410db0f4a89a6ef1(布尔值 x24af0daafcd8fb8c) [0x00000] 在 :0 处 Aspose.Words.Document.get_xcde671c53995c411 () [0x00000] in :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] 在 :0 在 Aspose.Words.Document.Save (System.String 文件名,Aspose.Words.Saving.SaveOptions saveOptions) [0x00000] in :0 在 Aspose.Words.Document.Save (System.String fileName, SaveFormat saveFormat) [0x00000] in :0
在 MonoTest.MainClass.Main (System.String[] args) [0x00000] 中 :0 [错误] 致命的未处理异常: System.ArgumentOutOfRangeException: startIndex + 长度 > 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] 在 :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] 在 :0 在 x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98 (Aspose.Words.Document x3664041d21d73fdc, x59d6a4fc5007b7a4.xdeb77ea37ad74c56 xdfde339da46db651) [0x00000] 在 :0 在 Aspose.Words.Document.UpdatePageLayout () [0x00000] 在 :0 处 Aspose.Words.Document.x410db0f4a89a6ef1(布尔值 x24af0daafcd8fb8c) [0x00000] 在 :0 处 Aspose.Words.Document.get_xcde671c53995c411 () [0x00000] in :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] 在 :0 在 Aspose.Words.Document.Save (System.String 文件名,Aspose.Words.Saving.SaveOptions saveOptions) [0x00000] in :0 在 Aspose.Words.Document.Save (System.String fileName, SaveFormat saveFormat) [0x00000] in :0
在 MonoTest.MainClass.Main (System.String[] args) [0x00000] 中 :0

感谢任何建议。谢谢。

【问题讨论】:

    标签: c# ubuntu mono aspose.words


    【解决方案1】:

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

    这可能是由于以下原因:

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

    解决方案:

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

    【讨论】:

    • 原来文档好像有问题。我使用了另一个文件,没有发生错误。非常感谢。
    • 嗨,Aler,还有一个问题。我的文档包含很多 unicode 字符。转换后的pdf文件是乱码。我尝试设置 LoadOptions 的 Encoding 属性,但没有成功。有什么想法吗?
    • Aspose 已经遇到过这个问题。这是因为 Aspose.PDF 使用 TrueType 字体,而对于 Linux,MAC OS 会导致问题。它在这个 .NET 更新中解决了:aspose.com/community/files/51/.net-components/…
    猜你喜欢
    • 1970-01-01
    • 2012-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-22
    • 2022-01-18
    • 1970-01-01
    相关资源
    最近更新 更多