List of usage examples for com.lowagie.text Paragraph setSpacingAfter
public void setSpacingAfter(float spacing)
From source file:optika.sql.java
public void eksportoNePdf(String id) { Document document = new Document() { };//from www.ja v a 2s . co m try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("receta.pdf")); document.open(); document.setPageSize(PageSize.A3); Image img = Image.getInstance("receta.jpg"); img.setAbsolutePosition(450f, 10f); img.scaleToFit(600, 849); img.setAlignment(Image.LEFT | Image.ALIGN_BOTTOM | Image.ALIGN_BASELINE); img.setAbsolutePosition(0, 0); document.add(img); String[][] receta = merrReceten("select * from recetat where id=" + parseInt(id) + ";"); String[][] tabela = merrReceten("select * from tabela where recetat_id=" + parseInt(id) + ";"); int[] white = new int[tabela.length]; for (int i = 0; i < tabela.length; i++) { white[i] = 0; int bosh = 0; for (int j = 3; j < tabela[i].length; j++) { if (tabela[i][j] == tabela[i][6]) { continue; } if (!tabela[i][j].isEmpty()) { bosh = 1; } } if (bosh == 0) { white[i] = 1; } } Paragraph data = new Paragraph("Data: " + receta[0][7]); data.setSpacingBefore(38); data.setSpacingAfter(40); PdfPTable table = new PdfPTable(7); if (white[0] == 0) { table.addCell(getCellPadding("" + tabela[0][3], 1)); } else { table.addCell(getCellWhite("_", 1, 30)); } table.addCell(getCellPadding("" + tabela[0][4], 1)); table.addCell(getCellPadding("" + tabela[0][5], 1)); table.addCell(getCellPadding("", 1)); table.addCell(getCellPadding("" + tabela[0][7], 1)); table.addCell(getCellPadding("" + tabela[0][8], 1)); table.addCell(getCellPadding("" + tabela[0][9], 1)); table.setWidthPercentage(105); table.setHorizontalAlignment(-100); if (white[1] == 0) { table.addCell(getCellPadding("" + tabela[1][3], 1)); } else { table.addCell(getCellWhite("_", 1, 36)); } table.addCell(getCellPadding("" + tabela[1][4], 1)); table.addCell(getCellPadding("" + tabela[1][5], 1)); table.addCell(getCellPadding("", 1)); table.addCell(getCellPadding("" + tabela[1][7], 1)); table.addCell(getCellPadding("" + tabela[1][8], 1)); table.addCell(getCellPadding("" + tabela[1][9], 1)); table.setWidthPercentage(105); table.setHorizontalAlignment(-100); if (white[2] == 0) { if (white[1] == 0) { table.addCell(getCell("" + tabela[2][3], 1, 30)); } else { table.addCell(getCellWhite("_", 1, 23)); } } else { table.addCell(getCellWhite("_", 1, 28)); } table.addCell(getCell("" + tabela[2][4], 1, 0)); table.addCell(getCell("" + tabela[2][5], 1, 0)); table.addCell(getCell("", 1, 0)); table.addCell(getCell("" + tabela[2][7], 1, 0)); table.addCell(getCell("" + tabela[2][8], 1, 0)); table.addCell(getCell("" + tabela[2][9], 1, 0)); table.setWidthPercentage(105); table.setSpacingBefore(27); table.setHorizontalAlignment(-100); String[][] distanca = merrReceten("select * from distanca where recetat_id=" + parseInt(id) + ";"); PdfPTable largAfer = new PdfPTable(3); if (distanca[0][3].isEmpty()) { PdfPCell larg = getCellWhite("_", 2, 15); largAfer.addCell(larg); } else { PdfPCell larg = new PdfPCell(new Phrase("" + distanca[0][3])); larg.setPadding(0); larg.setHorizontalAlignment(2); larg.setBorder(PdfPCell.NO_BORDER); larg.setPaddingBottom(20); largAfer.addCell(larg); } largAfer.addCell(getCell("", PdfPCell.ALIGN_RIGHT, 25)); if (distanca[0][8].isEmpty()) { largAfer.addCell(getCellWhite("_", PdfPCell.ALIGN_RIGHT, 15)); } else { largAfer.addCell(getCell("" + distanca[0][8], PdfPCell.ALIGN_RIGHT, 25)); } largAfer.setWidthPercentage(75); largAfer.setHorizontalAlignment(350); PdfPTable od_os = new PdfPTable(5); od_os.addCell(getCell("OD= " + distanca[0][4], 0, 195)); od_os.addCell(getCell("OS= " + distanca[0][5], 2, 195)); od_os.addCell(getCell("", 0, 0)); od_os.addCell(getCell("OD= " + distanca[0][9], 0, 0)); od_os.addCell(getCell("OS= " + distanca[0][10], 1, 0)); od_os.setWidthPercentage(90); od_os.setHorizontalAlignment(150); PdfPTable visusi = new PdfPTable(2); if (distanca[0][6].isEmpty()) { PdfPCell od_pa = getCellWhite("_", 2, 17); od_pa.setPaddingRight(45); visusi.addCell(od_pa); } else { PdfPCell od_pa = getCell(distanca[0][6], 2, 17); od_pa.setPaddingRight(45); visusi.addCell(od_pa); } if (distanca[0][11].isEmpty()) { visusi.addCell(getCellWhite("_", 2, 17)); } else { visusi.addCell(getCell(distanca[0][11], 2, 17)); } if (distanca[0][7].isEmpty()) { PdfPCell os_pa = getCellWhite("_", 2, 17); os_pa.setPaddingRight(45); visusi.addCell(os_pa); } else { PdfPCell os_pa = getCell(distanca[0][7], 2, 17); os_pa.setPaddingRight(45); visusi.addCell(os_pa); } if (distanca[0][12].isEmpty()) { visusi.addCell(getCellWhite("_", 2, 17)); } else { visusi.addCell(getCell(distanca[0][12], 2, 0)); } visusi.setWidthPercentage(100); visusi.setHorizontalAlignment(50); String[][] admin = merrReceten("select * from admin where id=1;"); PdfPTable klienti = new PdfPTable(3); klienti.addCell(getCell("", 0, 0)); klienti.addCell(getCell("", 0, 0)); klienti.addCell(getCell("Emri: " + receta[0][2], 0, 0)); klienti.addCell(getCell("Celular: " + admin[0][4], 0, 0)); klienti.addCell(getCell("", 0, 0)); PdfPCell celReceta = getCell("Celular: " + receta[0][4], 0, 0); celReceta.setPaddingTop(5); klienti.addCell(celReceta); klienti.addCell(getCell("Email: " + admin[0][5], 0, 0)); klienti.addCell(getCell("", 0, 0)); PdfPCell emailReceta = getCell("Email: " + receta[0][5], 0, 0); emailReceta.setPaddingBottom(5); emailReceta.setPaddingTop(5); klienti.addCell(emailReceta); klienti.addCell(getCell("Adresa: " + admin[0][6], 0, 0)); klienti.addCell(getCell("", 0, 0)); klienti.addCell(getCell("Adresa: " + receta[0][6], 0, 0)); klienti.setSpacingBefore(50); PdfPTable kreu = new PdfPTable(1); kreu.addCell(getCell(" ", 0, 0)); document.add(kreu); document.add(klienti); document.add(data); document.add(table); document.add(largAfer); document.add(od_os); document.add(visusi); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:org.activityinfo.server.report.renderer.itext.ThemeHelper.java
License:Open Source License
public static Paragraph reportTitle(String title) { Paragraph para = new Paragraph(title); para.setFont(new Font(Font.TIMES_ROMAN, TITLE_FONT_SIZE, Font.NORMAL, BLUE)); para.setSpacingAfter(15); return para;/*w ww . java 2s. c o m*/ }
From source file:org.apache.poi.xwpf.converter.internal.itext.XWPFParagraphUtils.java
License:Open Source License
public static void processLayout(XWPFParagraph paragraph, Paragraph pdfParagraph, XWPFStyle style, CTDocDefaults defaults) {/* w w w . j a va 2 s . c om*/ float indentationLeft = -1; float indentationRight = -1; float firstLineIndent = -1; float spacingBefore = -1; float spacingAfter = -1; // 1) From style CTPPr ppr = getPPr(style); if (ppr != null) { // Indentation CTInd ind = ppr.getInd(); if (ind != null) { // Left Indentation BigInteger left = ind.getLeft(); if (left != null) { indentationLeft = dxa2points(left); } // Right Indentation BigInteger right = ind.getRight(); if (right != null) { indentationRight = dxa2points(right); } // First line Indentation BigInteger firstLine = ind.getFirstLine(); if (firstLine != null) { firstLineIndent = dxa2points(firstLine); } } // Spacing CTSpacing spacing = ppr.getSpacing(); if (spacing != null) { // Spacing before BigInteger before = spacing.getBefore(); if (before != null) { spacingBefore = dxa2points(before); } // Spacing after BigInteger after = spacing.getAfter(); if (after != null) { spacingAfter = dxa2points(after); } } // Text aligment CTTextAlignment textAligment = ppr.getTextAlignment(); if (textAligment != null) { // TODO } } // 2) From paragraph if (indentationLeft == -1 && paragraph.getIndentationLeft() != -1) { indentationLeft = dxa2points(paragraph.getIndentationLeft()); } if (indentationRight == -1 && paragraph.getIndentationRight() != -1) { indentationRight = dxa2points(paragraph.getIndentationRight()); } if (firstLineIndent == -1 && paragraph.getIndentationFirstLine() != -1) { firstLineIndent = dxa2points(paragraph.getIndentationFirstLine()); } if (spacingBefore == -1 && paragraph.getSpacingBefore() != -1) { spacingBefore = dxa2points(paragraph.getSpacingBefore()); } if (spacingAfter == -1 && paragraph.getSpacingAfter() != -1) { spacingAfter = dxa2points(paragraph.getSpacingAfter()); } // 3) From default // TODO // Apply if (indentationLeft != -1) { pdfParagraph.setIndentationLeft(indentationLeft); } if (indentationRight != -1) { pdfParagraph.setIndentationRight(indentationRight); } if (firstLineIndent != -1) { pdfParagraph.setFirstLineIndent(firstLineIndent); } if (spacingBefore != -1) { pdfParagraph.setSpacingBefore(spacingBefore); } if (spacingAfter != -1) { pdfParagraph.setSpacingAfter(spacingAfter); } // Aligment ParagraphAlignment alignment = paragraph.getAlignment(); switch (alignment) { case LEFT: pdfParagraph.setAlignment(Paragraph.ALIGN_LEFT); break; case RIGHT: pdfParagraph.setAlignment(Paragraph.ALIGN_RIGHT); break; case CENTER: pdfParagraph.setAlignment(Paragraph.ALIGN_CENTER); break; case BOTH: pdfParagraph.setAlignment(Paragraph.ALIGN_JUSTIFIED); break; } }
From source file:org.bambrikii.photobank.web.documents.paymentcertificates.impl.PaymentCertificateBuilderRU.java
public void build(OutputStream outputStream) throws DocumentGenerationException { Document doc = new Document(PageSize.A4); PdfWriter writer;//from www. ja v a 2 s . c om BaseFont baseFont = null; try { writer = PdfWriter.getInstance(doc, outputStream); writer.setEncryption(null, "qweasdzxc".getBytes(), PdfWriter.ALLOW_PRINTING, PdfWriter.ENCRYPTION_AES_128); doc.open(); String baseFontPath = getResourcesPath() + "org/bambrikii/photobank/web/documents/ARIAL.TTF"; final String stampImagePath = getResourcesPath() + "org/bambrikii/photobank/web/documents/paymentcertificates/PersonaStarsStamp.png"; baseFont = BaseFont.createFont(baseFontPath, "Cp1251", true); Font baseTextStyle = new com.lowagie.text.Font(baseFont, 10, com.lowagie.text.Font.NORMAL, new Color(0, 0, 0)); Font baseBoldTextStyle = new com.lowagie.text.Font(baseFont, 10, com.lowagie.text.Font.BOLD, new Color(0, 0, 0)); Calendar cal = Calendar.getInstance(getLocale()); cal.setTime(getData().getDate()); // Act number String actNumber = MessageFormat.format( "\u0410\u043a\u0442 \u2116 {0} \u043e\u0442 \u00ab{1}\u00bb {2} {3} \u0433\u043e\u0434\u0430", String.valueOf(getData().getNumber()), cal.get(Calendar.DAY_OF_MONTH), monthsGenitiveCase.get(cal.get(Calendar.MONTH)).toLowerCase(), String.valueOf(cal.get(Calendar.YEAR))); Paragraph actNumberParagraph = new Paragraph(actNumber, new com.lowagie.text.Font(baseFont, 12, com.lowagie.text.Font.BOLD, new Color(0, 0, 0))); actNumberParagraph.setSpacingAfter(19); Paragraph cityParagraph = new Paragraph("\u0433. \u041c\u043e\u0441\u043a\u0432\u0430", baseTextStyle); cityParagraph.setSpacingAfter(15); // Licensor Paragraph licensorParagraph = new Paragraph(); licensorParagraph .add(new Chunk("\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0440: ", baseBoldTextStyle)); licensorParagraph.add(new Chunk(MessageFormat.format("{0}", "\u0418\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c \u041b\u0438\u043f\u0430\u0442\u043d\u0438\u043a\u043e\u0432 \u0415\u0432\u0433\u0435\u043d\u0438\u0439 \u0410\u0440\u043a\u0430\u0434\u044c\u0435\u0432\u0438\u0447, \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0421\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u041e\u0413\u0420\u041d \u2116 305501025600011 \u043e\u0442 13.09.2005\u0433."), baseTextStyle)); licensorParagraph.setSpacingAfter(15); // Licensee Paragraph licenseeParagraph = new Paragraph(); licenseeParagraph .add(new Chunk("\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0442: ", baseBoldTextStyle)); licenseeParagraph.add(new Chunk(getData().getLicensee(), baseTextStyle)); licenseeParagraph.setSpacingAfter(15); // Pre text Paragraph pretextParagraph = new Paragraph(); pretextParagraph.add(new Chunk( "\u0412 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0414\u043e\u0433\u043e\u0432\u043e\u0440\u043e\u043c \u041e\u0444\u0435\u0440\u0442\u044b \u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0440 \u043f\u0435\u0440\u0435\u0434\u0430\u043b \u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0442\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f (\u0446\u0438\u0444\u0440\u043e\u0432\u044b\u0435 \u043a\u043e\u043f\u0438\u0438) \u0438 \u043d\u0435\u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 (\u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f): ", baseTextStyle)); pretextParagraph.setSpacingAfter(15); int defaultLeading = 9; // Files table Table filesTbl = new Table(5); filesTbl.setWidths(new int[] { 5, 35, 35, 10, 15 }); filesTbl.setBorder(Table.RECTANGLE); filesTbl.setBorderWidth(1); filesTbl.setSpacing(0); filesTbl.setPadding(2); filesTbl.setCellsFitPage(false); filesTbl.setUseVariableBorders(true); filesTbl.setAlignment(Element.ALIGN_LEFT); filesTbl.setWidth(100); Cell cellheader1 = new Cell(new Phrase(new Chunk("\u2116", baseBoldTextStyle))); cellheader1.setHeader(true); cellheader1.setLeading(defaultLeading); cellheader1.setHorizontalAlignment(Cell.ALIGN_CENTER); filesTbl.addCell(cellheader1); Cell cellheader2 = new Cell(new Phrase( new Chunk("\u041d\u043e\u043c\u0435\u0440 \u0444\u043e\u0442\u043e", baseBoldTextStyle))); cellheader2.setHeader(true); cellheader2.setLeading(defaultLeading); cellheader2.setHorizontalAlignment(Cell.ALIGN_CENTER); filesTbl.addCell(cellheader2); Cell cellheader3 = new Cell( new Phrase(new Chunk("\u041f\u0435\u0440\u0441\u043e\u043d\u0430", baseBoldTextStyle))); cellheader3.setHeader(true); cellheader3.setLeading(defaultLeading); cellheader3.setHorizontalAlignment(Cell.ALIGN_CENTER); filesTbl.addCell(cellheader3); Cell cellheader4 = new Cell( new Phrase(new Chunk("\u0420\u0430\u0437\u043c\u0435\u0440", baseBoldTextStyle))); cellheader4.setHeader(true); cellheader4.setLeading(defaultLeading); cellheader4.setHorizontalAlignment(Cell.ALIGN_CENTER); filesTbl.addCell(cellheader4); Cell cellheader5 = new Cell( new Phrase(new Chunk("\u0426\u0435\u043d\u0430 \u0440\u0443\u0431.", baseBoldTextStyle))); cellheader5.setHeader(true); cellheader5.setLeading(defaultLeading); cellheader5.setHorizontalAlignment(Cell.ALIGN_CENTER); filesTbl.addCell(cellheader5); filesTbl.endHeaders(); Integer i = 0; for (PaymentCertificateDataItem item : getData().getItems()) { i++; Cell cell1 = new Cell(new Phrase(new Chunk(Integer.toString(i), baseTextStyle))); cell1.setLeading(defaultLeading); cell1.setHorizontalAlignment(Cell.ALIGN_CENTER); cell1.setBorder(Cell.NO_BORDER); filesTbl.addCell(cell1); Cell cell2 = new Cell(new Phrase(new Chunk(item.getFilename(), baseTextStyle))); cell2.setLeading(defaultLeading); cell2.setHorizontalAlignment(Cell.ALIGN_LEFT); cell2.setBorder(Cell.NO_BORDER); filesTbl.addCell(cell2); Cell cell3 = new Cell(new Phrase(new Chunk(item.getName(), baseTextStyle))); cell3.setLeading(defaultLeading); cell3.setHorizontalAlignment(Cell.ALIGN_LEFT); cell3.setBorder(Cell.NO_BORDER); filesTbl.addCell(cell3); Cell cell4 = new Cell(new Phrase(new Chunk(item.getSizeName(), baseTextStyle))); cell4.setLeading(defaultLeading); cell4.setHorizontalAlignment(Cell.ALIGN_CENTER); cell4.setBorder(Cell.NO_BORDER); filesTbl.addCell(cell4); Cell cell5 = new Cell(new Phrase(new Chunk(Double.toString(item.getPrice()), baseTextStyle))); cell5.setLeading(defaultLeading); cell5.setHorizontalAlignment(Cell.ALIGN_CENTER); cell5.setBorder(Cell.NO_BORDER); filesTbl.addCell(cell5); } filesTbl.complete(); // filesTbl.normalize(); String totalPrice = MessageFormat.format("{0} {1}", String.valueOf(getData().getTotal()), getData().getCurrency()); Paragraph totalParagraph = new Paragraph(); totalParagraph.setAlignment(Paragraph.ALIGN_RIGHT); totalParagraph.add(new Chunk("\u0418\u0442\u043e\u0433\u043e: ", baseTextStyle)); totalParagraph.add(new Chunk(totalPrice, baseBoldTextStyle)); totalParagraph.setSpacingAfter(25); Paragraph posttext1Paragraph = new Paragraph(); posttext1Paragraph.add(new Chunk( "\u0412\u043e\u0437\u043d\u0430\u0433\u0440\u0430\u0436\u0434\u0435\u043d\u0438\u0435 \u0437\u0430 \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442: ", baseTextStyle)); posttext1Paragraph.add(new Chunk(totalPrice, baseBoldTextStyle)); // posttext1Paragraph.setSpacingAfter(15); Paragraph posttext2Paragraph = new Paragraph( "\u041d\u0414\u0421 \u043d\u0435 \u043e\u0431\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0443\u043d\u043a\u0442\u0430\u043c\u0438 2, 3 \u0438 5 \u0441\u0442\u0430\u0442\u044c\u0438 346.11 \u041d\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0435\u043a\u0441\u0430 \u0420\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0439 \u0424\u0435\u0434\u0435\u0440\u0430\u0446\u0438\u0438.", baseTextStyle); posttext2Paragraph.setSpacingAfter(15); Paragraph posttext3Paragraph = new Paragraph( "\u041f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0441\u0440\u043e\u043a\u043e\u043c \u043d\u0430 1 (\u043e\u0434\u0438\u043d) \u0433\u043e\u0434 \u0441 \u0434\u0430\u0442\u044b \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432 \u0410\u043a\u0442\u0435.", baseTextStyle); posttext3Paragraph.setSpacingAfter(15); Paragraph posttext4Paragraph = new Paragraph(); posttext4Paragraph.add(new Chunk( "\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0442 \u043d\u0435 \u0432\u043f\u0440\u0430\u0432\u0435 ", baseTextStyle)); posttext4Paragraph.add(new Chunk("(\u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442\u0441\u044f)", baseBoldTextStyle)); posttext4Paragraph.add(new Chunk( ": \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u043a\u043e\u043f\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438; \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u0442\u044c, \u0441\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u043a\u0430\u0442, \u0430\u0440\u0435\u043d\u0434\u0443, \u043b\u0438\u0437\u0438\u043d\u0433, \u043a\u0430\u043a \u0441\u0430\u043c\u0438 \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0442\u0430\u043a \u0438 \u0444\u0430\u0439\u043b\u044b \u0441 \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0434\u0438\u0437\u0430\u0439\u043d\u0435 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u0435\u0439, \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0445 \u043a\u0430\u0440\u0442\u043e\u0447\u0435\u043a \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043a, \u043f\u043e\u0441\u0442\u0435\u0440\u043e\u0432 \u0438 \u043e\u0431\u0440\u0430\u043c\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u043f\u0440\u043e\u0434\u0443\u043a\u0446\u0438\u0439 \u0432 \u0446\u0435\u043b\u044f\u0445 \u043f\u0440\u043e\u0434\u0430\u0436\u0438; \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0441\u0435\u0442\u044c \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u043c \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0442\u0440\u0435\u0442\u044c\u0438\u043c\u0438 \u043b\u0438\u0446\u0430\u043c\u0438, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c, \u0434\u0435\u043b\u0430\u044f \u0438\u0445 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438.", baseTextStyle)); posttext4Paragraph.setSpacingAfter(15); Paragraph posttext5Paragraph = new Paragraph( "\u0421\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e\u0442, \u0447\u0442\u043e \u0443\u0441\u043b\u0443\u0433\u0438 \u043f\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043f\u0440\u0430\u0432 \u043d\u0430 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438 \u0432 \u043f\u043e\u043b\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043c\u0435. \u0421\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u0440\u0435\u0442\u0435\u043d\u0437\u0438\u0439 \u0434\u0440\u0443\u0433 \u043a \u0434\u0440\u0443\u0433\u0443 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442.", baseTextStyle); posttext5Paragraph.setSpacingAfter(15); // Signatures Table signaturesTable = new Table(4); signaturesTable.setWidths(new int[] { 10, 40, 10, 40 }); signaturesTable.setWidth(100); signaturesTable.setSpacing(0); signaturesTable.setPadding(5); signaturesTable.setBorder(Table.NO_BORDER); Cell licensorSignature1Cell = new Cell(new Phrase( new Chunk("\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0440:", baseBoldTextStyle))); licensorSignature1Cell.setHorizontalAlignment(Cell.ALIGN_LEFT); licensorSignature1Cell.setBorder(Cell.NO_BORDER); Cell licensorSignature2Cell = new Cell(new Phrase(new Chunk( "______________/ \u041b\u0438\u043f\u0430\u0442\u043d\u0438\u043a\u043e\u0432 \u0415.\u0410. /", baseTextStyle))); licensorSignature2Cell.setHorizontalAlignment(Cell.ALIGN_LEFT); licensorSignature2Cell.setBorder(Cell.NO_BORDER); licensorSignature2Cell.addElement(new Paragraph("\n\n\n\n")); licensorSignature2Cell.add( // Stamp Image.getInstance(stampImagePath)); Cell licenseeSignature1Cell = new Cell(new Phrase( new Chunk("\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0442:", baseBoldTextStyle))); licenseeSignature1Cell.setHorizontalAlignment(Cell.ALIGN_LEFT); licenseeSignature1Cell.setBorder(Cell.NO_BORDER); Cell licenseeSignature2Cell = new Cell(new Phrase(new Chunk( MessageFormat.format("______________/ {0} /", getData().getLicensee()), baseTextStyle))); licenseeSignature2Cell.setHorizontalAlignment(Cell.ALIGN_LEFT); licenseeSignature2Cell.setBorder(Cell.NO_BORDER); signaturesTable.addCell(new Cell() { { setBorder(Cell.NO_BORDER); } }); signaturesTable.addCell(licensorSignature1Cell); signaturesTable.addCell(new Cell(true) { { setBorder(Cell.NO_BORDER); } }); signaturesTable.addCell(licenseeSignature1Cell); signaturesTable.addCell(new Cell(true) { { setBorder(Cell.NO_BORDER); } }); signaturesTable.addCell(licensorSignature2Cell); signaturesTable.addCell(new Cell(true) { { setBorder(Cell.NO_BORDER); } }); signaturesTable.addCell(licenseeSignature2Cell); signaturesTable.addCell(new Cell(true) { { setBorder(Cell.NO_BORDER); } }); signaturesTable.addCell(new Cell(true) { { setBorder(Cell.NO_BORDER); } }); signaturesTable.complete(); // PdfPTable signaturePdPfTable = signaturesTable.createPdfPTable(); // Document items doc.add(actNumberParagraph); doc.add(cityParagraph); doc.add(licensorParagraph); doc.add(licenseeParagraph); doc.add(pretextParagraph); doc.add(filesTbl); doc.add(totalParagraph); doc.add(posttext1Paragraph); doc.add(posttext2Paragraph); doc.add(posttext3Paragraph); doc.add(posttext4Paragraph); doc.add(posttext5Paragraph); doc.add(signaturesTable); doc.close(); } catch (DocumentException ex) { throw new DocumentGenerationException("Exception creating document.", ex); } catch (IOException ex) { throw new DocumentGenerationException( "Exception creating document, required font file may not be found.", ex); } }
From source file:org.flightgear.clgen.backend.PdfVisitor.java
License:Open Source License
@Override public void enter(final AbstractSyntaxTree ast) { try {/*from w w w .j av a 2 s. c o m*/ String title = ast.getProject() != null ? ast.getProject() : "Checklists"; Paragraph t = new Paragraph(title.toUpperCase(), H1); t.setSpacingAfter(12.0f); t.setAlignment(Element.ALIGN_CENTER); document.add(t); } catch (DocumentException e) { document.close(); throw new GeneratorException(e); } }
From source file:org.goodoldai.jeff.report.pdf.PDFReportBuilder.java
License:Open Source License
/** * This method inserts the header into the PDF report. The header consists * of general data collected from the explanation (date and time created, * owner, title, language and country). If any of this data is missing, it is not * inserted into the report. Since the report format is PDF, the provided * stream should be an instance of com.lowagie.text.Document. * //from w w w .j av a2 s . c o m * @param explanation explanation from which the header data is to be * collected * @param stream output stream that the header is supposed to be inserted * into * * @throws org.goodoldai.jeff.explanation.ExplanationException if any of the arguments are * null or if the entered output stream type is not com.lowagie.text.Document */ protected void insertHeader(Explanation explanation, Object stream) { if (explanation == null) { throw new ExplanationException("The argument 'explanation' is mandatory, so it can not be null"); } if (stream == null) { throw new ExplanationException("The argument 'stream' is mandatory, so it can not be null"); } if (!(stream instanceof Document)) { throw new ExplanationException("The entered stream must be a com.lowagie.text.Document instance"); } Document doc = (Document) stream; String owner = explanation.getOwner(); String title = explanation.getTitle(); doc.addCreator("JEFF (Java Explanation Facility Framework)"); doc.addAuthor(owner + " [OWNER]"); doc.addCreationDate(); if (title != null) { try { Phrase p = new Phrase(title, new Font(Font.HELVETICA, 16)); Paragraph pa = new Paragraph(p); pa.setSpacingBefore(10); pa.setSpacingAfter(30); pa.setAlignment(Element.ALIGN_CENTER); doc.add(pa); } catch (DocumentException ex) { throw new ExplanationException(ex.getMessage()); } } }
From source file:org.mapfish.print.config.layout.TextBlock.java
License:Open Source License
public void render(PJsonObject params, PdfElement target, final RenderingContext context) throws DocumentException { Paragraph paragraph = new Paragraph(); final Font pdfFont = getPdfFont(); paragraph.setFont(pdfFont);/*from w w w . j a v a 2 s. co m*/ final Phrase text = PDFUtils.renderString(context, params, this.text, pdfFont); paragraph.add(text); if (getAlign() != null) paragraph.setAlignment(getAlign().getCode()); paragraph.setSpacingAfter((float) spacingAfter); target.add(paragraph); }
From source file:org.mapfish.print.PdfTestCase.java
License:Open Source License
@Override protected void setUp() throws Exception { super.setUp(); PJsonObject spec = MapPrinter.parseSpec(FileUtilities.readWholeTextFile(new File("samples/spec.json"))); spec.getInternalObj().put("units", "meters"); doc = new Document(PageSize.A4); String baseDir = PdfTestCase.class.getClassLoader().getResource(".").getFile(); outFile = new FileOutputStream(baseDir + getClass().getSimpleName() + "_" + getName() + ".pdf"); writer = PdfWriter.getInstance(doc, outFile); writer.setFullCompression();/*from w ww . j a va 2 s. c om*/ createContext(spec); doc.setMargins(MARGIN, MARGIN, MARGIN, MARGIN * 3); doc.open(); doc.newPage(); final Paragraph title = new Paragraph("Test class=" + getClass().getName() + " method=" + getName()); title.setSpacingAfter(20); doc.add(title); }
From source file:org.sakaiproject.evaluation.tool.reporting.EvalPDFReportBuilder.java
License:Educational Community License
public void addTitlePage(String evaltitle, String groupNames, String startDate, String endDate, String responseInformation, byte[] bannerImageBytes, String evalSystemTitle, String informationTitle) { try {/* w w w . j a v a 2s .c o m*/ float pagefooter = paragraphFont.getSize(); PdfContentByte cb = pdfWriter.getDirectContent(); float docMiddle = (document.right() - document.left()) / 2 + document.leftMargin(); Paragraph emptyPara = new Paragraph(" "); emptyPara.setSpacingAfter(100.0f); // Title Paragraph titlePara = new Paragraph("\n\n\n" + evaltitle, frontTitleFont); titlePara.setAlignment(Element.ALIGN_CENTER); document.add(titlePara); // Groups Paragraph groupPara = new Paragraph(groupNames, frontAuthorFont); groupPara.setSpacingBefore(25.0f); groupPara.setAlignment(Element.ALIGN_CENTER); document.add(groupPara); // Little info area? I don't know, it was on the mockup though Paragraph infoPara = new Paragraph(informationTitle, frontInfoFont); infoPara.setAlignment(Element.ALIGN_CENTER); infoPara.setSpacingBefore(90.0f); document.add(infoPara); // Started on Paragraph startedPara = new Paragraph(startDate, frontInfoFont); startedPara.setAlignment(Element.ALIGN_CENTER); startedPara.setSpacingBefore(25.0f); document.add(startedPara); // Ended on Paragraph endedPara = new Paragraph(endDate, frontInfoFont); endedPara.setAlignment(Element.ALIGN_CENTER); endedPara.setSpacingBefore(25.0f); document.add(endedPara); // Reply Rate Paragraph replyRatePara = new Paragraph(responseInformation, frontInfoFont); replyRatePara.setAlignment(Element.ALIGN_CENTER); replyRatePara.setSpacingBefore(25.0f); document.add(replyRatePara); // Logo and Tagline cb.beginText(); cb.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 12); cb.showTextAligned(PdfContentByte.ALIGN_CENTER, evalSystemTitle, docMiddle, document.bottom() + 20, 0); cb.endText(); if (bannerImageBytes != null) { Image banner = Image.getInstance(bannerImageBytes); cb.addImage(banner, banner.getWidth(), 0, 0, banner.getHeight(), docMiddle - (banner.getWidth() / 2), document.bottom() + 35); } document.newPage(); responseArea = new ColumnText(cb); responseArea.setSimpleColumn(document.left(), document.top(), document.right() / 2, document.bottom() + pagefooter); responseArea.go(); } catch (DocumentException | IOException de) { throw UniversalRuntimeException.accumulate(de, "Unable to create title page"); } }
From source file:org.sakaiproject.evaluation.tool.reporting.EvalPDFReportBuilder.java
License:Educational Community License
public void addSectionHeader(String headerText, boolean lastElementIsHeader, float theSize) { LOG.debug("Added a header with text: " + headerText + " and size: " + theSize + ". Previous element was another header: " + lastElementIsHeader); if (!lastElementIsHeader) { Paragraph emptyPara = new Paragraph(" "); this.addElementWithJump(emptyPara, true); }// w ww . j a v a2s . c o m Paragraph headerPara = new Paragraph(headerText); Font fuente = headerPara.getFont(); fuente.setSize(theSize); headerPara.setFont(fuente); headerPara.setSpacingAfter(SPACING_AFTER_HEADER); this.addElementWithJump(headerPara, true); }