If I have code like the following:
- Code: Select all
_document.LoadFromStream(new MemoryStream(template), FileFormat.Docx);
// do some processing
var memoryStream = new MemoryStream();
_document.SaveToStream(memoryStream, FileFormat.PDF);
return memoryStream.ToArray();
There are two versions:
1. I removed all my processing and the PDF generates but has strange characters like this: https://i.imgur.com/iV7oQNP.png
2. I perform my processing and I get an exception on the line with SaveToStream:
- Code: Select all
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index'
Stack Trace:
- Code: Select all
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at spr4016.0(Table A_0, Int32 A_1, Int32 A_2)
at spr4016.0(Table A_0, spr7085 A_1, Single A_2)
at spr4016.1(Table A_0, Single A_1)
at spr4016.3(Table A_0, Single A_1)
at spr4016.0(RectangleF& A_0, Boolean A_1)
at spr4016.0(RectangleF A_0)
at spr7932.3(spr6849 A_0)
at spr7932.0(RectangleF A_0)
at spr7932.3(spr6849 A_0)
at spr7932.0(RectangleF A_0)
at spr4541.0(spr6145 A_0, spr5311 A_1, spr6135 A_2)
at spr4129.20()
at spr4129.1(IDocument A_0)
at spr2278.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 Web.Utilities.WordProcessingAbstraction.GetPdf() in Utilities\WordProcessingAbstraction.cs:line 51
If I change the code and download as FileFormat.Docx it works no problem. It's just for PDF.
I was using FreeSpire.Doc lastest and I tried FreeSpire.Office 2.15.0.
Can anyone provide some help?