The problem occurs on page 4, the second time the image pdf is added, so the problem is probably related to that.
The construction of pageImage from reader_blancAvecImage was not included in your code snippets. Was it also created using getImportedPage? /Klas > ----- Original Message ----- From: "Mathieu MATHIAS" > <mmath...@deskom.com> > To: <itext-questions@lists.sourceforge.net> > Sent: Thursday, August 20, 2009 9:20 AM > Subject: [iText-questions] Bad result with merging PDF > > Hi, > I merge PDF1 (4 pages) with PDF2 (1 page) by inserting PDF2 between > every pages of PDF1. It creates a “recto-verso” printable PDF. > But the result creates a PDF that contains 3 pages well merged and 5 > pages unreadable with Acrobat Reader 9. > I use java 1.4.2 and iText 1.4.6. > > Can you please give me some help finding what is missing? > Thanks a lot. > > Here are pieces of my code: > > // PDF1 > PdfReader reader = new > PdfReader(repEntree+File.separator+pdfFile.getName()); > Rectangle rct = reader.getPageSizeWithRotation(1); > Document document = new Document(rct); > document.open(); > > // Final PDF > PdfCopy copy = new PdfCopy(document, new > FileOutputStream(repSortie+File.separator+pdfFile.getName())); > > // Loading an image > Image img = Image.getInstance(imageFile.getAbsolutePath()); > > // La hauteur d'une page est 842 > img.scaleToFit(10000, 842); > > // On positionne l'image depuis le coin en bas à gauche > img.setAbsolutePosition(0, 0); > > // PDF1 > File pdfImageFile = new File("image.pdf"); > if (pdfImageFile.exists()) > pdfImageFile.delete(); > Document document_blancAvecImage = new Document(rct); > writer_blancAvecImage = PdfWriter.getInstance(document_blancAvecImage, > new FileOutputStream(pdfImageFile)); > document_blancAvecImage.open(); > document_blancAvecImage.add(img); > document_blancAvecImage.close(); > reader_blancAvecImage = new PdfReader(pdfImageFile.getName()); > > // Do the copy > int nb_page = reader.getNumberOfPages(); > for (int j=1; j<=nb_page; j++) { > // Copie la page > PdfImportedPage page = copy.getImportedPage(reader, j); > copy.addPage(page); > copy.addPage(pageImage); > } > } > copy.close(); > document.close(); > > Regards, > Mathieu MATHIAS ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/