Hi Group, I have a PDF file. I have to generate a new PDF from this PDF with margins mirrored.
NOTE that, the original PDF file also has margins but those are not mirrored but are flat across the pages. There by I have used PdfReader and PdfSmartCopy classes to copy the pages from source PDF to destination PDF, but however, the final new PDF has no margins set and is almost same as source PDF! Following is the full source of this functionality: <code> PdfReader sourcePdf = new PdfReader(new FileInputStream(pdfInfoBean.pdfFileAbsolutePath())); String marginMirroredPdfFilePath = pdfInfoBean.getPdfPath() + destinationFileName; float marginLeftInPoints = MemoryBookPdfUtil.convertInchesToPoints(pdfInfoBean.getInsideMargin()); float marginRightInPoints = MemoryBookPdfUtil.convertInchesToPoints(pdfInfoBean.getOutsideMargin()); float marginTopInPoints = MemoryBookPdfUtil.convertInchesToPoints(pdfInfoBean.getMarginTop()); float marginBottomInPoints = MemoryBookPdfUtil.convertInchesToPoints(pdfInfoBean.getMarginBottom()); Rectangle psize = sourcePdf.getPageSizeWithRotation(1); Document document = new Document(psize, marginLeftInPoints, marginRightInPoints, marginTopInPoints, marginBottomInPoints); document.setMarginMirroring(true); PdfSmartCopy marginMirroredPdf = new PdfSmartCopy(document, new FileOutputStream(marginMirroredPdfFilePath)); marginMirroredPdf.setMargins(marginLeftInPoints, marginRightInPoints, marginTopInPoints, marginBottomInPoints); marginMirroredPdf.setMarginMirroring(true); document.open(); int noOfPages = sourcePdf.getNumberOfPages(); for(int i = 1; i <= noOfPages; i++) { marginMirroredPdf.addPage(marginMirroredPdf.getImportedPage(sourcePdf, i)); } document.close(); </code> Could anyone please advise the problem here and probable solution. Thank in advance, Shravan M -- View this message in context: http://itext-general.2136553.n4.nabble.com/Margin-Mirroring-is-not-working-tp3315090p3315090.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php