List of usage examples for com.lowagie.text Rectangle setTop
public void setTop(float ury)
From source file:org.geomajas.plugin.print.component.PdfContext.java
License:Open Source License
/** * Move this rectangle to the specified bottom-left point. * * @param rect rectangle to move// ww w . j av a 2 s.c o m * @param x new x origin * @param y new y origin */ public void moveRectangleTo(Rectangle rect, float x, float y) { float width = rect.getWidth(); float height = rect.getHeight(); rect.setLeft(x); rect.setBottom(y); rect.setRight(rect.getLeft() + width); rect.setTop(rect.getBottom() + height); }
From source file:org.geomajas.plugin.print.component.PdfContext.java
License:Open Source License
/** * Translate this rectangle over the specified following distances. * * @param rect rectangle to move/*from w w w .j a v a 2 s . co m*/ * @param dx delta x * @param dy delta y */ public void translateRectangle(Rectangle rect, float dx, float dy) { float width = rect.getWidth(); float height = rect.getHeight(); rect.setLeft(rect.getLeft() + dx); rect.setBottom(rect.getBottom() + dy); rect.setRight(rect.getLeft() + dx + width); rect.setTop(rect.getBottom() + dy + height); }
From source file:org.openconcerto.erp.core.finance.accounting.report.PdfGenerator.java
License:Open Source License
private void init() throws FileNotFoundException { // we create a reader for a certain document PdfReader reader = null;//from ww w.j av a 2 s. c o m PdfWriter writer = null; try { reader = new PdfReader(getStreamStatic(this.fileNameIn)); // we retrieve the total number of pages int n = reader.getNumberOfPages(); // we retrieve the size of the first page Rectangle psize = reader.getPageSize(1); psize.setRight(psize.getRight() - this.templateOffsetX); psize.setTop(psize.getTop() - this.templateOffsetY); this.width = (int) psize.getWidth(); float height = psize.getHeight(); // step 1: creation of a document-object int MARGIN = 32; this.document = new Document(psize, MARGIN, MARGIN, MARGIN, MARGIN); // step 2: we create a writer that listens to the document if (!this.directoryOut.exists()) { this.directoryOut.mkdirs(); } System.err.println("Directory out " + this.directoryOut.getAbsolutePath()); File f = new File(this.directoryOut, this.fileNameOut); if (f.exists()) { f.renameTo(new File(this.directoryOut, "Old" + this.fileNameOut)); f = new File(this.directoryOut, this.fileNameOut); } System.err.println("Creation du fichier " + f.getAbsolutePath()); writer = PdfWriter.getInstance(this.document, new FileOutputStream(f)); this.document.open(); // step 4: we add content this.cb = writer.getDirectContent(); System.out.println("There are " + n + " pages in the document."); this.document.newPage(); PdfImportedPage page1 = writer.getImportedPage(reader, 1); this.cb.addTemplate(page1, -this.templateOffsetX, -this.templateOffsetY); this.bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED); this.bfb = BaseFont.createFont(BaseFont.TIMES_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (FileNotFoundException fE) { throw fE; } catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } finally { if (reader != null) { reader.close(); } } }