Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Mar 06, 2018 12:22 am

Hello,

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?

stephenmichaelf
 
Posts: 4
Joined: Sun Mar 04, 2018 5:43 pm

Tue Mar 06, 2018 2:01 am

Hello,

Thanks for your post. Please first update to the full version(Spire.Doc Pack(hot fix) Version:6.2.3) which is stronger than free version. If you still encounter the issue, please share us with your full code(including your processing) and input Word file.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Tue Mar 06, 2018 1:21 pm

The error is gone but the content is still corrupted.

The code is as follows:

Code: Select all
public byte[] GetPdf()
        {
            var ms = new MemoryStream();
            var docLocal = new Document();
            docLocal.LoadFromFile(@"..\CorruptionIssues.docx");
            docLocal.SaveToStream(ms, FileFormat.PDF);

            return ms.ToArray();
        }


I have also attached the document.

Also now there is red warning text since I am not using the free version...

Thanks.

stephenmichaelf
 
Posts: 4
Joined: Sun Mar 04, 2018 5:43 pm

Tue Mar 06, 2018 1:24 pm

Also even if I load docx and save to pdf, the content is corrupt:

Code: Select all
var docLocal = new Document();
docLocal.LoadFromFile(@"..\CorruptionIssues.docx");
docLocal.SaveToFile(@"..\CorruptionIssues.pdf", FileFormat.PDF);

stephenmichaelf
 
Posts: 4
Joined: Sun Mar 04, 2018 5:43 pm

Wed Mar 07, 2018 2:01 am

Hello,

Thanks for your sharing. As I was unable to reproduce the issue, please share us with the result PDF on your side, OS information and region language setting of your machine. I also attached the result PDF on my side for your reference.
In addition, please make sure you have installed the font of Book Antiqua on your machine.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Wed Mar 07, 2018 12:08 pm

Thanks for the help Simon, it's working now.

Last night I installed Office on my machine (Windows 10) and it started working. Perhaps that installed the missing fonts?

Also I now get red error warnings for using Spire.Doc and Spire.PDF.

Does this mean the Free version is no longer supported and I need to pay to remove the red warning text?

Thank you.

stephenmichaelf
 
Posts: 4
Joined: Sun Mar 04, 2018 5:43 pm

Thu Mar 08, 2018 2:05 am

Hello,

Thanks for your feedback. As we don't have a plan to upgrade the free version, you need to use the paid version instead. Our sales has sent an one-month temporary license to your email to help you remove the red warning. Please check your email later.

Best regards,
Simon
E-icelbue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Return to Spire.Doc