List of usage examples for com.lowagie.text Rectangle Rectangle
public Rectangle(Rectangle rect)
Rectangle
-object. From source file:com.teag.reports.EstatePlan.java
private void page1() { EstatePlanTable ept = new EstatePlanTable(); ClientBean cb = new ClientBean(); CFRow row;/*w w w. jav a 2 s .c om*/ float tallest = 0; drawHeader(client, ""); String header = "Estimate Of Cash Flows - Scenario #2 After (in 000's)"; Rectangle agt = placeHeading(header); cb.setPrimaryId(clientID); cb.initialize(); ept.setClient(cb); ept.setScenarioId(epg.getScenarioId()); ept.setEstate(epg); ept.initialize(); ept.resetRows(); int colCount = MAX_COLS; float baseWidths[] = this.initWidths(colCount - 1); float widths[] = this.calcWidths(baseWidths, 11.0f * 72); Rectangle rct = new Rectangle(prctFull); rct.setLeft(_1_4TH); rct.setRight(rct.getLeft() + 756); Rectangle r = doRow(leList(), widths, agt, colCount - 1); rct.setTop(r.getBottom()); r = doRow(agesList(), widths, rct, colCount - 1); rct.setTop(r.getBottom()); r = doRow(fiscalYearList(), widths, rct, colCount - 1); rct.setTop(r.getBottom()); tallest = tallest < r.getHeight() ? r.getHeight() : tallest; boolean nPage = false; while ((row = ept.getRow()) != null) { if (rct.getTop() < (.5f * 72) + tallest) { // need to span to a new page newPage(); drawHeader(client, ""); header = "Estimate Of Net Worth - Scenario #2 After (in 000's)"; agt = placeHeading(header); rct = new Rectangle(prctFull); rct.setLeft(_1_4TH); rct.setRight(rct.getLeft() + 756); r = doRow(leList(), widths, agt, colCount - 1); rct.setTop(r.getBottom()); r = doRow(agesList(), widths, rct, colCount - 1); rct.setTop(r.getBottom()); r = doRow(fiscalYearList(), widths, rct, colCount - 1); rct.setTop(r.getBottom()); tallest = tallest < r.getHeight() ? r.getHeight() : tallest; nPage = true; } String pdfRow[] = buildRow(row, colCount); //Rectangle r = doSimpleRow(pdfRow, rct); if ((row.getHeader().startsWith("III.") || row.getHeader().startsWith("IV.")) || row.getHeader().startsWith("II") && !nPage) { // need to span to a new page newPage(); drawHeader(client, ""); header = "Estimate Of Net Worth - Scenario #2 After (in 000's)"; agt = placeHeading(header); rct = new Rectangle(prctFull); rct.setLeft(_1_4TH); rct.setRight(rct.getLeft() + 756); r = doRow(leList(), widths, agt, colCount - 1); rct.setTop(r.getBottom()); r = doRow(agesList(), widths, rct, colCount - 1); rct.setTop(r.getBottom()); r = doRow(fiscalYearList(), widths, rct, colCount - 1); rct.setTop(r.getBottom()); tallest = tallest < r.getHeight() ? r.getHeight() : tallest; } nPage = false; r = this.doRow(pdfRow, widths, rct, colCount - 1); tallest = tallest < r.getHeight() ? r.getHeight() : tallest; rct.setTop(r.getBottom()); /* if(rct.getTop() < (.5f * 72) + tallest) { // need to span to a new page newPage(); drawHeader(client, ""); header = "Estimate Of Net Worth - Scenario #2 After (in 000's)"; agt = placeHeading(header); rct = new Rectangle(prctFull); rct.setLeft(_1_4TH); rct.setRight(rct.getLeft() + 756); r = doRow(leList(), widths, agt, colCount-1); rct.setTop(r.getBottom()); r = doRow(agesList(),widths,rct,colCount-1); rct.setTop(r.getBottom()); r = doRow(fiscalYearList(),widths,rct,colCount-1); rct.setTop(r.getBottom()); tallest = tallest < r.getHeight() ? r.getHeight() : tallest; nPage = true; } */ } }
From source file:com.teag.reports.EstatePlan.java
private Rectangle placeHeading(String header) { BaseFont font = PageUtils.LoadFont("GARA.TTF"); Rectangle rect = new Rectangle(document.getPageSize()); rect.setBottom(rect.getTop() - (72 * .6f)); HeadingText ht = new HeadingText(this.writer); rect.setBottom(rect.getBottom() - (72 * .33f)); ht.setColor(57, 57, 57);/*from w ww . j av a 2s .c om*/ ht.setCapsColor(98, 98, 98); ht.display(rect, 12f, font, 3f, header, HeadingText.DHT_CENTER); rect.setTop(rect.getBottom() - _1_8TH); rect.setBottom(prctFull.getBottom()); rect.setLeft(_1_2TH); rect.setRight(rect.getLeft() + 11.0f * 72); drawHeader(client, ""); PageBorder pb = new PageBorder(writer); pb.setLicense(userInfo.getPlannerFirstName() + " " + userInfo.getPlannerLastName()); pb.drawNoBorder(document, Integer.toString(pageNum)); drawLifeExp(); return (rect); }
From source file:include.nseer_cookie.MakePdf.java
License:Open Source License
public void make(String database, String tablename, String sql1, String sql2, String filename, int everypage, HttpSession session) {//from w w w . ja v a 2 s .co m try { nseer_db aaa = new nseer_db(database); nseer_db demo_db = new nseer_db(database); ServletContext context = session.getServletContext(); String path = context.getRealPath("/"); Masking reader = new Masking(configFile); Vector columnNames = new Vector(); Vector tables = reader.getTableNicks(); Iterator loop = tables.iterator(); while (loop.hasNext()) { String tablenick = (String) loop.next(); columnNames = reader.getColumnNames(tablenick); } int cpage = 1; //? int spage = 1; int ipage = everypage; String pagesql = sql1; //? ResultSet pagers = demo_db.executeQuery(pagesql); pagers.next(); int allCol = pagers.getInt("A"); allpage = (int) Math.ceil((allCol + ipage - 1) / ipage); // for (int m = 1; m <= allpage; m++) { spage = (m - 1) * ipage; String sql = sql2 + " limit " + spage + "," + ipage; ResultSet bbb = aaa.executeQuery(sql); //ResultSetMetaData tt=bbb.getMetaData(); // int b = columnNames.size(); // int a = 0; while (bbb.next()) { a++; } // bbb.first(); // ?? Rectangle rectPageSize = new Rectangle(PageSize.A4);// rectPageSize = rectPageSize.rotate(); Document document = new Document(rectPageSize, 20, 20, 20, 20); //? Document PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path + filename + m + ".pdf")); //?PDF?? document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); //? com.lowagie.text.Font FontChinese = new com.lowagie.text.Font(bfChinese, 8, com.lowagie.text.Font.NORMAL); // Paragraph title1 = new Paragraph("nseer ERP", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC)); Chapter chapter1 = new Chapter(title1, 1); // ? chapter1.setNumberDepth(0); Paragraph title11 = new Paragraph(tablename, FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD)); Section section1 = chapter1.addSection(title11); //? Table t = new Table(b, a); // ? t.setPadding(1); // t.setSpacing(0); // ? t.setBorderWidth(1); // do { // // for (int k = 0; k < b; k++) { // Cell cell = new Cell( new Paragraph(bbb.getString((String) columnNames.elementAt(k)), FontChinese)); //? // t.addCell(cell); // ? // } // } while (bbb.next()); // section1.add(t); // document.add(chapter1); // document.close(); } // ? } catch (Exception pp) { pp.printStackTrace(); } }
From source file:questions.images.TransparentPng.java
public static final void main(String[] args) throws IOException, DocumentException { Image img = Image.getInstance(IMAGE); Rectangle rectangle = new Rectangle(img); rectangle.setBackgroundColor(Color.YELLOW); Document document = new Document(rectangle); PdfWriter.getInstance(document, new FileOutputStream(RESULT)); document.open();//from ww w . j a v a 2 s .c o m img.setAbsolutePosition(0, 0); document.add(img); document.close(); }
From source file:questions.importpages.NameCards.java
public static void createSheet(int p) throws DocumentException, IOException { Rectangle rect = new Rectangle(PageSize.A4); Document document = new Document(rect); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(SHEET[p - 1])); document.open();//from w w w . j ava 2 s . c o m PdfContentByte canvas = writer.getDirectContentUnder(); PdfReader reader = new PdfReader(NameCard.CARD); PdfImportedPage front = writer.getImportedPage(reader, p); float x = rect.getWidth() / 2 - front.getWidth(); float y = (rect.getHeight() - (front.getHeight() * 5)) / 2; canvas.setLineWidth(0.5f); canvas.moveTo(x, y - 15); canvas.lineTo(x, y); canvas.lineTo(x - 15, y); canvas.moveTo(x + front.getWidth(), y - 15); canvas.lineTo(x + front.getWidth(), y); canvas.moveTo(x + front.getWidth() * 2, y - 15); canvas.lineTo(x + front.getWidth() * 2, y); canvas.lineTo(x + front.getWidth() * 2 + 15, y); canvas.stroke(); for (int i = 0; i < 5; i++) { for (int j = 0; j < 2; j++) { canvas.addTemplate(front, x, y); x += front.getWidth(); } x = rect.getWidth() / 2 - front.getWidth(); y += front.getHeight(); canvas.moveTo(x, y); canvas.lineTo(x - 15, y); canvas.moveTo(x + front.getWidth() * 2, y); canvas.lineTo(x + front.getWidth() * 2 + 15, y); canvas.stroke(); } canvas.moveTo(x, y + 15); canvas.lineTo(x, y); canvas.moveTo(x + front.getWidth(), y + 15); canvas.lineTo(x + front.getWidth(), y); canvas.moveTo(x + front.getWidth() * 2, y + 15); canvas.lineTo(x + front.getWidth() * 2, y); canvas.stroke(); document.close(); }