Hi,
We are trying to convert a PDF into a word document and saving it to an OutputStream. We’re doing some further processing using the OutputStream, but we’re running into issues when saving it to the stream. It works fine when there is only one thread running, but we’re seeing errors when using multiple threads to parallelly convert multiple different PDFs and saving to different OutputStreams. In tests where we’re running 10 threads to process about 100 PDFs, the majority of the conversions are successful, but for a few of them, errors pop up. We have tried this for Aspose PDF 19.7 and 24.9, and the results are the same. To rule out the possibility of this being a data issue, we’ve tried tests where we’ve kept the contents of the PDFs the same. I’ve attached one of the test PDFs that we used.
test.pdf (36.7 KB)
Here are some of the errors that we’ve seen throughout multiple tests. There are more if you want me to list out all of them.
class com.aspose.pdf.internal.ms.System.l6n: This is not a structured storage file.
com.aspose.pdf.internal.l27p.lh.(Unknown Source)
com.aspose.pdf.internal.l27p.le.lj(Unknown Source)
com.aspose.pdf.internal.l27p.le.(Unknown Source)
com.aspose.pdf.internal.l96p.l0f.lI(Unknown Source)
com.aspose.pdf.internal.l96p.le.lI(Unknown Source)
com.aspose.pdf.internal.l96p.le.lt(Unknown Source)
com.aspose.pdf.internal.l2u.lf.lt(Unknown Source)
com.aspose.pdf.l1p.lI(Unknown Source)
com.aspose.pdf.l1p.lI(Unknown Source)
com.aspose.pdf.ADocument.ld(Unknown Source)
com.aspose.pdf.ADocument.lt(Unknown Source)
com.aspose.pdf.ADocument.lI(Unknown Source)
com.aspose.pdf.Document.lI(Unknown Source)
com.aspose.pdf.ADocument.save(Unknown Source)
com.aspose.pdf.Document.save(Unknown Source)
class com.aspose.pdf.internal.ms.System.lv: Position must be non-negative and less than 2^31 - 1 - origin
Parameter name: value
com.aspose.pdf.internal.ms.System.IO.l1j.setPosition(Unknown Source)
com.aspose.pdf.internal.l27p.ld.lI(Unknown Source)
com.aspose.pdf.internal.l27p.le.lj(Unknown Source)
com.aspose.pdf.internal.l27p.le.(Unknown Source)
com.aspose.pdf.internal.l96p.l0f.lI(Unknown Source)
com.aspose.pdf.internal.l96p.le.lI(Unknown Source)
com.aspose.pdf.internal.l96p.le.lt(Unknown Source)
com.aspose.pdf.internal.l2u.lf.lt(Unknown Source)
com.aspose.pdf.l1p.lI(Unknown Source)
com.aspose.pdf.l1p.lI(Unknown Source)
com.aspose.pdf.ADocument.ld(Unknown Source)
com.aspose.pdf.ADocument.lt(Unknown Source)
com.aspose.pdf.ADocument.lI(Unknown Source)
com.aspose.pdf.Document.lI(Unknown Source)
com.aspose.pdf.ADocument.save(Unknown Source)
com.aspose.pdf.Document.save(Unknown Source)
class com.aspose.pdf.internal.ms.System.l6n: The FAT in the structured storage document seems to be corrupted.
com.aspose.pdf.internal.l27p.le.lj(Unknown Source)
com.aspose.pdf.internal.l27p.le.lj(Unknown Source)
com.aspose.pdf.internal.l27p.le.(Unknown Source)
com.aspose.pdf.internal.l96p.l0f.lI(Unknown Source)
com.aspose.pdf.internal.l96p.le.lI(Unknown Source)
com.aspose.pdf.internal.l96p.le.lt(Unknown Source)
com.aspose.pdf.internal.l2u.lf.lt(Unknown Source)
com.aspose.pdf.l1p.lI(Unknown Source)
com.aspose.pdf.l1p.lI(Unknown Source)
com.aspose.pdf.ADocument.ld(Unknown Source)
com.aspose.pdf.ADocument.lt(Unknown Source)
com.aspose.pdf.ADocument.lI(Unknown Source)
com.aspose.pdf.Document.lI(Unknown Source)
com.aspose.pdf.ADocument.save(Unknown Source)
com.aspose.pdf.Document.save(Unknown Source)
java.lang.NullPointerException: Cannot invoke “com.aspose.pdf.internal.l27p.lk.lf(String)” because the return value of “com.aspose.pdf.internal.l27p.le.lI()” is null
at com.aspose.pdf.internal.l96p.l0f.lI(Unknown Source)
at com.aspose.pdf.internal.l96p.le.lI(Unknown Source)
at com.aspose.pdf.internal.l96p.le.lt(Unknown Source)
at com.aspose.pdf.internal.l2u.lf.lt(Unknown Source)
at com.aspose.pdf.l1p.lI(Unknown Source)
at com.aspose.pdf.l1p.lI(Unknown Source)
at com.aspose.pdf.ADocument.ld(Unknown Source)
at com.aspose.pdf.ADocument.lt(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.Document.lI(Unknown Source)
at com.aspose.pdf.ADocument.save(Unknown Source)
at com.aspose.pdf.Document.save(Unknown Source)
java.lang.NullPointerException: Cannot invoke “java.util.Map$Entry.getKey()” because the return value of “java.util.Map.get(Object)” is null
at com.aspose.pdf.internal.l16l.l1l.lt(Unknown Source)
at com.aspose.pdf.internal.l16l.l1l.lI(Unknown Source)
at com.aspose.pdf.internal.l16l.l1l.lI(Unknown Source)
at com.aspose.pdf.internal.l16l.l1l.lI(Unknown Source)
at com.aspose.pdf.internal.l15y.lh.lI(Unknown Source)
at com.aspose.pdf.internal.l15y.lh.lI(Unknown Source)
at com.aspose.pdf.internal.l15y.lh.lI(Unknown Source)
at com.aspose.pdf.internal.l15y.lt.lI(Unknown Source)
at com.aspose.pdf.internal.l15y.lv.lI(Unknown Source)
at com.aspose.pdf.internal.l15y.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l15y.le.lI(Unknown Source)
at com.aspose.pdf.internal.l15y.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l15h.lj.lI(Unknown Source)
at com.aspose.pdf.internal.l0n.lf.lI(Unknown Source)
at com.aspose.pdf.l4if.lI(Unknown Source)
at com.aspose.pdf.l4if.lI(Unknown Source)
at com.aspose.pdf.ADocument.lj(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.Document.lI(Unknown Source)
at com.aspose.pdf.ADocument.save(Unknown Source)
at com.aspose.pdf.Document.save(Unknown Source)
This is how we’re converting the PDFs and saving them to streams. The PDFs are retrieved from a database.
byte[] pdfData = delivery.getPdfData();
ByteArrayInputStream inputStream = new ByteArrayInputStream(pdfData);
Document pdfDoc = new Document(inputStream);
DocSaveOptions docSaveOptions = new DocSaveOptions();
docSaveOptions.setMode(DocSaveOptions.RecognitionMode.Flow);
docSaveOptions.setFormat(DocSaveOptions.DocFormat.Doc);
docSaveOptions.setMaxDistanceBetweenTextLines(0.5F);
docSaveOptions.setRelativeHorizontalProximity(1F);
ByteArrayOutputStream wordOutStream= new ByteArrayOutputStream();
pdfDoc.save(wordOutStream, docSaveOptions);
Thank you,