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.

Mon May 01, 2023 4:14 am

Hello,
I have an error during LoadFromStream document. The error:
Caused by: com.spire.doc.packages.sprzzu: Position cannot be negative
Parameter name: value
at com.spire.doc.packages.sprwxt.setPosition(MemoryStream.java:173) ~[spire.doc.free-5.2.0.jar:5.2.0]
at com.spire.doc.packages.spromy.spr▅─—(Unknown Source) ~[spire.doc.free-5.2.0.jar:5.2.0]
at com.spire.doc.Document.spr┡┈—(Unknown Source) ~[spire.doc.free-5.2.0.jar:5.2.0]
at com.spire.doc.Document.spr┭┇—(Unknown Source) ~[spire.doc.free-5.2.0.jar:5.2.0]
at com.spire.doc.Document.spr┰┉—(Unknown Source) ~[spire.doc.free-5.2.0.jar:5.2.0]
at com.spire.doc.Document.spr╓‘(Unknown Source) ~[spire.doc.free-5.2.0.jar:5.2.0]
at com.spire.doc.Document.loadFromStream(Unknown Source) ~[spire.doc.free-5.2.0.jar:5.2.0]
at com.halcyon.service.ReportGeneratorService.loadTemplate(ReportGeneratorService.java:34) ~[classes/:na]
at com.halcyon.service.ReportGeneratorService.<init>(ReportGeneratorService.java:20) ~[classes/:na]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_144]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_144]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_144]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_144]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211) ~[spring-beans-5.3.15.jar:5.3.15]

The code:
Document reportTemplate = new Document();
File file = ResourceUtils.getFile("classpath:template/report_template.docx");
InputStream templateStream = new FileInputStream(file);
reportTemplate.loadFromStream(templateStream, FileFormat.Auto);

The file exists and the InputStrem is created. I'm using SpringBoot as a framework.
Thank you in advance!

AlekseyMatsarski
 
Posts: 2
Joined: Mon May 01, 2023 4:06 am

Mon May 01, 2023 10:05 am

Hello,

Thanks for your inquiry.
According to the message you provided, you are using the free version of Spire.Doc. I suggest you can first test your scenario with the latest commercial version of Spire.Doc 11.4.2, due to the latest commercial version is more stable and fix more bug than the free version. If the issue still exists in the latest version, please offer the following message to help us reproduce your issue and work out a solution for you. Thanks for your assistance in advance.

1) Your input word file, you can attach it here or send it via email(support@e-iceblue.com).
2) The Jdk version, such as Oracle Jdk1.8.
3) The test environment, such as Win7-64bit.

Sincerely,
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 984
Joined: Tue Mar 08, 2022 2:02 am

Thu May 04, 2023 2:12 am

I found the problem, the Word file was corrupted after SpringBoot create a jar package. It was the proof of concept application which is why the Word file was placed into 'resource'. But it is interesting why Maven corrupted the Word file. Anyway, it is not a Sprie.Doc problem.

AlekseyMatsarski
 
Posts: 2
Joined: Mon May 01, 2023 4:06 am

Thu May 04, 2023 6:24 am

Hello,

Thanks for your feedback.
If you have any issue about our product in the future, just feel free to contact us.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 984
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.Doc