Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] PDF header signature not found

Bob Rogers

2006-06-26

Replies:

All,

I'm using iText to merge multiple pdfs together. However, under certain
conditions iText is throwing an exception with the above message.

Here is the code I use to merge docs together:

          /**
 * Merges a list of PDF documents
 * @param pdfGenerationContext
 */
 private void mergePDFs(PDFGenerationContext pdfGenerationContext) throws
EDistPDFException {
   logger.debug("Enter method");
   int fileCount = 0;
   com.lowagie.text.Document document = null;
   PdfCopy writer = null;
   IPDFPage pdfPage = null;
   ByteArrayOutputStream baos = null;

   try {
     Iterator iterator = pdfGenerationContext.getPdfPages().iterator();
     while (iterator.hasNext()){
       pdfPage = (IPDFPage) iterator.next();
       PdfReader reader = new PdfReader(pdfPage.getPDFBytes());

       if  (fileCount == 0){
         document = new
com.lowagie.text.Document(reader.getPageSizeWithRotation(1));
         baos = new ByteArrayOutputStream();
         writer = new PdfCopy(document, baos);
         document.open();
       }
       int pageCount = reader.getNumberOfPages();
       PdfImportedPage page = null;
       for (int i = 0; i < pageCount;){
         ++i;
         page = writer.getImportedPage(reader, i);
         writer.addPage(page);
       }
       fileCount++;
     }
     document.close();
   }
   catch(IOException ioe){
     logger.error("Error merging PDF: " + ioe.getMessage());
     throw new EDistPDFException(ioe);
   }
   catch(BadPdfFormatException badPdfe){
     logger.error("Error merging PDF: " + badPdfe.getMessage());
     throw new EDistPDFException(badPdfe.getMessage());
   }
   catch(com.lowagie.text.DocumentException dome){
     logger.error("Error merging PDF: " + dome.getMessage());
     throw new EDistPDFException(dome.getMessage());
   }

_________________________________________________________________
Don?t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
©2008 junlu.com - Jax Systems, LLC, U.S.A.