Question

I'm using Aspose.Words to convert a doc/docx file to a pdf file on ubuntu. Mono runtime has been installed. My code is below:

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

Somehow, when the second line of the code is executed, an error was thrown. The detail is below:

Unhandled Exception: System.ArgumentOutOfRangeException: startIndex + length > this.length Parameter name: length at System.String.Substring (Int32 startIndex, Int32 length) [0x00000] in :0 at x6c95d9cf46ff5f25.x0d299f323d241756.x3b67e683e83cab62 (System.String xe4115acdf4fbfccc, Int32 x961016a387451f05) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x4469479613bec4d8 (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
at 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 at x59d6a4fc5007b7a4.x487cdc969fefe3d6.xbbf9a1ead81dd3a1 (System.String x1f25abf5fb75e795, System.Object xa860e35844c20ac7) [0x00000] in :0 at x59d6a4fc5007b7a4.x487cdc969fefe3d6.xf3a1cfbffa44728c () [0x00000] in :0 at x59d6a4fc5007b7a4.x487cdc969fefe3d6.x47f176deff0d42e2 () [0x00000] in :0 at x59d6a4fc5007b7a4.x487cdc969fefe3d6.x83f07df6a659e05b () [0x00000] in :0 at x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98 (Aspose.Words.Document x3664041d21d73fdc, x59d6a4fc5007b7a4.xdeb77ea37ad74c56 xdfde339da46db651) [0x00000] in :0 at Aspose.Words.Document.UpdatePageLayout () [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 at xf989f31a236ff98c.x6c74398bceb133f8.xa2e0b7f7da663553 (x28925c9b27b37a46.x8556eed81191af11 x5ac1382edb7bf2c2) [0x00000] in :0 at Aspose.Words.Document.xf381a641001e6830 (System.IO.Stream xcf18e5243f8d5fd3, System.String xafe2f3653ee64ebc, Aspose.Words.Saving.SaveOptions xc27f01f21f67608c) [0x00000] in :0 at Aspose.Words.Document.Save (System.String fileName, Aspose.Words.Saving.SaveOptions saveOptions) [0x00000] in :0 at Aspose.Words.Document.Save (System.String fileName, SaveFormat saveFormat) [0x00000] in :0
at MonoTest.MainClass.Main (System.String[] args) [0x00000] in :0 [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: startIndex + length > this.length Parameter name: length at System.String.Substring (Int32 startIndex, Int32 length) [0x00000] in :0 at x6c95d9cf46ff5f25.x0d299f323d241756.x3b67e683e83cab62 (System.String xe4115acdf4fbfccc, Int32 x961016a387451f05) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x4469479613bec4d8 (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
at 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 at x59d6a4fc5007b7a4.x487cdc969fefe3d6.xbbf9a1ead81dd3a1 (System.String x1f25abf5fb75e795, System.Object xa860e35844c20ac7) [0x00000] in :0 at x59d6a4fc5007b7a4.x487cdc969fefe3d6.xf3a1cfbffa44728c () [0x00000] in :0 at x59d6a4fc5007b7a4.x487cdc969fefe3d6.x47f176deff0d42e2 () [0x00000] in :0 at x59d6a4fc5007b7a4.x487cdc969fefe3d6.x83f07df6a659e05b () [0x00000] in :0 at x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98 (Aspose.Words.Document x3664041d21d73fdc, x59d6a4fc5007b7a4.xdeb77ea37ad74c56 xdfde339da46db651) [0x00000] in :0 at Aspose.Words.Document.UpdatePageLayout () [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 at xf989f31a236ff98c.x6c74398bceb133f8.xa2e0b7f7da663553 (x28925c9b27b37a46.x8556eed81191af11 x5ac1382edb7bf2c2) [0x00000] in :0 at Aspose.Words.Document.xf381a641001e6830 (System.IO.Stream xcf18e5243f8d5fd3, System.String xafe2f3653ee64ebc, Aspose.Words.Saving.SaveOptions xc27f01f21f67608c) [0x00000] in :0 at Aspose.Words.Document.Save (System.String fileName, Aspose.Words.Saving.SaveOptions saveOptions) [0x00000] in :0 at Aspose.Words.Document.Save (System.String fileName, SaveFormat saveFormat) [0x00000] in :0
at MonoTest.MainClass.Main (System.String[] args) [0x00000] in :0

Any advice is appreciated. Thanks.

Was it helpful?

Solution

Often inner exceptions is a very common problem for converting words documents in PDF via Aspose.

It can be due to some reasones like:

  1. 2013 MS Word office.
  2. Some complex elements in word
  3. Old version of Aspose.Words.dll.

Solutions:

  1. Try to update Aspose.Words.dll to new version. If it's still not working - write to aspose forum, and this error will be fixed in new release.
  2. Check word document itself. may be you can find something thac call this inner exception, than try to remove it and check again. If this is acceptable of course.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top