We are facing a problem in our SAP PI (7.40) environment. We get invoices (XML, CSV, PDF) from different interfaces and during the process we have to send a TIFF file (converted from PDF via pdfbox/icafe4j) to OCR provider.
The PDF could be:
- an incoming PDF
- a generated PDF by our own (via pdfbox, from XML or CSV input).
The conversion is implemented in external Java classes. It works fine for most of the PDF files. There are only a few PDF files where we get an exception in our SAP PI environment which runs on Linux(!!). And the same conversion runs fine without any error in local Windows(!!) environment.
Part of the exception from Linux environment:
<?xml version="1.0" encoding="ISO-8859-1"?> <ErrorHandling> <ExceptionType>class java.lang.IndexOutOfBoundsException</ExceptionType <ExceptionLocalizedMsg>Index: 0, Size: 0</ExceptionLocalizedMsg> ...
Excerpt from Java implementation:
// pDoc is the PDDocument object, returns byte[]
bTiff = tiffFromPdf.createMultipageTIFF(pDoc);
sTiffBase64 = DatatypeConverter.printBase64Binary(bTiff);
this.fireTrace(1, "Content of sTiffBase64 -> [" + sTiffBase64 + "]");
// Trace 'normally' contains:
<Trace type="T" level="1">Content of sTiffBase64 -> [base64-encoded tiff data] </Trace>
// In createMultipageTIFF the exception occurs in this line
TIFFTweaker.writeMultipageTIFF(rout, param, images);
After we have found the following regarding an update to the TIFFTweaker
class, we implemented the update and after that the exception is not thrown but as mentioned in the link it is swallowed.
https://github.com/dragon66/icafe/issues/63
// Trace of byte[] then is emtpy:
<Trace type="T" level="1">Content of sTiffBase64 -> [] </Trace>
That is not very helpful as we must have the TIFF file for OCR.
We also had a look to the internals of PDF byte stream and found that there are some special parts handling with fonts/encoding:
TrueType font and "/Encoding /Identity-H" ... all PDF files which do not run under our Linux system contain this "Identity-H".
Does anyone has similar experience/error in doing this conversion on Linux?
Any idea what we can do in addition to our tries?
Maybe some libraries are missing under Linux or something else!?
Please also have a look at this conversion (maybe helpful for understanding):
https://www.mail-archive.com/[email protected]/msg09569.html
I start my initial entry for this question without any more code or affected PDF file but provide it if required.
Stack Trace:
RuntimeException during appliction Java mapping com/covestro/eai/cov/x01/apb/CheckAndPrepareEmailPDF Thrown: java.lang.RuntimeException: com.bbs.eai.bay0.x01.interfaces.MappingError: <?xml version="1.0" encoding="ISO-8859-1"?> <ErrorHandling> <ExceptionType>class java.lang.IndexOutOfBoundsException</ExceptionType> <CauseInfo>CheckAndPrepareEmailPDF: Check EmailPDF problem</CauseInfo> <ExceptionCause>null</ExceptionCause> <ExceptionMsg>Index: 0, Size: 0</ExceptionMsg> <ExceptionLocalizedMsg>Index: 0, Size: 0</ExceptionLocalizedMsg> <ExceptionStackTrace> <Trace> at java.util.ArrayList.RangeCheck Line 547</Trace> <Trace> at java.util.ArrayList.get Line 322</Trace> <Trace> at com.icafe4j.image.tiff.TIFFTweaker.writeMultipageTIFF Line 3154</Trace> <Trace> at com.covestro.eai.cov.x01.apb.pdf.CreateMultiTIFFFromPDF.createMultipageTIFF Line 113</Trace> <Trace> at com.covestro.eai.cov.x01.apb.CheckAndPrepareEmailPDF.transformStreamMapping Line 234</Trace> <Trace> at com.bbs.eai.bay0.x01.templates.JavaMappingTemplateV2.transform Line 731</Trace> <Trace> at com.sap.aii.ib.server.mapping.execution.JavaMapping.executeStep Line 112</Trace> <Trace> at com.sap.aii.ib.server.mapping.execution.Mapping.execute Line 60</Trace> <Trace> at com.sap.aii.ib.server.mapping.execution.SequenceMapping.executeStep Line 40</Trace> <Trace> at com.sap.aii.ib.server.mapping.execution.Mapping.execute Line 60</Trace> <Trace> at com.sap.aii.ib.server.mapping.execution.MappingHandler.map Line 87</Trace> <Trace> at com.sap.aii.ib.server.mapping.execution.MappingHandler.map Line 71</Trace> <Trace> at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleMappingRequest Line 123</Trace> <Trace> at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleRequest Line 73</Trace> <Trace> at com.sap.aii.ibrun.sbeans.mapping.MappingServiceImpl.processFunction Line 79</Trace> <Trace> at sun.reflect.GeneratedMethodAccessor406.invoke Line -1</Trace> <Trace> at sun.reflect.DelegatingMethodAccessorImpl.invoke Line 25</Trace> <Trace> at java.lang.reflect.Method.invoke Line 597</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.RequestInvocationContext.proceedFinal Line 47</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 166</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatesTransition.invoke Line 19</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 179</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Resource.invoke Line 50</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 179</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.doWorkWithAttribute Line 37</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.invoke Line 21</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 179</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_MethodRetry.invoke Line 46</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 179</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 191</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatelessInstanceGetter.invoke Line 23</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 179</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_SecurityCheck.invoke Line 25</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 179</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_ExceptionTracer.invoke Line 17</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 179</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.DefaultInvocationChainsManager.startChain Line 138</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke Line 172</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke Line 99</Trace> <Trace> at com.sun.proxy.$Proxy645.processFunction Line -1</Trace> <Trace> at sun.reflect.NativeMethodAccessorImpl.invoke0 Line -2</Trace> <Trace> at sun.reflect.NativeMethodAccessorImpl.invoke Line 39</Trace> <Trace> at sun.reflect.DelegatingMethodAccessorImpl.invoke Line 25</Trace> <Trace> at java.lang.reflect.Method.invoke Line 597</Trace> <Trace> at com.sap.engine.services.rfcengine.RFCDefaultRequestHandler.handleRequest Line 183</Trace> <Trace> at com.sap.engine.services.rfcengine.RFCJCOServer$J2EEApplicationRunnable.run Line 267</Trace> <Trace> at com.sap.engine.core.thread.impl3.ActionObject.run Line 37</Trace> <Trace> at java.security.AccessController.doPrivileged Line -2</Trace> <Trace> at com.sap.engine.core.thread.impl3.SingleThread.execute Line 185</Trace> <Trace> at com.sap.engine.core.thread.impl3.SingleThread.run Line 302</Trace> </ExceptionStackTrace> </ErrorHandling> at com.bbs.eai.bay0.x01.templates.JavaMappingTemplateV2.transform(JavaMappingTemplateV2.java:740) at com.sap.aii.ib.server.mapping.execution.JavaMapping.executeStep(JavaMapping.java:112) at com.sap.aii.ib.server.mapping.execution.Mapping.execute(Mapping.java:60) at com.sap.aii.ib.server.mapping.execution.SequenceMapping.executeStep(SequenceMapping.java:40) at com.sap.aii.ib.server.mapping.execution.Mapping.execute(Mapping.java:60) at com.sap.aii.ib.server.mapping.execution.MappingHandler.map(MappingHandler.java:87) at com.sap.aii.ib.server.mapping.execution.MappingHandler.map(MappingHandler.java:71) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleMappingRequest(MappingRequestHandler.java:123) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleRequest(MappingRequestHandler.java:73) at com.sap.aii.ibrun.sbeans.mapping.MappingServiceImpl.processFunction(MappingServiceImpl.java:79) at sun.reflect.GeneratedMethodAccessor406.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sap.engine.services.ejb3.runtime.impl.RequestInvocationContext.proceedFinal(RequestInvocationContext.java:47) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:166) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatesTransition.invoke(Interceptors_StatesTransition.java:19) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Resource.invoke(Interceptors_Resource.java:50) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.doWorkWithAttribute(Interceptors_Transaction.java:37) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.invoke(Interceptors_Transaction.java:21) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_MethodRetry.invoke(Interceptors_MethodRetry.java:46) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:191) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatelessInstanceGetter.invoke(Interceptors_StatelessInstanceGetter.java:23) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_SecurityCheck.invoke(Interceptors_SecurityCheck.java:25) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_ExceptionTracer.invoke(Interceptors_ExceptionTracer.java:17) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.DefaultInvocationChainsManager.startChain(DefaultInvocationChainsManager.java:138) at com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke(DefaultEJBProxyInvocationHandler.java:172) at com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke(DefaultEJBProxyInvocationHandler.java:99) at com.sun.proxy.$Proxy645.processFunction(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sap.engine.services.rfcengine.RFCDefaultRequestHandler.handleRequest(RFCDefaultRequestHandler.java:183) at com.sap.engine.services.rfcengine.RFCJCOServer$J2EEApplicationRunnable.run(RFCJCOServer.java:267) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:185) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:302) Caused by: com.bbs.eai.bay0.x01.interfaces.MappingError: <?xml version="1.0" encoding="ISO-8859-1"?> <ErrorHandling> <ExceptionType>class java.lang.IndexOutOfBoundsException</ExceptionType> <CauseInfo>CheckAndPrepareEmailPDF: Check EmailPDF problem</CauseInfo> <ExceptionCause>null</ExceptionCause> <ExceptionMsg>Index: 0, Size: 0</ExceptionMsg> <ExceptionLocalizedMsg>Index: 0, Size: 0</ExceptionLocalizedMsg> <ExceptionStackTrace> <Trace> at java.util.ArrayList.RangeCheck Line 547</Trace> <Trace> at java.util.ArrayList.get Line 322</Trace> <Trace> at com.icafe4j.image.tiff.TIFFTweaker.writeMultipageTIFF Line 3154</Trace> <Trace> at com.covestro.eai.cov.x01.apb.pdf.CreateMultiTIFFFromPDF.createMultipageTIFF Line 113</Trace> <Trace> at com.covestro.eai.cov.x01.apb.CheckAndPrepareEmailPDF.transformStreamMapping Line 234</Trace> <Trace> at com.bbs.eai.bay0.x01.templates.JavaMappingTemplateV2.transform Line 731</Trace> <Trace> at com.sap.aii.ib.server.mapping.execution.JavaMapping.executeStep Line 112</Trace> <Trace> at com.sap.aii.ib.server.mapping.execution.Mapping.execute Line 60</Trace> <Trace> at com.sap.aii.ib.server.mapping.execution.SequenceMapping.executeStep Line 40</Trace> <Trace> at com.sap.aii.ib.server.mapping.execution.Mapping.execute Line 60</Trace> <Trace> at com.sap.aii.ib.server.mapping.execution.MappingHandler.map Line 87</Trace> <Trace> at com.sap.aii.ib.server.mapping.execution.MappingHandler.map Line 71</Trace> <Trace> at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleMappingRequest Line 123</Trace> <Trace> at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleRequest Line 73</Trace> <Trace> at com.sap.aii.ibrun.sbeans.mapping.MappingServiceImpl.processFunction Line 79</Trace> <Trace> at sun.reflect.GeneratedMethodAccessor406.invoke Line -1</Trace> <Trace> at sun.reflect.DelegatingMethodAccessorImpl.invoke Line 25</Trace> <Trace> at java.lang.reflect.Method.invoke Line 597</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.RequestInvocationContext.proceedFinal Line 47</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 166</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatesTransition.invoke Line 19</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 179</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Resource.invoke Line 50</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 179</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.doWorkWithAttribute Line 37</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.invoke Line 21</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 179</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_MethodRetry.invoke Line 46</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 179</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 191</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatelessInstanceGetter.invoke Line 23</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 179</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_SecurityCheck.invoke Line 25</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 179</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.Interceptors_ExceptionTracer.invoke Line 17</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed Line 179</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.DefaultInvocationChainsManager.startChain Line 138</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke Line 172</Trace> <Trace> at com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke Line 99</Trace> <Trace> at com.sun.proxy.$Proxy645.processFunction Line -1</Trace> <Trace> at sun.reflect.NativeMethodAccessorImpl.invoke0 Line -2</Trace> <Trace> at sun.reflect.NativeMethodAccessorImpl.invoke Line 39</Trace> <Trace> at sun.reflect.DelegatingMethodAccessorImpl.invoke Line 25</Trace> <Trace> at java.lang.reflect.Method.invoke Line 597</Trace> <Trace> at com.sap.engine.services.rfcengine.RFCDefaultRequestHandler.handleRequest Line 183</Trace> <Trace> at com.sap.engine.services.rfcengine.RFCJCOServer$J2EEApplicationRunnable.run Line 267</Trace> <Trace> at com.sap.engine.core.thread.impl3.ActionObject.run Line 37</Trace> <Trace> at java.security.AccessController.doPrivileged Line -2</Trace> <Trace> at com.sap.engine.core.thread.impl3.SingleThread.execute Line 185</Trace> <Trace> at com.sap.engine.core.thread.impl3.SingleThread.run Line 302</Trace> </ExceptionStackTrace> </ErrorHandling> at com.bbs.eai.bay0.x01.templates.JavaMappingTemplateV2.makeAndLogMappingError(JavaMappingTemplateV2.java:717) at com.covestro.eai.cov.x01.apb.CheckAndPrepareEmailPDF.transformStreamMapping(CheckAndPrepareEmailPDF.java:351) at com.bbs.eai.bay0.x01.templates.JavaMappingTemplateV2.transform(JavaMappingTemplateV2.java:731) ... 44 more Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.RangeCheck(ArrayList.java:547) at java.util.ArrayList.get(ArrayList.java:322) at com.icafe4j.image.tiff.TIFFTweaker.writeMultipageTIFF(TIFFTweaker.java:3154) at com.covestro.eai.cov.x01.apb.pdf.CreateMultiTIFFFromPDF.createMultipageTIFF(CreateMultiTIFFFromPDF.java:113) at com.covestro.eai.cov.x01.apb.CheckAndPrepareEmailPDF.transformStreamMapping(CheckAndPrepareEmailPDF.java:234) ... 45 more