List of usage examples for com.lowagie.text FontFactory getFont
public static Font getFont(String fontname, float size, int style, Color color)
Font
-object. From source file:org.cyberoam.iview.charts.Chart.java
License:Open Source License
/** * Function for getting report PdfPtable instance for given report and record set * @param report bean specifies the report for which table is generated * @param rsw specifies Result set collection * @return instance of PdfPtable// w w w . ja v a 2 s . co m */ public static PdfPTable getPdfPTable(ReportBean reportBean, ResultSetWrapper rsw) { PdfPTable pdfTable = null; try { rsw.last(); //int rowCount=rsw.getRow(); ReportColumnBean[] reportColumns = (ReportColumnBean[]) ReportColumnBean .getReportColumnsByReportID(reportBean.getReportId()).toArray(new ReportColumnBean[0]); pdfTable = new PdfPTable(reportColumns.length); // Adding Column Name to PDF Table PdfPCell headCell; for (int count = 0; count < reportColumns.length; count++) { headCell = new PdfPCell(new Phrase(18, new Chunk(reportColumns[count].getColumnName(), FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16, Font.BOLD, Color.blue)))); headCell.setBackgroundColor(new Color(238, 238, 238)); pdfTable.addCell(headCell); } String data; int i = 0; rsw.beforeFirst(); while (rsw.next()) { for (int j = 0; j < reportColumns.length; j++) { if (reportColumns[j].getColumnFormat() == TabularReportConstants.BYTE_FORMATTING) { data = ByteInUnit.getBytesInUnit(rsw.getLong(reportColumns[j].getDbColumnName())); } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.PERCENTAGE_FORMATTING) { data = rsw.getString(reportColumns[j].getDbColumnName()) + " %"; } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.DECODE_FORMATTING) { data = URLDecoder.decode(rsw.getString(reportColumns[j].getDbColumnName())); } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.PROTOCOL_FORMATTING) { int index = rsw.getString(reportColumns[j].getDbColumnName()).indexOf(':'); if (index != -1) { data = ProtocolBean.getProtocolNameById(Integer.parseInt( rsw.getString(reportColumns[j].getDbColumnName()).substring(0, index))); data = data + rsw.getString(reportColumns[j].getDbColumnName()).substring(index, rsw.getString(reportColumns[j].getDbColumnName()).length()); } else { data = rsw.getString(reportColumns[j].getDbColumnName()); } } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.SEVERITY_FORMATTING) { data = TabularReportConstants .getSeverity(rsw.getString(reportColumns[j].getDbColumnName())); } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.ACTION_FORMATTING) { data = TabularReportConstants.getAction(rsw.getString(reportColumns[j].getDbColumnName())); } else { data = rsw.getString(reportColumns[j].getDbColumnName()); } if (data == null || "".equalsIgnoreCase(data)) data = "N/A"; pdfTable.addCell(data); } i++; } } catch (SQLException e) { CyberoamLogger.sysLog.debug("Chart.getPDFPTable.e" + e, e); } return pdfTable; }
From source file:org.cyberoam.iview.charts.Chart.java
License:Open Source License
public static void generatePDFReport(OutputStream out, int reportID, String applianceID, String startDate, String endDate, String limit, int[] deviceIDs, HttpServletRequest request, int reportGroupID, LinkedHashMap paramMap) throws Exception { float width = 768; float height = 1024; float rec_hieght = 470; Rectangle pagesize = new Rectangle(768, 1024); Document document = new Document(pagesize, 30, 30, 30, 30); IndexManager indexManager = null;//w ww .ja va 2s . c om JFreeChart chart = null; SqlReader sqlReader = new SqlReader(false); CyberoamLogger.sysLog.debug("reportID:" + reportID); CyberoamLogger.sysLog.debug("applianceID:" + applianceID); CyberoamLogger.sysLog.debug("startDate:" + startDate); CyberoamLogger.sysLog.debug("endDate:" + endDate); CyberoamLogger.sysLog.debug("limit:" + limit); try { //PdfWriter writer = PdfWriter.getInstance(document, response!=null ? response.getOutputStream():new FileOutputStream(pdfFileName)); PdfWriter writer = PdfWriter.getInstance(document, out); writer.setPageEvent(new Chart()); document.addAuthor("iView"); document.addSubject("iView Report"); document.open(); PdfContentByte contentByte = writer.getDirectContent(); //ReportGroupBean reportGroupBean=ReportGroupBean.getRecordbyPrimarykey(reportGroupID); //ArrayList reportList=reportGroupBean.getReportIdByReportGroupId(reportGroupID); ReportBean reportBean; ResultSetWrapper rsw = null; String seperator = System.getProperty("file.separator"); // String path=System.getProperty("catalina.home") +seperator+"webapps" +seperator+"ROOT" + seperator + "images" + seperator; String path = InitServlet.contextPath + seperator + "images" + seperator + "iViewPDF.jpg"; /* * Loading Image to add into PDF */ Image iViewImage = Image.getInstance(path); iViewImage.scaleAbsolute(750, 900); //iViewImage.scaleAbsolute(600,820); iViewImage.setAbsolutePosition(10, 10); /*Image headerImage= Image.getInstance(path+ "iViewPDFHeader.jpg"); PdfPTable headerTable = new PdfPTable(2); PdfPCell cell = new PdfPCell(headerImage); headerTable.addCell(cell); HeaderFooter docHeader=null; //document.setHeader(new HeaderFooter(new Phrase(new Chunk())), true); */ document.add(iViewImage); document.add(new Paragraph("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")); /* * Generating Table on the First Page of Report providing summary of Content */ PdfPTable frontPageTable = new PdfPTable(2); PdfPCell dataCell; String reportName = ""; Color tableHeadBackColor = new Color(150, 174, 190); Color tableContentBackColor = new Color(229, 232, 237); Color tableBorderColor = new Color(229, 232, 237); dataCell = new PdfPCell(new Phrase(new Chunk("Report Profile", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16, Font.PLAIN, new Color(255, 255, 255))))); dataCell.setBackgroundColor(tableHeadBackColor); dataCell.setBorderColor(tableBorderColor); frontPageTable.addCell(dataCell); if (paramMap != null) { reportName = paramMap.get("title").toString(); paramMap.remove("title"); } if (request != null) { ReportGroupBean reportGroupBean = ReportGroupBean.getRecordbyPrimarykey(reportGroupID); reportName = getFormattedTitle(request, reportGroupBean, true); } dataCell = new PdfPCell(); dataCell.addElement(new Phrase(new Chunk(reportName, FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(255, 255, 255))))); //dataCell.addElement(new Phrase(new Chunk(ReportBean.getRecordbyPrimarykey(reportID).getTitle(), FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.PLAIN, new Color(10,10,10))))); if (request != null) { dataCell.addElement(new Phrase(new Chunk(reportName + " >> ", FontFactory .getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(255, 255, 255))))); dataCell.addElement( new Phrase(new Chunk(ReportBean.getRecordbyPrimarykey(reportID).getTitle(), FontFactory .getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(255, 255, 255))))); } dataCell.setBackgroundColor(tableHeadBackColor); dataCell.setBorderColor(tableBorderColor); frontPageTable.addCell(dataCell); dataCell = new PdfPCell(new Phrase(new Chunk("Start Date", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0))))); dataCell.setBackgroundColor(tableContentBackColor); dataCell.setBorderColor(tableBorderColor); frontPageTable.addCell(dataCell); dataCell = new PdfPCell(new Phrase(startDate)); dataCell.setBackgroundColor(tableContentBackColor); dataCell.setBorderColor(tableBorderColor); frontPageTable.addCell(dataCell); dataCell = new PdfPCell(new Phrase(new Chunk("End Date", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0))))); dataCell.setBackgroundColor(tableContentBackColor); dataCell.setBorderColor(tableBorderColor); frontPageTable.addCell(dataCell); dataCell = new PdfPCell(new Phrase(endDate)); dataCell.setBackgroundColor(tableContentBackColor); dataCell.setBorderColor(tableBorderColor); frontPageTable.addCell(dataCell); dataCell = new PdfPCell(new Phrase(new Chunk("iView Server Time", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0))))); dataCell.setBackgroundColor(tableContentBackColor); dataCell.setBorderColor(tableBorderColor); frontPageTable.addCell(dataCell); java.util.Date currentDate = new java.util.Date(); dataCell = new PdfPCell(new Phrase(currentDate.toString())); dataCell.setBackgroundColor(tableContentBackColor); dataCell.setBorderColor(tableBorderColor); frontPageTable.addCell(dataCell); dataCell = new PdfPCell(new Phrase(new Chunk("Device Names (IP Address)", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0))))); dataCell.setBackgroundColor(tableContentBackColor); dataCell.setBorderColor(tableBorderColor); frontPageTable.addCell(dataCell); DeviceBean deviceBean = null; String deviceNameWithIP = ""; if (deviceIDs != null) { for (int i = 0; i < deviceIDs.length; i++) { deviceBean = DeviceBean.getRecordbyPrimarykey(deviceIDs[i]); if (deviceBean != null) { deviceNameWithIP += " " + (i + 1) + ". " + deviceBean.getName() + " (" + deviceBean.getIp() + ")\n"; } } } dataCell = new PdfPCell(new Phrase("\n" + deviceNameWithIP + "\n")); dataCell.setBackgroundColor(tableContentBackColor); dataCell.setBorderColor(tableBorderColor); frontPageTable.addCell(dataCell); /* * Adding Table to PDF */ document.add(frontPageTable); /* * Adding Charts and Table to PDF */ document.newPage(); reportBean = ReportBean.getRecordbyPrimarykey(reportID); String query = null; if (request == null) { query = PrepareQuery.getQuery(reportBean, startDate, endDate, applianceID, null, null, "0", limit, paramMap); } else { PrepareQuery prepareQuery = new PrepareQuery(); query = prepareQuery.getQuery(reportBean, request); } String searchQuery = ""; if (request == null) { searchQuery = null; } else { searchQuery = request.getParameter("searchquery"); } if (searchQuery != null && !"".equalsIgnoreCase(searchQuery)) { query = query.replaceFirst("where", "where " + searchQuery + " and"); } CyberoamLogger.sysLog.debug("PDF:ReportID:" + reportBean.getReportId() + "Query->" + query); try { if (query.indexOf("select") == -1 && query.indexOf("SELECT") == -1) { indexManager = new IndexManager(); rsw = indexManager.getSearch(query); //rsw=indexManager.getResutSetFromArrayList(searchRecord); } else { rsw = sqlReader.getInstanceResultSetWrapper(query); } } catch (org.postgresql.util.PSQLException e) { if (query.indexOf("5min_ts_20") > -1) { query = query.substring(0, query.indexOf("5min_ts_20")) + "4hr" + query.substring(query.indexOf("5min_ts_20") + 16, query.length()); CyberoamLogger.appLog.debug("New query : " + query); rsw = sqlReader.getInstanceResultSetWrapper(query); } else { CyberoamLogger.appLog.error("Exeption in AjaxController.java " + e, e); } } catch (Exception e) { CyberoamLogger.appLog.error("Exeption in AjaxController.java " + e, e); rsw.close(); } /* * PDF Rendering work starts here */ //if(Integer.parseInt(limit)<=10 && query.indexOf("where")>-1){ if (reportBean.getReportFormatId() != 2) { chart = Chart.getChart(reportBean.getReportId(), rsw, null); PdfTemplate pdfTemplate = contentByte.createTemplate(width, height); Graphics2D graphics2D = pdfTemplate.createGraphics(width, height); Rectangle2D rectangle = new Rectangle2D.Double(100, 85, 540, rec_hieght); chart.draw(graphics2D, rectangle); graphics2D.dispose(); contentByte.addTemplate(pdfTemplate, 0, 0); for (int j = 0; j < (int) (rec_hieght / 16) + 1; j++) { document.add(new Paragraph("\n")); } } else document.add(new Paragraph("\n")); // Retrieving PdfPTable PdfPTable pdfTable = getPdfPTable(reportBean, rsw); rsw.close(); document.add(pdfTable); CyberoamLogger.appLog.info("*************Finishing PDF Work****************"); } catch (Exception e) { CyberoamLogger.sysLog.debug("Chart.writeChartToPDF.e" + e.getMessage(), e); } finally { sqlReader.close(); } document.close(); }
From source file:org.displaytag.export.PdfView.java
License:Artistic License
/** * Initialize the main info holder table. * @throws BadElementException for errors during table initialization *///from ww w. java 2s . co m protected void initTable() throws BadElementException { tablePDF = new Table(this.model.getNumberOfColumns()); // tablePDF.setDefaultVerticalAlignment(Element.ALIGN_TOP); //modify by mz tablePDF.setAlignment(Element.ALIGN_TOP); tablePDF.setCellsFitPage(true); tablePDF.setWidth(100); tablePDF.setPadding(2); tablePDF.setSpacing(0); smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL, new Color(0, 0, 0)); }
From source file:org.displaytag.render.ItextTableWriter.java
License:Artistic License
/** * Obtain the font used to render text in the table; Meant to be overriden if a different font is desired. * @return The font used to render text in the table. *//*from ww w .j a v a 2 s. co m*/ protected Font getTableFont() { return FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL, new Color(0x00, 0x00, 0x00)); }
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./*from www .j a 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 ww . ja v a 2 s. c o m*/ * @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.egov.infra.web.displaytag.export.EGovPdfView.java
License:Open Source License
/** * Initialize the main info holder table. * @throws BadElementException for errors during table initialization *//* ww w . j a v a 2 s . c om*/ protected void initTable() throws BadElementException { this.tablePDF = new Table(this.model.getNumberOfColumns()); this.tablePDF.setCellsFitPage(true); this.tablePDF.setWidth(100); this.tablePDF.setPadding(2); this.tablePDF.setSpacing(0); this.smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL, new Color(0, 0, 0)); /* * try { BaseFont btKannada = BaseFont.createFont("Tunga", "Identity-H", BaseFont.NOT_EMBEDDED); } catch (DocumentException e) { } catch (IOException e) { } */ }
From source file:org.egov.infra.web.displaytag.export.EGovPdfView.java
License:Open Source License
protected Font getCaptionFont() { return FontFactory.getFont(FontFactory.HELVETICA, 17, Font.BOLD, new Color(0x00, 0x00, 0x00)); }
From source file:org.jaffa.modules.printing.services.FormPrintEngineIText.java
License:Open Source License
/** * This will fill in the page with data, * m_currentPageData contains the details of the current page being printed * @throws FormPrintException Thrown if there is any form processing problems *//*from ww w .j a v a 2 s . com*/ protected void fillPageFields() throws FormPrintException { log.debug("fillPageFields: Page=" + getCurrentPage()); try { PdfContentByte cb = m_writer.getDirectContent(); PageDetailsExtended page = (PageDetailsExtended) getCurrentPageData(); // // Test code to throw a barcode on the page... // Barcode39 code39 = new Barcode39(); // code39.setCode("CODE39-1234567890"); // code39.setStartStopText(false); // code39.setSize(0); // Image image39 = code39.createImageWithBarcode(cb, null, null); // com.lowagie.text.pdf.PdfPTable table = new com.lowagie.text.pdf.PdfPTable(2); // table.setWidthPercentage(100); // table.getDefaultCell().setBorder(com.lowagie.text.Rectangle.NO_BORDER); // table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); // table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); // table.getDefaultCell().setFixedHeight(70); // table.addCell("CODE 39"); // table.addCell(new Phrase(new Chunk(image39, 0, 0))); // m_generatedDoc.add(table); // //-------------------------------------------------- // Loop through each field to be inserted for (Iterator i = page.fieldList.iterator(); i.hasNext();) { String fieldname = (String) i.next(); // Get the properties for displaying this field FieldProperties props = (FieldProperties) page.fieldProperties.get(fieldname); // Get the data to display FormPrintEngine.DomValue data = new FormPrintEngine.DomValue(fieldname, props.sampleData); // Caluclate Clipping Region float x1 = Math.min(props.x1, props.x2); float x2 = Math.max(props.x1, props.x2); float y1 = Math.min(props.y1, props.y2); float y2 = Math.max(props.y1, props.y2); float w = Math.abs(props.x1 - props.x2) + 1; float h = Math.abs(props.y1 - props.y2) + 1; if (log.isDebugEnabled()) log.debug("Print Field " + fieldname + "=" + data.getObject() + " @ [(" + x1 + "," + y1 + ")->(" + x2 + "," + y2 + ")]"); // Default the font if not specified String font = BaseFont.HELVETICA; if (props.fontFace != null) font = props.fontFace; // Handle Barcodes diffently withing iText, don't just use fonts if (font.startsWith("Barcode")) { String bcClassName = "com.lowagie.text.pdf." + font; Object bcode = null; String dataStr = data.getValue(); if (dataStr != null) { log.debug("Barcode Data String = " + dataStr); // Try and create the correct Barcode Object try { Class bcClass = Class.forName(bcClassName); bcode = bcClass.newInstance(); } catch (Exception e) { String err = "Can't Create Barcode Object for barcode type '" + font + "' on field " + fieldname; log.error(err, e); } // Only continue if the barcode object was created if (bcode != null) { // Generate and Print barcode, based on common interface if (bcode instanceof Barcode) { Barcode b = (Barcode) bcode; // Set some default output a barcode b.setCode(dataStr); if (props.fontSize <= 0) { // Hide text if font size is 0, and make the barcode height the size of the box b.setBarHeight(h); b.setFont(null); } else { b.setSize(props.fontSize); // size of text under barcode b.setBarHeight(h - props.fontSize - 5); // Adjust Bar Height to allow for font size } b.setN(2); // Wide Bars // Set custom parameters setBarcodeParams(fieldname, bcode, props.style); // Print out barcode Image image = ((Barcode) bcode).createImageWithBarcode(cb, null, null); printImage(image, cb, x1, y1, x2, y2, props.align, props.fitMethod, props.rotate); } else // Print PDF417 barcode, not based on common interface if (bcode instanceof BarcodePDF417) { BarcodePDF417 b = (BarcodePDF417) bcode; // Set some default output a barcode b.setText(dataStr); b.setErrorLevel(5); // Set custom parameters setBarcodeParams(fieldname, bcode, props.style); log.debug("PDF417 Settings\n" + "BitColumns=" + b.getBitColumns() + "\n" + "CodeColumns=" + b.getCodeColumns() + "\n" + "CodeRows=" + b.getCodeRows() + "\n" + "ErrorLevel=" + b.getErrorLevel() + "\n" + "YHeight=" + b.getYHeight() + "\n" + "AspectRatio=" + b.getAspectRatio() + "\n" + "Options=" + b.getOptions() + "\n" + "LenCodewords=" + b.getLenCodewords()); // Print out barcode //image = b.getImage(); printImage(b.getImage(), cb, x1, y1, x2, y2, props.align, props.fitMethod, props.rotate); } else { // Error, unknown barcode String err = "Error, No print handler for barcode object " + bcode.getClass().getName(); log.error(err); //throw new EngineProcessingException(err); } } } else log.debug("SKIPPED BARCODE : No data for " + fieldname); // Handle Images differently within iText, native support for JFreeChart } else if ("image".equalsIgnoreCase(font)) { try { java.awt.Image image = data.getDomImage(); // Add an image to the page if (image != null) { if (fieldname.startsWith("watermark")) { // Add an image-based watermark to the under content layer PdfContentByte contentUnder = m_writer.getDirectContentUnder(); if (props.opacity != 1f) { PdfGState gs = new PdfGState(); gs.setFillOpacity(props.opacity); contentUnder.setGState(gs); } printImage(image, contentUnder, x1, y1, x2, y2, props.align, props.fitMethod, props.rotate); } else { // Add an image to main page layer printImage(image, cb, x1, y1, x2, y2, props.align, props.fitMethod, props.rotate); } } } catch (IOException e) { // Add Error on page. Phrase text = new Phrase("Image Error", FontFactory .getFont(FontFactory.HELVETICA_BOLDOBLIQUE, 8f, 0, ColorHelper.getColor("red"))); ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(text, x1, y1, x2, y2, 8f, Element.ALIGN_LEFT); } } else if (fieldname.startsWith("watermark")) { // Add a text-based watermark String text = data.getValue(); PdfContentByte contentUnder = m_writer.getDirectContentUnder(); if (props.opacity != 1f) { PdfGState gs = new PdfGState(); gs.setFillOpacity(props.opacity); contentUnder.setGState(gs); } // The text aligns (left, center, right) on the pivot point. // Default to align left. float pivotX = x1; float pivotY = y1; if (Element.ALIGN_CENTER == props.align) { pivotX = (x1 / 2) + (x2 / 2); pivotY = y1; } else if (Element.ALIGN_RIGHT == props.align) { pivotX = x2; pivotY = y1; } Phrase watermark = new Phrase(text, FontFactory.getFont(props.fontFace, props.fontSize, decodeFontStyle(props.style), ColorHelper.getColor(defaultWatermarkColor))); ColumnText.showTextAligned(contentUnder, props.align, watermark, pivotX, pivotY, props.rotate); } else { // Handle printing of basic Text float lineHeight = props.fontSize; String str = data.getValue(); if (str != null) { // Add a bounded column to add text to. Phrase text = new Phrase(str, FontFactory.getFont(props.fontFace, props.fontSize, decodeFontStyle(props.style), ColorHelper.getColor(props.color))); ColumnText ct = new ColumnText(cb); if (props.fitMethod == FIT_METHOD_CLIP) // set up column with height/width restrictions ct.setSimpleColumn(text, x1, y1, x2, y2, lineHeight, props.align); else // set up column without (i.e. large) height/width restrictions ct.setSimpleColumn(text, x1, y1, 1000, 0, lineHeight, props.align); ct.go(); } } // Draw outline boxes arround fields if (isTemplateMode()) { cb.setLineWidth(0.5f); cb.setLineDash(4f, 2f); cb.setColorStroke(new Color(0xA0, 0xA0, 0xA0)); cb.moveTo(x1, y1); cb.lineTo(x1, y2); cb.lineTo(x2, y2); cb.lineTo(x2, y1); cb.lineTo(x1, y1); cb.stroke(); } } // end for-loop } catch (DocumentException e) { String err = "Error printing data - " + e.getMessage(); log.error(err, e); throw new EngineProcessingException(err); // } catch (IOException e) { // String err = "Error printing data - " + e.getMessage(); // log.error(err ,e); // throw new EngineProcessingException(err); } }
From source file:org.jivesoftware.openfire.archive.ConversationUtils.java
License:Open Source License
public ByteArrayOutputStream getConversationPDF(Conversation conversation) { Font red = FontFactory.getFont(FontFactory.HELVETICA, 12f, Font.BOLD, new Color(0xFF, 0x00, 0x00)); Font blue = FontFactory.getFont(FontFactory.HELVETICA, 12f, Font.ITALIC, new Color(0x00, 0x00, 0xFF)); Font black = FontFactory.getFont(FontFactory.HELVETICA, 12f, Font.BOLD, Color.BLACK); Map<String, Font> colorMap = new HashMap<String, Font>(); if (conversation != null) { Collection<JID> set = conversation.getParticipants(); int count = 0; for (JID jid : set) { if (conversation.getRoom() == null) { if (count == 0) { colorMap.put(jid.toString(), blue); } else { colorMap.put(jid.toString(), red); }//w w w.j a v a2 s .c o m count++; } else { colorMap.put(jid.toString(), black); } } } return buildPDFContent(conversation, colorMap); }