List of usage examples for com.lowagie.text Rectangle getRight
public float getRight()
From source file:ch.gpb.elexis.kgexporter.pdf.HeaderFooterPageEvent.java
License:Open Source License
public void onStartPage(PdfWriter writer, Document document) { Rectangle rect = writer.getBoxSize("art"); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, new Phrase(sbHeader), rect.getLeft(), rect.getTop(), 0); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT, new Phrase(sDate), rect.getRight(), rect.getTop(), 0); PdfContentByte cb = writer.getDirectContentUnder(); //cb.rectangle(document.left(), document.top(), // document.right() - document.left(), document.top() - 25); /*/*from w w w . j a v a 2 s.c om*/ System.out.println("l: " + document.left()); System.out.println("r: " + document.right()); System.out.println("t: " + document.top()); System.out.println("b: " + document.bottom()); l: 36.0 r: 559.0 t: 806.0 b: 36.0 */ //Rectangle rect2 = new Rectangle(document.top() - 36, document.top() - 36, 559, 1); /* float l = 36f; float r = 36f; float t = 559f; float b = 2f; Rectangle rect2 = new Rectangle(l, r, t, b); //Rectangle rect2 = new Rectangle(36, 36, 559, 1); rect2.setBorder(Rectangle.BOTTOM); rect2.setBorderWidth(0.5f); cb.rectangle(rect2); //cb.setColorStroke(Color.BLACK); */ /* for (int i = 30; i > 0; i--) { System.err.println((float) i / 10); cb.setLineWidth((float) i / 10); cb.moveTo(36, 806 - (5 * i)); cb.lineTo(400, 806 - (5 * i)); cb.stroke(); } cb.moveTo(10, 50); cb.lineTo(559, 50); */ cb.setLineWidth(0.5f); cb.moveTo(30, 791); cb.lineTo(559, 791); cb.stroke(); }
From source file:classroom.filmfestival_c.Movies19.java
protected static void drawGrid(PdfWriter writer, List<String> places, String day, float left, float column_width, float top, float row_height) { // CANVAS// www.j a v a 2 s. c o m PdfContentByte directcontent = writer.getDirectContent(); Rectangle art = writer.getBoxSize("art"); // LINES directcontent.setLineWidth(1); float bottom = art.getTop(); // rows int rows = places.size(); for (int i = 0; i <= rows; i++) { directcontent.moveTo(art.getLeft(), art.getTop() - (i * row_height)); directcontent.lineTo(art.getRight(), art.getTop() - (i * row_height)); bottom = art.getTop() - (i * row_height); } // Rectangle directcontent.moveTo(art.getLeft(), art.getTop()); directcontent.lineTo(art.getLeft(), bottom); directcontent.moveTo(left, art.getTop()); directcontent.lineTo(left, bottom); directcontent.moveTo(art.getLeft() + (COLUMNS * column_width), art.getTop()); directcontent.lineTo(art.getLeft() + (COLUMNS * column_width), bottom); directcontent.stroke(); // columns directcontent.saveState(); directcontent.setLineWidth(0.3f); directcontent.setColorStroke(SILVER); directcontent.setLineDash(3, 1); for (int i = 2; i < COLUMNS; i++) { directcontent.moveTo(art.getLeft() + (i * column_width), art.getTop()); directcontent.lineTo(art.getLeft() + (i * column_width), bottom); } directcontent.stroke(); directcontent.restoreState(); // TEXT // date directcontent.beginText(); directcontent.setFontAndSize(FONT, 12); directcontent.showTextAligned(Element.ALIGN_RIGHT, day, art.getLeft() - 5, art.getTop(), 90); directcontent.endText(); // time for (int i = 1; i < COLUMNS; i++) { directcontent.beginText(); directcontent.setFontAndSize(FONT, 8); directcontent.showTextAligned(Element.ALIGN_LEFT, TIME[i - 1], art.getLeft() + (i * column_width) + 5, top + 5, 90); directcontent.endText(); } // places for (int i = 0; i < rows; i++) { directcontent.beginText(); directcontent.setFontAndSize(FONT, 12); directcontent.showTextAligned(Element.ALIGN_CENTER, places.get(i), art.getLeft() + 16, art.getTop() - ((i + 0.5f) * row_height), 90); directcontent.endText(); } }
From source file:com.estate.pdf.Page.java
protected void drawRectangle(Rectangle rct, Color color) { drawLine(rct.getLeft(), rct.getTop(), rct.getLeft(), rct.getBottom(), color); // Left drawLine(rct.getLeft(), rct.getTop(), rct.getRight(), rct.getTop(), color); // Top drawLine(rct.getRight(), rct.getTop(), rct.getRight(), rct.getBottom(), color); // right drawLine(rct.getLeft(), rct.getBottom(), rct.getRight(), rct.getBottom(), color); // Bottom }
From source file:com.estate.pdf.Page.java
protected void drawSpacingGrid(Rectangle rct, float spacing, Color color) { PdfContentByte cb = writer.getDirectContentUnder(); cb.setLineWidth(.25f);/*www. java 2 s .c o m*/ cb.setColorStroke(color); for (float x = 0; x < rct.getRight(); x += spacing) { cb.moveTo(x, 0); cb.lineTo(x, rct.getTop()); } for (float y = 0; y < rct.getTop(); y += spacing) { cb.moveTo(0, y); cb.lineTo(rct.getRight(), y); } cb.stroke(); }
From source file:com.estate.pdf.Page.java
protected Rectangle toPage(float orgX, float orgY, Rectangle orgRect) { Rectangle rct = new Rectangle(orgRect); rct.setLeft(rct.getLeft() + orgX);/*from ww w. ja v a 2 s . co m*/ rct.setRight(rct.getRight() + orgX); rct.setTop(rct.getTop() + orgY); rct.setBottom(rct.getBottom() + orgY); return rct; }
From source file:com.estate.pdf.Page.java
protected Rectangle translateRect(Rectangle rct) { Rectangle rctPage = new Rectangle(document.getPageSize()); rct = new Rectangle(rct.getLeft(), rctPage.getTop() - rct.getBottom(), rct.getRight(), rctPage.getTop() - rct.getTop()); return (rct); }
From source file:com.estate.pdf.PageBorder.java
public void draw(Document doc, int iconNum, String pageNum, String toolName) { try {/*w w w .j av a2 s . co m*/ PdfContentByte cb = writer.getDirectContentUnder(); BaseFont fontBold = BaseFont.createFont(Locations.getFontLocation() + "timesbd.ttf", BaseFont.CP1252, BaseFont.EMBEDDED); BaseFont font = BaseFont.createFont(Locations.getFontLocation() + "times.ttf", BaseFont.CP1252, BaseFont.EMBEDDED); Rectangle rct = new Rectangle(doc.getPageSize()); float iconBase = (1.25f * 72); // This is the base of the icons on // the page Image icon = Image.getInstance(Locations.getImageLocation() + icons[iconNum]); // Image box = Image.getInstance(Locations.ImageLocation() + // "blueBOX.png"); icon.scalePercent(23); float scale = .23f; float iconLeft = (icon.getWidth() / 2) * scale; float boxSize = (.1875f * 72); // Adjust the top rct.setTop(rct.getTop() - (.5f * 72)); // Place the Icon icon.setAbsolutePosition((1.25f * 72) - iconLeft, rct.getTop() - iconBase); doc.add(icon); // Set our line color cb.setRGBColorStroke(0, 72, 117); cb.setLineWidth(.75f); // do the bottom line cb.moveTo(1.25f * 72, (.5f * 72)); cb.lineTo(rct.getRight() - (.5f * 72), (.5f * 72)); cb.moveTo(1.25f * 72, (.5f * 72)); cb.lineTo(1.25f * 72, rct.getTop()); // stroke the lines cb.stroke(); // Do the lower left box cb.rectangle((1.25f - 0.09375f) * 72, (.5f - 0.09375f) * 72, boxSize, boxSize); cb.setRGBColorFill(0, 72, 117); cb.closePathFillStroke(); // Do the lower right box Rectangle pnRect = new Rectangle(0, 0); pnRect.setLeft(rct.getRight() - ((.5f + 0.09375f) * 72)); pnRect.setTop((.5f - 0.09375f) * 72); pnRect.setRight(pnRect.getLeft() + boxSize); pnRect.setBottom(pnRect.getTop() - boxSize); // cb.rectangle(rct.getRight() - ((.5f + 0.09375f) * 72), (.5f - // 0.09375f) * 72, (.1875f * 72), (.1875f * 72)); cb.rectangle(pnRect.getLeft(), pnRect.getTop(), boxSize, boxSize); cb.setRGBColorFill(0, 72, 117); cb.closePathFillStroke(); // Now we do the page number if one is supplied. if (pageNum.length() > 0) { float pnHeight = fontBold.getAscentPoint(pageNum, 9) - fontBold.getDescentPoint(pageNum, 9); float pnWidth = fontBold.getWidthPoint(pageNum, 9); float l = pnRect.getLeft() + ((boxSize - pnWidth) / 2); float b = pnRect.getTop() + ((boxSize - pnHeight) / 2); cb.beginText(); cb.setFontAndSize(fontBold, 9); cb.setRGBColorFill(255, 255, 255); cb.setTextMatrix(l, b); cb.showText(pageNum); cb.endText(); } // Display the copyright SimpleDateFormat df = new SimpleDateFormat("yyyy"); char cs = 0x00a9; // Unicode for the copyright symbol String copyRight = com.estate.constants.StringConstants.copyRight + cs + " " + df.format(new Date()); float crWidth; float crLeft; crWidth = font.getWidthPoint(copyRight, 8); cb.beginText(); cb.setFontAndSize(font, 8); cb.setRGBColorFill(0, 0, 0); crLeft = (doc.getPageSize().getRight() - crWidth) / 2; cb.setTextMatrix(crLeft, .375f * 72); // Place the base of the // copyright at 3/8" up from // the bottom cb.showText(copyRight); cb.endText(); if (toolName.length() > 0) { cb.beginText(); cb.setFontAndSize(font, 8); cb.setRGBColorFill(0, 0, 0); cb.setTextMatrix((1.25f * 72) + boxSize, .375f * 72); cb.showText(toolName); cb.endText(); } // Fix a licensee at left cb.beginText(); cb.setFontAndSize(font, 8); cb.setRGBColorFill(0, 0, 0); cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, " Licensee: " + getLicense(), (10.2f * 72), .375f * 72, 0); cb.endText(); } catch (Exception e) { System.out.println(e.getMessage()); } }
From source file:com.estate.pdf.PageBorder.java
public void drawNoBorder(Document doc, String pageNum) { try {// w w w .j a v a2 s . c o m PdfContentByte cb = writer.getDirectContentUnder(); BaseFont fontBold = BaseFont.createFont(Locations.getFontLocation() + "timesbd.ttf", BaseFont.CP1252, BaseFont.EMBEDDED); BaseFont font = BaseFont.createFont(Locations.getFontLocation() + "times.ttf", BaseFont.CP1252, BaseFont.EMBEDDED); Rectangle rct = new Rectangle(doc.getPageSize()); float boxSize = (.1875f * 72); // Adjust the top rct.setTop(rct.getTop() - (.5f * 72)); // Do the lower right box Rectangle pnRect = new Rectangle(0, 0); pnRect.setLeft(rct.getRight() - ((.5f + 0.09375f) * 72)); pnRect.setTop(((.5f - 0.09375f) * 72) - 9); pnRect.setRight(pnRect.getLeft() + boxSize); pnRect.setBottom(pnRect.getTop() - boxSize); cb.rectangle(pnRect.getLeft(), pnRect.getTop(), boxSize, boxSize); cb.setRGBColorFill(0, 72, 117); cb.closePathFillStroke(); // Now we do the page number if one is supplied. if (pageNum.length() > 0) { float pnHeight = fontBold.getAscentPoint(pageNum, 9) - fontBold.getDescentPoint(pageNum, 9) - 4.5f; float pnWidth = fontBold.getWidthPoint(pageNum, 9); float l = pnRect.getLeft() + ((boxSize - pnWidth) / 2); float b = pnRect.getTop() + ((boxSize - pnHeight) / 2) - 4.5f; cb.beginText(); cb.setFontAndSize(fontBold, 9); cb.setRGBColorFill(255, 255, 255); cb.setTextMatrix(l, b); cb.showText(pageNum); cb.endText(); } // Display the copyright SimpleDateFormat df = new SimpleDateFormat("yyyy"); char cs = 0x00a9; // Unicode for the copyright symbol String copyRight = "Advanced Practice Network " + cs + " " + df.format(new Date()); float crWidth; float crLeft; crWidth = font.getWidthPoint(copyRight, 8); cb.beginText(); cb.setFontAndSize(font, 8); cb.setRGBColorFill(0, 0, 0); crLeft = (doc.getPageSize().getRight() - crWidth) / 2; cb.setTextMatrix(crLeft, .375f * 72); // Place the base of the // copyright at 3/8" up from // the bottom cb.showText(copyRight); cb.endText(); if (license != null) { // Fix a licensee at left cb.beginText(); cb.setFontAndSize(font, 8); cb.setRGBColorFill(0, 0, 0); cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, " Licensee: " + getLicense(), (10.2f * 72), .375f * 72, 0); cb.endText(); } } catch (Exception e) { System.out.println(e.getMessage()); } }
From source file:jdbreport.model.io.pdf.itext2.PdfWriter.java
License:Apache License
private PdfPTable createPdfTable(int columnCount, float[] widths, Rectangle pageSize) throws DocumentException { PdfPTable table;/*from w w w. jav a 2 s .co m*/ table = new PdfPTable(columnCount); table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT); table.setTotalWidth(widths); float widthPercentage = table.getTotalWidth() / (pageSize.getRight() - pageSize.getLeft()) * 100f; table.setWidthPercentage(widthPercentage); return table; }
From source file:net.sf.jsignpdf.PdfExtraInfo.java
License:Mozilla Public License
/** * Returns page info./* www . j a v a 2s . co m*/ * * @param aPage * number of page for which size should be returned * @return FloatPoint or null */ public PageInfo getPageInfo(int aPage) { PageInfo tmpResult = null; PdfReader reader = null; try { reader = PdfUtils.getPdfReader(options.getInFile(), options.getPdfOwnerPwdStrX().getBytes()); final Rectangle tmpRect = reader.getPageSizeWithRotation(aPage); if (tmpRect != null) { tmpResult = new PageInfo(tmpRect.getRight(), tmpRect.getTop()); } } catch (Exception e) { // nothing to do } finally { if (reader != null) { try { reader.close(); } catch (Exception e) { } } } return tmpResult; }