Thanks. My problem was fixed by this code: PdfReader reader = new PdfReader(sciezkaout + pliki[0]); PdfCopy copy = new PdfCopy(document, new FileOutputStream(sciezkaout + "sklejony.pdf")); document.open(); Rectangle crop = reader.getCropBox(1); PdfDictionary pagedict; for (String aPliki : pliki) { reader = new PdfReader(sciezkaout + aPliki); int nu_pages = reader.getNumberOfPages(); for (int j = 1; j <= nu_pages; j++) { if (crop.getWidth() != reader.getCropBox(j).getWidth() && crop.getHeight() != reader.getCropBox(j).getHeight()) { pagedict = reader.getPageN(j); pagedict.put(PdfName.MEDIABOX, new PdfRectangle(15, 0, 582, 820)); } copy.addPage(copy.getImportedPage(reader, j)); } } document.close();
So you can see you gave me a good direction. Thanks now everything works as i want. Pozdrawiam, Paweł Gawędzki -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bruno Lowagie Sent: Thursday, April 10, 2008 2:54 PM To: Post all your questions about iText here Subject: Re: [iText-questions] is it possible to grab and move whole contentof pdf ? Hello, > I got document that has few pages with content moved to much right. So > i want move this content to left side of document. Is it possible to > grab and move whole content of pdf to other position. If it is then how. Normally I'd advise you to do this with a tool like Acrobat Reader, because that's the easiest way. I wouldn't recommend writing code to do it with iText. However I see in your code that you are changing the cropbox (as a result of one of your previous question), so while you are at it, you could also change the mediabox. Suppose the mediabox is [ 0 0 595 842 ] (an A4 page) but you have a huge marging at the left and part of your text isn't showing on the right. Suppose we're talking about 5cm ( = 142 pt) then you could change the mediabox into [ 142 0 595 984 ]: pagedict.put(PdfName.MEDIABOX, new PdfRectangle(142, 0, 595, 984)); This will have the effect that everything moves 5cm to the left. Don't forget to change the cropbox accordingly or you risk having the same problem as before (text not showing). Read the following FAQ entry to find out more: http://www.1t3xt.com/docs/faq.php?branch=faq.pdf_in_general&node=pdfpage Note that I think it's dangerous to compare objects like rectangle like this: "crop != box". I think they will always be different, even if crop is equal to box. But that's a Java-related issue. br, Bruno ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Do you like iText? Buy the iText book: http://www.1t3xt.com/docs/book.php Or leave a tip: https://tipit.to/itexttipjar ------------------------------------------------------------------------------ Skandia Życie Towarzystwo Ubezpieczeń S.A. ul. Cybernetyki 7, 02-677 Warszawa Sąd Rejonowy dla m.st. Warszawy, XIII Wydział Gospodarczy Krajowego Rejestru Sądowego Nr KRS 0000056463, Regon: 016003836, NIP: 951-19-33-418 wysokość kapitału zakładowego: 46.000.000,00 PLN wysokość kapitału wpłaconego: 46.000.000,00 PLN ------------------------------------------------------------------------------ ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Do you like iText? Buy the iText book: http://www.1t3xt.com/docs/book.php Or leave a tip: https://tipit.to/itexttipjar