I can't provide you with a file to reproduce the error (it doesn't fail before replacing the text) but I think the stacktraces speak for themselves. It seems the error may be related to "Mailto:" hyperlinks of an e-mail address in combination with something else. The exception does not occur when the link is removed, but it also does not occur when other parts of the text are removed.
I've tested using:
Spire.Doc Pack(hot fix) Version:5.5.189 (See pdf and docx stacktraces)
Spire.office 2.12.5 Spire.Doc 5.5.114.4035 (See pdf and docx stacktraces)
Spire office 2.8.2 Spire Doc 5.1.13.4035 (Docx works, pdf gets another exception, see this support thread)
.NET 3.5, Windows 10, Office 2013
Thank you,
Robin
To Docx with Spire.Doc Pack(hot fix) Version:5.5.189:
- Code: Select all
{System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
at System.String.Substring(Int32 startIndex, Int32 length)
at Spire.Doc.Fields.TextRange.get_Text()
at Spire.Doc.Fields.Field.ᜃ(DocumentObject A_0)
at Spire.Doc.Fields.Field.ᜃ()
at Spire.Doc.Fields.Field.᜕()
at sprᧈ.ᜂ(Field A_0)
at sprᧈ.ᜉ(Field A_0)
at sprᧈ.ᜈ(ParagraphBase A_0)
at sprᧈ.ᜀ(ParagraphItemCollection A_0)
at sprᧈ.ᜀ(Paragraph A_0, Boolean A_1)
at sprᧈ.ᜀ(BodyRegion A_0, Boolean A_1)
at sprᧈ.ᜀ(BodyRegionCollection A_0, Boolean A_1)
at sprᧈ.ᜇ(Section A_0)
at sprᧈ.ᜧ()
at sprᧈ.ᜱ()
at sprᧈ.ᜀ(Document A_0)
at sprᧈ.ᜀ(Stream A_0, Document A_1)
at Spire.Doc.Document.ᜆ(Stream A_0)
at Spire.Doc.Document.SaveToFile(Stream stream, FileFormat fileFormat)
at Spire.Doc.Document.SaveToStream(Stream stream, FileFormat fileFormat)
at ......
To Pdf with Spire.Doc Pack(hot fix) Version:5.5.189:
- Code: Select all
{System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
Parameter name: startIndex
at System.String.Substring(Int32 startIndex, Int32 length)
at Spire.Doc.Fields.TextRange.get_Text()
at Spire.Doc.Fields.TextRange.ᜀ()
at Spire.Doc.Fields.TextRange.᜴()
at Spire.Doc.Fields.TextRange.CreateLayoutInfo()
at Spire.Doc.DocumentBase.Spire.Doc.Layout.IDocumentBase.get_LayoutInfo()
at sprᥩ.ᜃ()
at sprᥩ.ᜀ(RectangleF A_0)
at sprṀ.ᜃ(spr⊭ A_0)
at sprᥩ.ᜀ(RectangleF A_0)
at sprᥩ.ᜃ(spr⊭ A_0)
at sprᥩ.ᜀ(RectangleF A_0)
at sprᥩ.ᜃ(spr⊭ A_0)
at sprᥩ.ᜀ(RectangleF A_0)
at sprស.ᜀ(spr A_0, sprấ A_1, spr A_2)
at sprᲴ.()
at sprᲴ.ᜁ(IDocument A_0)
at spr᧭.ᜀ(Document A_0)
at Spire.Doc.Document.ᜀ(Stream A_0)
at Spire.Doc.Document.SaveToFile(Stream stream, FileFormat fileFormat)
at Spire.Doc.Document.SaveToStream(Stream stream, FileFormat fileFormat)
at ......
To Docx with Spire.office 2.12.5 Spire.Doc 5.5.114.4035:
- Code: Select all
System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
at System.String.Substring(Int32 startIndex, Int32 length)
at Spire.Doc.Fields.TextRange.get_Text()
at Spire.Doc.Fields.Field.3(DocumentObject A_0)
at Spire.Doc.Fields.Field.3()
at Spire.Doc.Fields.Field.21()
at spr8082.2(Field A_0)
at spr8082.9(Field A_0)
at spr8082.8(ParagraphBase A_0)
at spr8082.0(ParagraphItemCollection A_0)
at spr8082.0(Paragraph A_0, Boolean A_1)
at spr8082.0(BodyRegion A_0, Boolean A_1)
at spr8082.0(BodyRegionCollection A_0, Boolean A_1)
at spr8082.7(Section A_0)
at spr8082.39()
at spr8082.49()
at spr8082.0(Document A_0)
at spr8082.0(Stream A_0, Document A_1)
at Spire.Doc.Document.6(Stream A_0)
at Spire.Doc.Document.SaveToFile(Stream stream, FileFormat fileFormat)
at Spire.Doc.Document.SaveToStream(Stream stream, FileFormat fileFormat)
at .....
To Pdf with Spire.office 2.12.5 Spire.Doc 5.5.114.4035:
- Code: Select all
System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
Parameter name: startIndex
at System.String.Substring(Int32 startIndex, Int32 length)
at Spire.Doc.Fields.TextRange.get_Text()
at Spire.Doc.Fields.TextRange.CreateLayoutInfo()
at Spire.Doc.DocumentBase.Spire.Doc.Layout.IDocumentBase.get_LayoutInfo()
at spr8536.3()
at spr8536.0(RectangleF A_0)
at spr7982.3(spr7392 A_0)
at spr8536.0(RectangleF A_0)
at spr8536.3(spr7392 A_0)
at spr8536.0(RectangleF A_0)
at spr8536.3(spr7392 A_0)
at spr8536.0(RectangleF A_0)
at spr4900.0(spr6629 A_0, spr5719 A_1, spr6619 A_2)
at spr4448.21()
at spr4448.1(IDocument A_0)
at spr2464.0(Document A_0)
at Spire.Doc.Document.0(Stream A_0)
at Spire.Doc.Document.SaveToFile(Stream stream, FileFormat fileFormat)
at Spire.Doc.Document.SaveToStream(Stream stream, FileFormat fileFormat)
at ....