Hi,
We're using the iText-2.1.2u.jar version to generate flattened pdf forms
with additional pdf files inserted. The following code illustrates how the
additional pdf files are inserted:
...
// read pdf attachment
InputStream is = getFileInputStream(con, diu);
if (is == null)
{
return;
}
PdfReader docReader = new PdfReader(is);
// note: pdf pages start with 1, not 0
for (int p = 1; p <= docReader.getNumberOfPages(); p++)
{
copy.addPage(copy.getImportedPage(docReader, p));
}
docReader.close();
is.close();
...
Our customer is having trouble with inserting a pdf file that was generated
from scanning a document into a pdf file. The "new PdfReader(is)" line
above keeps generating the exception below. I've searched online for the
cause of this error and learned that it's because the file is not ended
properly or is somehow corrupt, but I am able to open the pdf file just fine
with Adobe Reader; furthermore, I compared the ending of the file with other
pdf files that work just fine (using a text editor), and don't observe any
differences. Does anyone know how to resolve this issue?
Thanks,
Daniel
2013-10-01 10:29:19 [ ERROR] ajp-bio-8116-exec-1 Exception =
java.io.IOException: trailer not found.
java.io.IOException: trailer not found.
at com.lowagie.text.pdf.PdfReader.rebuildXref(Unknown Source)
at com.lowagie.text.pdf.PdfReader.readPdf(Unknown Source)
at com.lowagie.text.pdf.PdfReader.<init>(Unknown Source)
at com.lowagie.text.pdf.PdfReader.<init>(Unknown Source)
at
com.extraview.applogic.admin.PDFGenerationTool.insertDocument(PDFGenerationT
ool.java:627)
at
com.extraview.applogic.admin.PDFGenerationTool.applyDocumentAttachmentMappin
g(PDFGenerationTool.java:281)
at
com.extraview.applogic.admin.PDFGenerationTool.generatePDF(PDFGenerationTool
.java:178)
at
com.extraview.usercustom.CustomCodeBase.generateAndSavePdf(CustomCodeBase.ja
va:3663)
at
com.extraview.usercustom.CustomCodeBase.ucEditRefresh(CustomCodeBase.java:79
1)
at
com.extraview.usercustom.UserCustom.preEditRefresh(UserCustom.java:1699)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
com.extraview.usercustom.UserCustomProxy.invoke(UserCustomProxy.java:105)
at $Proxy6.preEditRefresh(Unknown Source)
at
com.extraview.presentation.Display.doEditDisplayRefresh(Display.java:1925)
at
com.extraview.presentation.Display.doEditDisplay(Display.java:1723)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at ExtraView.service(ExtraView.java:309)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:304)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:210)
at
com.planetj.servlet.filter.compression.CompressingFilter.doFilter(Compressin
gFilter.java:270)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:243)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:210)
at
com.extraview.presentation.JSPForwardingFilter.doFilter(JSPForwardingFilter.
java:38)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:243)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:224)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:175)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.java:472)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100
)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:196)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(Abstrac
tProtocol.java:515)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:
300)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source)
at java.lang.Thread.run(Unknown Source)
---------------------------------------
Daniel Borlean
Consulting Engineer
ExtraView Corporation
Scotts Valley, California, USA
(831) 461-7100 ext 117
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php