List of usage examples for com.lowagie.text Font BOLD
int BOLD
To view the source code for com.lowagie.text Font BOLD.
Click Source Link
From source file:org.apache.poi.xwpf.converter.internal.itext.PDFMapper.java
License:Open Source License
@Override protected void visitRun(XWPFRun run, IITextContainer pdfContainer) throws Exception { CTR ctr = run.getCTR();// w ww. j a va2 s . c o m // Get family name // Get CTRPr from style+defaults CTString rStyle = getRStyle(run); CTRPr runRprStyle = getRPr(super.getXWPFStyle(rStyle != null ? rStyle.getVal() : null)); CTRPr rprStyle = getRPr(super.getXWPFStyle(run.getParagraph().getStyleID())); CTRPr rprDefault = getRPr(defaults); // Font family String fontFamily = getFontFamily(run, rprStyle, rprDefault); // Get font size float fontSize = run.getFontSize(); // Get font style int fontStyle = Font.NORMAL; if (isBold(run, runRprStyle, rprStyle, rprDefault)) { fontStyle |= Font.BOLD; } if (isItalic(run, runRprStyle, rprStyle, rprDefault)) { fontStyle |= Font.ITALIC; } // Process color Color fontColor = null; String hexColor = getFontColor(run, runRprStyle, rprStyle, rprDefault); if (StringUtils.isNotEmpty(hexColor)) { if (hexColor != null && !"auto".equals(hexColor)) { fontColor = ColorRegistry.getInstance().getColor("0x" + hexColor); } } // Get font Font font = XWPFFontRegistry.getRegistry().getFont(fontFamily, options.getFontEncoding(), fontSize, fontStyle, fontColor); UnderlinePatterns underlinePatterns = run.getUnderline(); boolean singleUnderlined = false; switch (underlinePatterns) { case SINGLE: singleUnderlined = true; break; default: break; } List<CTBr> brs = ctr.getBrList(); for (@SuppressWarnings("unused") CTBr br : brs) { pdfContainer.addElement(Chunk.NEWLINE); } List<CTText> texts = run.getCTR().getTList(); for (CTText ctText : texts) { Chunk aChunk = new Chunk(ctText.getStringValue(), font); if (singleUnderlined) aChunk.setUnderline(1, -2); pdfContainer.addElement(aChunk); } super.visitPictures(run, pdfContainer); // <w:lastRenderedPageBreak /> List<CTEmpty> lastRenderedPageBreakList = ctr.getLastRenderedPageBreakList(); if (lastRenderedPageBreakList != null && lastRenderedPageBreakList.size() > 0) { // IText Document#newPage must be called to generate page break. // But before that, CTSectPr must be getted to compute pageSize, // margins... // The CTSectPr <w:pPr><w:sectPr w:rsidR="00AA33F7" // w:rsidSect="00607077"><w:pgSz w:w="16838" w:h="11906" // w:orient="landscape" />... Stack<CTSectPr> sectPrStack = getSectPrStack(); if (sectPrStack != null && !sectPrStack.isEmpty()) { CTSectPr sectPr = sectPrStack.pop(); applySectPr(sectPr); } for (CTEmpty lastRenderedPageBreak : lastRenderedPageBreakList) { pdfDocument.newPage(); } } }
From source file:org.apache.poi.xwpf.converter.internal.itext.StyleEngineForIText.java
License:Open Source License
private FontInfos processRPR(CTRPr ctParaRPr) { FontInfos fontInfos = new FontInfos(); CTFonts fonts = ctParaRPr.getRFonts(); if (fonts != null && fonts.getAscii() != null) { // font familly fontInfos.setFontFamily(fonts.getAscii()); }//from w w w.ja v a 2s . co m boolean bold = ctParaRPr.getB() != null && STOnOff.TRUE.equals(ctParaRPr.getB().xgetVal()); boolean italic = ctParaRPr.getI() != null && STOnOff.TRUE.equals(ctParaRPr.getI().xgetVal()); if (bold && italic) { fontInfos.setFontStyle(Font.BOLDITALIC); } else if (bold) { fontInfos.setFontStyle(Font.BOLD); } else if (italic) { fontInfos.setFontStyle(Font.ITALIC); } // font size CTHpsMeasure hpsMeasure = ctParaRPr.getSz(); if (hpsMeasure != null) { STHpsMeasure measure = hpsMeasure.xgetVal(); float size = measure.getBigDecimalValue().floatValue(); // cf. http://www.schemacentral.com/sc/ooxml/t-w_ST_HpsMeasure.html fontInfos.setFontSize(size / 2); } CTUnderline underline = ctParaRPr.getU(); int style = fontInfos.getFontStyle(); if (underline != null) { STUnderline uu = underline.xgetVal(); if (STUnderline.NONE != uu.enumValue()) { style = style | Font.UNDERLINE; fontInfos.setFontStyle(style); } } // font color... CTColor ctColor = ctParaRPr.getColor(); if (ctColor != null) { STHexColor hexColor = ctColor.xgetVal(); String strText = hexColor.getStringValue(); if (!"auto".equals(strText)) { Color color = ColorRegistry.getInstance().getColor("0x" + strText); fontInfos.setFontColor(color); } } // font encoding fontInfos.setFontEncoding(options.getFontEncoding()); return fontInfos; }
From source file:org.areasy.common.doclet.document.Fonts.java
License:Open Source License
public static Font getFont(int faceType, int style, int size) { Font font = null;//w w w . j a v a 2 s . c o m String lookup = String.valueOf(faceType); String fontFile = fontTable.getProperty(lookup); int fontStyle = Font.NORMAL; Color color = COLOR_BLACK; if ((style & LINK) != 0) { fontStyle += Font.UNDERLINE; color = COLOR_LINK; } else if ((style & UNDERLINE) != 0) fontStyle += Font.UNDERLINE; if ((style & STRIKETHROUGH) != 0) fontStyle += Font.STRIKETHRU; if (fontFile != null) { File file = new File(DefaultConfiguration.getWorkDir(), fontFile); if (file.exists() && file.isFile()) { try { String encoding = encTable.getProperty(lookup, BaseFont.CP1252); BaseFont bfComic = BaseFont.createFont(file.getAbsolutePath(), encoding, BaseFont.EMBEDDED); if ((style & AbstractConfiguration.ITALIC) > 0) { if ((style & AbstractConfiguration.BOLD) > 0) fontStyle += Font.BOLDITALIC; else fontStyle += Font.ITALIC; } else if ((style & AbstractConfiguration.BOLD) > 0) fontStyle += Font.BOLD; if (fontStyle != Font.NORMAL) font = new Font(bfComic, size, fontStyle, color); else font = new Font(bfComic, size); if (font == null) throw new IllegalArgumentException("Font null: " + fontFile); } catch (Exception e) { e.printStackTrace(); throw new IllegalArgumentException("Font unusable"); } } else DocletUtility.error("Font file not found: " + fontFile); } else { // Use predefined font String face = ""; if (faceType == TEXT_FONT) { face = FontFactory.HELVETICA; if ((style & AbstractConfiguration.ITALIC) > 0) { if ((style & AbstractConfiguration.BOLD) > 0) face = FontFactory.HELVETICA_BOLDOBLIQUE; else face = FontFactory.HELVETICA_OBLIQUE; } else if ((style & AbstractConfiguration.BOLD) > 0) face = FontFactory.HELVETICA_BOLD; } else { face = FontFactory.COURIER; if ((style & ITALIC) > 0) { if ((style & BOLD) > 0) face = FontFactory.COURIER_BOLDOBLIQUE; else face = FontFactory.COURIER_OBLIQUE; } else if ((style & BOLD) > 0) face = FontFactory.COURIER_BOLD; } if (fontStyle != Font.NORMAL) font = FontFactory.getFont(face, size, fontStyle, color); else font = FontFactory.getFont(face, size); } return font; }
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 w w w. j a v a 2 s . c o m*/ 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.caisi.tickler.web.TicklerPrinter.java
License:Open Source License
public void start() throws DocumentException, IOException { //Create the font we are going to print to bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); font = new Font(bf, FONTSIZE, Font.NORMAL); boldFont = new Font(bf, FONTSIZE, Font.BOLD); document = new Document(); writer = PdfWriterFactory.newInstance(document, os, FontSettings.HELVETICA_10PT); writer.setStrictImageSequence(true); document.setPageSize(PageSize.LETTER); document.open();//from w w w . j av a 2s . c o m }
From source file:org.cocktail.superplan.server.gestionimpression.TabularEdtReport.java
License:CeCILL license
public NSData genererPdf(NSArray creneaux, NSTimestamp debutSemaine, String semaine, String libelleFormation) throws DocumentException { ByteArrayOutputStream os = new ByteArrayOutputStream(); Document document = new Document(); PdfWriter.getInstance(document, os); document.open();// www . ja v a 2 s . c om document.setMargins(0, 0, 0, 0); Font font = new Font(Font.TIMES_ROMAN, 12, Font.BOLD, Color.DARK_GRAY); PdfPTable headerTable = new PdfPTable(1); PdfPCell cell = new PdfPCell(); Phrase ph = new Phrase(); ph.add(new Chunk(libelleFormation, font)); cell.setPhrase(ph); cell.setHorizontalAlignment(Element.ALIGN_CENTER); headerTable.addCell(cell); font = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL, Color.DARK_GRAY); cell = new PdfPCell(); ph = new Phrase(); ph.add(new Chunk(semaine, font)); cell.setPhrase(ph); cell.setHorizontalAlignment(Element.ALIGN_CENTER); headerTable.addCell(cell); headerTable.setWidthPercentage(100); headerTable.setSpacingAfter(5.0f); document.add(headerTable); PdfPTable pdfTable = creerCreneauxTable(creneaux, debutSemaine); pdfTable.setWidthPercentage(100); document.add(pdfTable); document.close(); return new NSData(os.toByteArray()); }
From source file:org.displaytag.render.ItextTableWriter.java
License:Artistic License
/** * Obtain the caption font; Meant to be overriden if a different style is desired. * @return The caption font.// w w w .ja v a 2 s . co m */ protected Font getCaptionFont() { return FontFactory.getFont(FontFactory.HELVETICA, 17, Font.BOLD, new Color(0x00, 0x00, 0x00)); }
From source file:org.displaytag.render.ItextTableWriter.java
License:Artistic License
/** * Makes chunk content bold./*from w w w . java 2 s . c om*/ * @param chunk The chunk whose content is to be rendered bold. * @param color The font color desired. */ private void setBoldStyle(Chunk chunk, Color color) { Font font = chunk.getFont(); chunk.setFont(FontFactory.getFont(font.getFamilyname(), font.getSize(), Font.BOLD, color)); }
From source file:org.eclipse.birt.report.engine.emitter.odp.device.OdpPage.java
License:Open Source License
protected void drawText(String text, float textX, float textY, float baseline, float width, float height, TextStyle textStyle) {/* w w w . ja va 2 s. com*/ // width of text is enlarged by 1 point because the text will be // automatically wrapped if the width of textbox equals to the width of // text exactly. FontInfo fontInfo = textStyle.getFontInfo(); float descend = fontInfo.getBaseFont().getFontDescriptor(BaseFont.DESCENT, fontInfo.getFontSize()); StyleEntry style = StyleBuilder.createEmptyStyleEntry(StyleConstant.TYPE_TEXT); style.setProperty(StyleConstant.DIRECTION_PROP, textStyle.getDirection()); style.setProperty(StyleConstant.COLOR_PROP, OdpUtil.getColorString(textStyle.getColor())); style.setProperty(StyleConstant.LETTER_SPACING, new FloatValue(FloatValue.CSS_PT, textStyle.getLetterSpacing() / PDFConstants.LAYOUT_TO_PDF_RATIO)); if (fontInfo != null) { BaseFont baseFont = fontInfo.getBaseFont(); String fontName = OdpUtil.getFontName(baseFont); style.setProperty(StyleConstant.FONT_FAMILY_PROP, fontName); style.setProperty(StyleConstant.FONT_SIZE_PROP, Double.valueOf(fontInfo.getFontSize())); if ((fontInfo.getFontStyle() & Font.BOLD) != 0) { style.setProperty(StyleConstant.FONT_WEIGHT_PROP, "bold"); } if ((fontInfo.getFontStyle() & Font.ITALIC) != 0) { style.setProperty(StyleConstant.FONT_STYLE_PROP, "italic"); } if (textStyle.isLinethrough()) { style.setProperty(StyleConstant.TEXT_LINE_THROUGH_PROP, true); } if (textStyle.isOverline()) { style.setProperty(StyleConstant.TEXT_OVERLINE_PROP, true); } if (textStyle.isUnderline()) { style.setProperty(StyleConstant.TEXT_UNDERLINE_PROP, true); } } // TODO: hyperlink context.addStyle(style); writer.drawText(text, textX, textY, width, height + descend * 0.6f, textFrameStyle, style, link); }
From source file:org.eclipse.birt.report.engine.emitter.pdf.PDFPage.java
License:Open Source License
private void setTextMatrix(PdfContentByte cb, FontInfo fi, float x, float y) { cb.concatCTM(1, 0, 0, 1, x, y);/*from w w w. j a va 2s .c om*/ if (!fi.getSimulation()) { cb.setTextMatrix(0, 0); return; } switch (fi.getFontStyle()) { case Font.ITALIC: { simulateItalic(cb); break; } case Font.BOLD: { simulateBold(cb, fi.getFontWeight()); break; } case Font.BOLDITALIC: { simulateBold(cb, fi.getFontWeight()); simulateItalic(cb); break; } } }