Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Apr 15, 2026 1:30 pm

We get this error

ava.lang.ArrayIndexOutOfBoundsException: arraycopy: source index -17320 out of bounds for byte[8092]

  at com.spire.pdf.packages.spryvq.spr◍▕(RandomAccessFileBuffered.java:474) ~[spire.pdf-11.9.6.jar:11.9.6]

  at com.spire.pdf.packages.spryvq.spr┧¶(RandomAccessFileBuffered.java:582) ~[spire.pdf-11.9.6.jar:11.9.6]

  at com.spire.pdf.packages.sprmwv.read(FileStream.java:299) ~[spire.pdf-11.9.6.jar:11.9.6]

  at com.spire.pdf.packages.sproog.spr┧¶(BinaryReader.java:166) ~[spire.pdf-11.9.6.jar:11.9.6]

  at com.spire.pdf.packages.sprigo.spr┧¶(Unknown Source) ~[spire.pdf-11.9.6.jar:11.9.6]

  at com.spire.pdf.packages.sprxnf.spr┚⌭(Unknown Source) ~[spire.pdf-11.9.6.jar:11.9.6]

  at com.spire.pdf.packages.sprxnf.spr⌫⌭(Unknown Source) ~[spire.pdf-11.9.6.jar:11.9.6]

  at com.spire.pdf.packages.sprxnf.spr┛⌭(Unknown Source) ~[spire.pdf-11.9.6.jar:11.9.6]

  at com.spire.pdf.packages.sprxye.spr⑶⌮(Unknown Source) ~[spire.pdf-11.9.6.jar:11.9.6]

  at com.spire.pdf.packages.sprxye.spr㈯⃠⌭(Unknown Source) ~[spire.pdf-11.9.6.jar:11.9.6]

  at com.spire.pdf.packages.sprxye.sprㆁ⌭(Unknown Source) ~[spire.pdf-11.9.6.jar:11.9.6]

  at com.spire.pdf.packages.sprkxe.spr™∮(Unknown Source) ~[spire.pdf-11.9.6.jar:11.9.6]

  at com.spire.pdf.packages.sprnvo.spr™∮(Unknown Source) ~[spire.pdf-11.9.6.jar:11.9.6]

  at com.spire.pdf.packages.sprwkf.spr╸⌭(Unknown Source) ~[spire.pdf-11.9.6.jar:11.9.6]

  at com.spire.pdf.packages.sprwkf.spr┳⌭(Unknown Source) ~[spire.pdf-11.9.6.jar:11.9.6]



Environment:

* Java: 21.0.6
* Spire.PDF: 11.9.6
* Platform: Liferay (OSGi environment)
* Execution context: asynchronous workflow (multi-threaded)



Input handling:

We are loading and saving the PDF entirely in memory using byte streams, we need to return a byte[].
Here are some snippets.

Code: Select all
byte[] inputByte = dlFileEntry.getContentStream();

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ByteArrayInputStream bais = new ByteArrayInputStream(inputByte);

PdfDocument pdfDocument = new PdfDocument();
pdfDocument.loadFromStream(bais);

pdfDocument.saveToStream(byteArrayOutputStream);

byte[] streamPDF = byteArrayOutputStream.toByteArray();




Additional context:

The same logic works correctly in other flows.
The PDF is successfully loaded (loadFromStream does not throw errors).
The exception occurs only during saveToStream in some cases.



Request:

Could you please clarify:

    1. Possible causes for this exception during saveToStream
    2. Whether there are known issues with stream-based processing in version 11.9.6
    3. Recommended approach for handling PDFs entirely in memory

Thanks.

jadinard
 
Posts: 13
Joined: Wed Aug 13, 2025 2:25 pm

Thu Apr 16, 2026 1:39 am

Hello,

Thank you for your inquiry,
Based solely on the current exception information, we are unable to accurately locate the cause. What needs to be confirmed is, is this exception caused by operating a specific PDF document? If that's the case, it should be related to the specific data in the document. You can first verify with the latest version "Spire.PDF for Java Version:12.3.9". If the problem still persists, please provide the document that caused this exception. You can provide it here or send it to [email protected]. Looking forward to your further feedback.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1510
Joined: Wed Apr 25, 2018 3:20 am

Thu Apr 16, 2026 7:46 am

Hello,

We are currently using version 11.9.6 and have a valid license.

If we upgrade to version 12.x, will a new license be required? This could be an issue for us.

Additionally, are there any changes to the API call methods in version 12?

We are also experiencing an issue where PDFs are not consistently generated. The problem occurs randomly, and we have not yet identified the cause or a reliable way to reproduce it.

Thank you for your support.

Best regards,

Jacopo.

jadinard
 
Posts: 13
Joined: Wed Aug 13, 2025 2:25 pm

Thu Apr 16, 2026 8:42 am

Hello,

Thank you for your feedback.
We apologize that based on your email address, we did not correspond to your purchased order. Could you provide us with the order number or license registration email to help us check the purchased record? Or you can send these messages to [email protected].

If the license you purchased has expired before March 27, 2026, upgrading to the current new version, the old license will not valid. We can provide a temporary license for you to test first. If your license expires after March 27, 2026, you can upgrade to the latest version for free.

In addition, our latest version is compatible with all the features of the old version. Compared to the old version, our latest version has more new features and optimizations. For the version release news, you can check: https://www.e-iceblue.com/news/spire-pdf-java.html

Regarding the current exception, we still need to confirm whether it is a specific document or all PDF documents. If it is a specific document, we also need the document to further reproduce and investigate the cause. Thank you for your understanding.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1510
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF

cron