Hi,
I tried to convert PDF to PDF/A by using Aspose library, it works on single thread application, however when I tried to run it in multi-thread application by using ExecutorService, got the EmptyValueException: CreationDate value is empty when save the Document after converting.
Multi-threading code is
ExecutorService executor = Executors.newFixedThreadPool(5);
for (int i = 0; i < 2; i++) {
Runnable worker = new WorkerThread(“0” + i);
executor.execute(worker);
}
Convert code is :
pdfStream = new ByteArrayInputStream(pdf);
Document pdfDocument = new Document(pdfStream);
pdfOutStream = new ByteArrayOutputStream();
boolean success = pdfDocument.convert(“D:/NotBackedUp/projects/glenspdf/tmp/file.log”, PdfFormat.PDF_A_1A, ConvertErrorAction.Delete);
if (!success) {
throw new RuntimeException (“Could not convert the PDF to a PDF/A-1A format PDF.”);
}
//DocumentInfo di = pdfDocument.getInfo();
//System.out.println(“CreationDate is:” + di.getCreationDate());
pdfDocument.save(pdfOutStream);
Exception is lie:
Exception in thread “pool-1-thread-2” class com.aspose.pdf.exceptions.EmptyValueException: CreationDate value is empty
com.aspose.pdf.internal.p17.z14.m10(Unknown Source)
com.aspose.pdf.internal.p106.z1.m1(Unknown Source)
com.aspose.pdf.internal.p106.z5.m1(Unknown Source)
com.aspose.pdf.internal.p102.z18.m1(Unknown Source)
com.aspose.pdf.internal.p102.z16.m1(Unknown Source)
com.aspose.pdf.internal.p17.z13.m1(Unknown Source)
com.aspose.pdf.ADocument.saveInternal(Unknown Source)
com.aspose.pdf.Document.saveInternal(Unknown Source)
com.aspose.pdf.ADocument$3.m1(Unknown Source)
com.aspose.pdf.internal.p789.z2.m2(Unknown Source)
com.aspose.pdf.internal.p789.z3.m1(Unknown Source)
com.aspose.pdf.ADocument.save(Unknown Source)
com.aspose.pdf.Document.save(Unknown Source)
nz.govt.mymsd.utils.AsposePDFConverter.convertPDFToPDFA(AsposePDFConverter.java:145)
ConvertTest.runTest(ConvertTest.java:90)
WorkerThread.processCommand(MultiThreadConvertTest.java:64)
WorkerThread.run(MultiThreadConvertTest.java:50)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
at com.aspose.pdf.internal.p17.z14.m10(Unknown Source)
at com.aspose.pdf.internal.p106.z1.m1(Unknown Source)
Actually I can see there is a CreationDate value in the DocumentInfo, not sure why Aspose complain about it.
Wondering if Aspose PDF converting works in the Java multi-thread environment? Have anyone got the same issue before?
Thanks