List of usage examples for com.lowagie.text Font BOLDITALIC
int BOLDITALIC
To view the source code for com.lowagie.text Font BOLDITALIC.
Click Source Link
From source file:org.unitime.timetable.util.PdfFont.java
License:Open Source License
private static Font createFont(float size, boolean fixed, boolean bold, boolean italic) { String font = null;/* ww w. j a v a 2 s . c om*/ if (fixed) font = ApplicationProperty.PdfFontFixed.value(); else if (bold) { if (italic) font = ApplicationProperty.PdfFontBoldItalic.value(); else font = ApplicationProperty.PdfFontBold.value(); } else if (italic) font = ApplicationProperty.PdfFontItalic.value(); else font = ApplicationProperty.PdfFontNormal.value(); if (font != null && !font.isEmpty()) { try { BaseFont base = BaseFont.createFont(font, BaseFont.IDENTITY_H, true); if (base != null) return new Font(base, size); } catch (Throwable t) { } } font = (fixed ? ApplicationProperty.PdfFontFixed.value() : ApplicationProperty.PdfFontNormal.value()); if (font != null && !font.isEmpty()) { try { BaseFont base = BaseFont.createFont(font, BaseFont.IDENTITY_H, true); if (base != null) return new Font(base, size, italic && bold ? Font.BOLDITALIC : italic ? Font.ITALIC : bold ? Font.BOLD : Font.NORMAL); } catch (Throwable t) { } } if (fixed) return FontFactory.getFont(bold ? italic ? FontFactory.COURIER_BOLDOBLIQUE : FontFactory.COURIER_BOLD : italic ? FontFactory.COURIER_OBLIQUE : FontFactory.COURIER, size); else return FontFactory .getFont(bold ? italic ? FontFactory.HELVETICA_BOLDOBLIQUE : FontFactory.HELVETICA_BOLD : italic ? FontFactory.HELVETICA_OBLIQUE : FontFactory.HELVETICA, size); }
From source file:oscar.eform.util.EFormPDFServlet.java
License:Open Source License
private void writeContent(Properties printCfg, Properties props, Properties measurements, float height, PdfContentByte cb) throws Exception { for (Enumeration e = printCfg.propertyNames(); e.hasMoreElements();) { StringBuilder temp = new StringBuilder(e.nextElement().toString()); String[] cfgVal = printCfg.getProperty(temp.toString()).split(" *, *"); String[] fontType = null; int fontFlags = 0; if (cfgVal[4].indexOf(";") > -1) { fontType = cfgVal[4].split(";"); if (fontType[1].trim().equals("italic")) fontFlags = Font.ITALIC; else if (fontType[1].trim().equals("bold")) fontFlags = Font.BOLD; else if (fontType[1].trim().equals("bolditalic")) fontFlags = Font.BOLDITALIC; else//from w ww .ja v a2s . c o m fontFlags = Font.NORMAL; } else { fontFlags = Font.NORMAL; fontType = new String[] { cfgVal[4].trim() }; } String encoding = null; if (fontType[0].trim().equals("BaseFont.HELVETICA")) { fontType[0] = BaseFont.HELVETICA; encoding = BaseFont.CP1252; //latin1 encoding } else if (fontType[0].trim().equals("BaseFont.HELVETICA_OBLIQUE")) { fontType[0] = BaseFont.HELVETICA_OBLIQUE; encoding = BaseFont.CP1252; } else if (fontType[0].trim().equals("BaseFont.ZAPFDINGBATS")) { fontType[0] = BaseFont.ZAPFDINGBATS; encoding = BaseFont.ZAPFDINGBATS; } else { fontType[0] = BaseFont.COURIER; encoding = BaseFont.CP1252; } BaseFont bf = BaseFont.createFont(fontType[0], encoding, BaseFont.NOT_EMBEDDED); String propValue = props.getProperty(temp.toString()); //if not in regular config then check measurements if (propValue == null) { propValue = measurements.getProperty(temp.toString(), ""); } ColumnText ct = new ColumnText(cb); // write in a rectangle area if (cfgVal.length >= 9) { Font font = new Font(bf, Integer.parseInt(cfgVal[5].trim()), fontFlags); ct.setSimpleColumn(Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), Integer.parseInt(cfgVal[7].trim()), (height - Integer.parseInt(cfgVal[8].trim())), Integer.parseInt(cfgVal[9].trim()), (cfgVal[0].trim().equals("left") ? Element.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? Element.ALIGN_RIGHT : Element.ALIGN_CENTER))); ct.setText(new Phrase(12, propValue, font)); ct.go(); continue; } // draw line directly if (temp.toString().startsWith("__$line")) { cb.setRGBColorStrokeF(0f, 0f, 0f); cb.setLineWidth(Float.parseFloat(cfgVal[4].trim())); cb.moveTo(Float.parseFloat(cfgVal[0].trim()), Float.parseFloat(cfgVal[1].trim())); cb.lineTo(Float.parseFloat(cfgVal[2].trim()), Float.parseFloat(cfgVal[3].trim())); cb.stroke(); } else if (temp.toString().startsWith("__")) { cb.beginText(); cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim())); cb.showTextAligned( (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT : PdfContentByte.ALIGN_CENTER)), (cfgVal.length >= 7 ? (cfgVal[6].trim()) : propValue), Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0); cb.endText(); } else { // write prop text cb.beginText(); cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim())); cb.showTextAligned( (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT : PdfContentByte.ALIGN_CENTER)), (cfgVal.length >= 7 ? ((propValue.equals("") ? "" : cfgVal[6].trim())) : propValue), Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0); cb.endText(); } } }
From source file:pl.exsio.ca.app.report.terraincard.view.TerrainCardsView.java
License:Open Source License
private Cell getColumnTitleCell(String title) throws Exception { Paragraph p = new Paragraph(title, this.getFont()); p.getFont().setSize(10);//w w w. j a v a 2s .c o m p.getFont().setStyle(Font.BOLDITALIC); p.setSpacingAfter(2); p.setSpacingBefore(2); Cell cell = new Cell(p); cell.setColspan(2); cell.setBackgroundColor(new Color(230, 230, 230)); return cell; }
From source file:pl.exsio.ca.app.report.terraincard.view.TerrainCardsView.java
License:Open Source License
private Cell getColumnDescCell(String desc) throws Exception { Paragraph p = new Paragraph(t(desc), this.getFont()); p.getFont().setSize(8);//from w ww . j a v a 2s. c o m p.getFont().setStyle(Font.BOLDITALIC); p.setSpacingAfter(2); p.setSpacingBefore(2); Cell cell = new Cell(p); cell.setBackgroundColor(new Color(230, 230, 230)); return cell; }
From source file:ro.nextreports.engine.exporter.RtfExporter.java
License:Apache License
private void updateFont(Font fnt, Map<String, Object> style) { if (style != null) { if (style.containsKey(StyleFormatConstants.FONT_FAMILY_KEY)) { String val = (String) style.get(StyleFormatConstants.FONT_FAMILY_KEY); fnt.setFamily(val); }//from ww w . j a v a 2s . c om if (style.containsKey(StyleFormatConstants.FONT_SIZE)) { Float val = (Float) style.get(StyleFormatConstants.FONT_SIZE); fnt.setSize(val); } if (style.containsKey(StyleFormatConstants.FONT_COLOR)) { Color val = (Color) style.get(StyleFormatConstants.FONT_COLOR); fnt.setColor(val); } if (style.containsKey(StyleFormatConstants.FONT_STYLE_KEY)) { if (StyleFormatConstants.FONT_STYLE_NORMAL.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) { fnt.setStyle(com.lowagie.text.Font.NORMAL); } if (StyleFormatConstants.FONT_STYLE_BOLD.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) { fnt.setStyle(com.lowagie.text.Font.BOLD); } if (StyleFormatConstants.FONT_STYLE_ITALIC.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) { fnt.setStyle(com.lowagie.text.Font.ITALIC); } if (StyleFormatConstants.FONT_STYLE_BOLDITALIC .equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) { fnt.setStyle(com.lowagie.text.Font.BOLDITALIC); } } } }
From source file:test.itext.html.AimsPdf.java
License:Open Source License
public static void addScreenShorts(Document doc, String text) throws BadElementException, IOException, DocumentException { Paragraph heading = new Paragraph("Screenshots", FontFactory.getFont("arial", 10, Font.UNDERLINE | Font.BOLDITALIC)); heading.setSpacingAfter(12f);/* w w w. ja v a2s.c o m*/ doc.add(heading); PdfPTable table = new PdfPTable(3); table.setWidthPercentage(80); table.setHorizontalAlignment(Element.ALIGN_CENTER); Image image = Image.getInstance("screen_shoot1.gif"); image.scalePercent(70); PdfPCell cell = new PdfPCell(image); cell.setPadding(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); image = Image.getInstance("screen_shoot2.gif"); image.scalePercent(70); cell = new PdfPCell(image); cell.setPadding(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); image = Image.getInstance("screen_shoot3.gif"); image.scalePercent(70); cell = new PdfPCell(image); cell.setPadding(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); image = Image.getInstance("screen_shoot4.gif"); image.scalePercent(70); cell = new PdfPCell(image); cell.setPadding(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); image = Image.getInstance("screen_shoot5.gif"); image.scalePercent(70); cell = new PdfPCell(image); cell.setPadding(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); image = Image.getInstance("screen_shoot6.gif"); image.scalePercent(70); cell = new PdfPCell(image); cell.setPadding(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); // doc.add(new Paragraph("\n")); doc.add(table); }
From source file:test.itext.html.AimsPdf.java
License:Open Source License
private static void writeData(Document doc, StringBuffer sb, String headingText) throws IOException, DocumentException { String data = Utility.replace(sb.toString(), "<p> </p>", "", Utility.REPLACE_ALL); data = Utility.replace(data, "</p>", "</p><br/>", Utility.REPLACE_ALL); data = Utility.replace(data, "</ul>", "</ul><br/>", Utility.REPLACE_ALL); data = Utility.replace(data, "</p><br/></td>", "</p></td>", Utility.REPLACE_ALL); System.out.println(data);/*from w w w . ja v a 2 s . c o m*/ Reader reader = new StringReader("<root>" + data + "</root>"); if (headingText != null && headingText.length() > 0) { Paragraph heading = new Paragraph(headingText, FontFactory.getFont("arial", 10, Font.UNDERLINE | Font.BOLDITALIC)); heading.setSpacingAfter(12f); doc.add(heading); } ArrayList objects = HTMLWorker.parseToList(reader, style, null); for (int k = 0; k < objects.size(); ++k) { Element ele = (Element) objects.get(k); doc.add(ele); } reader.close(); }
From source file:za.co.equalpay.web.utils.PDFExportUtility.java
public void postProcess() throws MalformedURLException, IOException, DocumentException { // document.open(); //// w w w . jav a 2 s . c o m // ByteArrayOutputStream baos = new ByteArrayOutputStream(); // PdfWriter writer = PdfWriter.getInstance(document, baos); // // writer.open(); // PdfContentByte cb = writer.getDirectContent(); // cb.addImage(image); ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext() .getContext(); String fontPath = LogoPathFinder.getFontPath(servletContext, "Tahoma"); BaseFont bf = BaseFont.createFont(fontPath, BaseFont.IDENTITY_H, true); Font tahoma = new Font(bf, 16, Font.BOLDITALIC); tahoma.setColor(Color.GRAY); Font boldFont8 = new Font(bf, 8, Font.BOLD, Color.GRAY); Font normalFont8 = new Font(bf, 8, Font.NORMAL, Color.GRAY); Font boldFont10 = new Font(bf, 10, Font.BOLDITALIC, Color.GRAY); Font normalFont10 = new Font(bf, 10, Font.ITALIC, Color.GRAY); phrase = new Phrase(); phrase.add(new Phrase("Exclusive Distributors of ", normalFont10)); phrase.add(new Phrase("SAM Medical, CONTERRA, TACMED Solutions ", boldFont10)); phrase.add(new Phrase("and ", normalFont10)); phrase.add(new Phrase("NARP ", boldFont10)); phrase.add(new Phrase("in South Africa.", normalFont10)); Paragraph paragraph = new Paragraph(phrase); paragraph.setAlignment(Paragraph.ALIGN_CENTER); document.add(paragraph); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100); // Terms & Conditions phrase = new Phrase(); phrase.add(new Phrase("\n\n\n")); phrase.add(new Phrase("Terms and Conditions: ", boldFont8)); phrase.add(new Phrase("\n")); phrase.add(new Phrase( "\n1. Full Payment in Advance, unless arranged otherwise. Orders will only be processed once payment reflects in our Bank Account.", normalFont8)); phrase.add(new Phrase("\n2. Prices are net.", normalFont8)); phrase.add(new Phrase("\n3. Delivery will be ex stock, alternatively 4 6 weeks from date of order.", normalFont8)); phrase.add( new Phrase("\n4. Shipping Lead Time will depend on clients mode of Transport.", normalFont8)); phrase.add(new Phrase("\n5. Prices and Supply of Goods are Subject to availability of stock.", normalFont8)); phrase.add(new Phrase("\n6. Prices are subject to exchange rate and brand.", normalFont8)); phrase.add(new Phrase("\n7. Quotation is valid for 30 Days", boldFont8)); phrase.add(new Phrase( "\n8. All capital equipment carries a one year guarantee against defective material and workmanship", normalFont8)); phrase.add(new Phrase("\n9. E & OA accepted.", normalFont8)); phrase.add(new Phrase("\n10. Excluding Postage, Packaging or Freight Forwarding to relevant Country.", normalFont8)); PdfPCell cell = new PdfPCell(phrase); cell.setBorder(0); table.addCell(cell); document.add(table); }