Ho do i merge two pdfs from byte arrays with different page sizes? I have wrote the followin code, it merges them but the page sizes are the same.
public static byte[] mergePdfs(byte[] firstPdf, byte[] lastPdf) ByteArrayOutputStream byteArrayOutputStream = null; byte[] mergedPdf = null; try{ Document document = new Document(); byteArrayOutputStream = new ByteArrayOutputStream(); PdfWriter pdfWriter = PdfWriter.getInstance(document, byteArrayOutputStream); document.open(); PdfContentByte pdfContentByte = pdfWriter.getDirectContent(); PdfImportedPage pdfImportedPage = null; PdfReader pdfReader = new PdfReader(firstPdf); for (int i = 0; i < pdfReader.getNumberOfPages(); i++) { document.newPage(); pdfImportedPage = pdfWriter.getImportedPage(pdfReader, i + 1); float width = pdfImportedPage.getWidth(); float height = pdfImportedPage.getHeight(); document.setPageSize(new Rectangle(width, height)); // doesent work pdfContentByte.addTemplate(pdfImportedPage, 0, 0); } pdfReader = new PdfReader(lastPdf); for (int i = 0; i < pdfReader.getNumberOfPages(); i++) { document.newPage(); pdfImportedPage = pdfWriter.getImportedPage(pdfReader, i + 1); float width = pdfImportedPage.getWidth(); float height = pdfImportedPage.getHeight(); document.setPageSize(new Rectangle(width, height)); // doesent work pdfContentByte.addTemplate(pdfImportedPage, 0, 0); } document.close(); mergedPdf = byteArrayOutputStream.toByteArray(); } -- View this message in context: http://www.nabble.com/Mergin-pdfs-tp25058642p25058642.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ 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/