Hi, I have to to do some postprocessing on an existing pdf (created by iText):
1. rotate certain pages by 180 degress 2. combine 4 pages in 1 Both tasks could be solved with the list archives and the tutorial. However, somehow I cannot rotate first, then combine 4 in 1: the result does not have rotated pages, just as if the rotation step would have been omitted. I have put each task into a separate method: > private void rotatePages(InputStream is, OutputStream os) throws > IOException, DocumentException > { > PdfReader reader = new PdfReader(is); > int relativePage; > for (int i = 1; i <= reader.getNumberOfPages(); i++) > { > relativePage = ((i - 1) % 4) + 1; > if (relativePage == 2 || relativePage == 3) > reader.getPageN(i).put(PdfName.ROTATE, new PdfNumber(180)); > } > PdfStamper stp = new PdfStamper(reader, os); > stp.close(); > } > private void arrangePages(InputStream is, OutputStream os) > throws DocumentException, IOException > { > PdfReader reader = new PdfReader(is); > int pageCount = reader.getNumberOfPages(); > Rectangle pageSize = reader.getPageSize(1); > float width = pageSize.width(); > float height = pageSize.height(); > float subpageWidth = width / 2; > float subpageHeight = height / 2; > > Document document = new Document(pageSize, 50, 50, 50, 50); // TODO don't > use hardcoded margins > PdfWriter writer = PdfWriter.getInstance(document, os); > > document.open(); > PdfContentByte cb = writer.getDirectContent(); > PdfImportedPage page; > int i = 1; > while (i <= pageCount) > { > document.newPage(); > for (int y = 1; y >= 0 && i <= pageCount; y--) > for (int x = 0; x < 2 && i <= pageCount; x++, i++) > { > page = writer.getImportedPage(reader, i); > cb.addTemplate(page, .5f, 0, 0, .5f, x * subpageWidth, y * > subpageHeight); > } > } > document.close(); > writer.close(); > } I suppose that the rotation tag or option is lost when the pages are reread and rearranged. What can I do about this? Werner ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions