List of usage examples for com.lowagie.text Font Font
public Font(BaseFont bf, float size, int style, Color color)
From source file:com.stratelia.webactiv.newsEdito.control.PdfGenerator.java
License:Open Source License
/** * Method declaration/*w ww. j a va2s .c o m*/ * @param document * @param title * @param titleCount * @param publicationBm * @return * @throws NewsEditoException * @see */ public static Section addTitle(Document document, NodeDetail title, int titleCount, PublicationBm publicationBm) throws NewsEditoException { // we define some fonts Font titleFont = new Font(Font.HELVETICA, 24, Font.NORMAL, new Color(255, 255, 255)); Paragraph cTitle = new Paragraph(title.getName(), titleFont); Chapter chapter = new Chapter(cTitle, titleCount); if (title.getDescription() != null) { chapter.add(new Paragraph(title.getDescription())); } try { addPublications(chapter, title, publicationBm); document.add(chapter); } catch (Exception e) { throw new NewsEditoException("PdfGenerator.addTitle", NewsEditoException.WARNING, "NewsEdito.EX_NO_TITLE_ADDED", e); } return chapter; }
From source file:com.stratelia.webactiv.newsEdito.control.PdfGenerator.java
License:Open Source License
/** * Method declaration/* ww w. ja v a2s .c o m*/ * @param section * @param complete * @see */ public static void addPublication(Section section, CompletePublication complete) { Font publicationFont = new Font(Font.HELVETICA, 18, Font.BOLD, new Color(0, 64, 64)); try { Paragraph pub = new Paragraph(complete.getPublicationDetail().getName(), publicationFont); Section subsection = section.addSection(pub, 0); if (complete.getPublicationDetail().getDescription() != null) { subsection.add(new Paragraph(complete.getPublicationDetail().getDescription())); } if ((complete.getInfoDetail() != null) && (complete.getModelDetail() != null)) { String toParse = complete.getModelDetail().getHtmlDisplayer(); Iterator<InfoTextDetail> textIterator = complete.getInfoDetail().getInfoTextList().iterator(); Iterator<InfoImageDetail> imageIterator = complete.getInfoDetail().getInfoImageList().iterator(); int posit = toParse.indexOf("%WA"); InfoTextDetail textDetail = null; Paragraph text = null; InfoImageDetail imageDetail = null; Image img = null; while (posit != -1) { if (posit > 0) { toParse = toParse.substring(posit); } if (toParse.startsWith("%WATXTDATA%")) { if (textIterator.hasNext()) { textDetail = textIterator.next(); text = new Paragraph(textDetail.getContent()); subsection.add(text); } toParse = toParse.substring(11); } else if (toParse.startsWith("%WAIMGDATA%")) { if (imageIterator.hasNext()) { imageDetail = imageIterator.next(); String imagePath = FileRepositoryManager .getAbsolutePath(imageDetail.getPK().getComponentName()) + getImagePath() + File.separator + imageDetail.getPhysicalName(); SilverTrace.info("NewsEdito", "PDFGenerator.addPublication", "root.MSG_PARAM_VALUE", "imagePath = " + imagePath); img = Image.getInstance(imagePath); subsection.add(img); } toParse = toParse.substring(11); } // et on recommence posit = toParse.indexOf("%WA"); } } } catch (Exception e) { SilverTrace.warn("NewsEdito", "PdfGenerator.addPublication", "NewsEdito.EX_NO_PUBLI_ADDED"); } }
From source file:com.stratelia.webactiv.newsEdito.control.PdfGenerator.java
License:Open Source License
/** * Method declaration/* w ww . j a v a2 s .c om*/ * @param document * @param archiveDetail * @param publicationBm * @param langue * @see */ public static void addEditorial(Document document, NodeDetail archiveDetail, PublicationBm publicationBm, String langue) throws NewsEditoException { SilverTrace.info("NewsEdito", "PdfGenerator.addEditorial", "NewsEdito.MSG_ENTRY_METHOD"); try { ResourceLocator message = new ResourceLocator( "com.stratelia.webactiv.newsEdito.multilang.newsEditoBundle", langue); Collection<PublicationDetail> pubList = publicationBm.getDetailsByFatherPK(archiveDetail.getNodePK()); Iterator<PublicationDetail> i = pubList.iterator(); if (i.hasNext()) { try { Font publicationFont = new Font(Font.HELVETICA, 18, Font.BOLD, new Color(0, 64, 64)); Font titleFont = new Font(Font.HELVETICA, 24, Font.NORMAL, new Color(255, 255, 255)); Paragraph cTitle = new Paragraph(message.getString("editorial"), titleFont); Chapter chapter = new Chapter(cTitle, 0); chapter.setNumberDepth(0); PublicationDetail detail = null; Paragraph name = null; Section subsection = null; Image img = null; while (i.hasNext()) { detail = i.next(); name = new Paragraph(detail.getName(), publicationFont); subsection = chapter.addSection(name, 0); subsection.setNumberDepth(0); if (detail.getDescription() != null) { subsection.add(new Paragraph(detail.getDescription())); } if (detail.getImage() != null) { String imagePath = FileRepositoryManager .getAbsolutePath(detail.getPK().getComponentName()) + getImagePath() + File.separator + detail.getImage(); try { SilverTrace.info("NewsEdito", "PDFGenerator.addEditorial", "root.MSG_PARAM_VALUE", "imagePath = " + imagePath); img = Image.getInstance(imagePath); } catch (Exception e) { SilverTrace.info("NewsEdito", "PDFGenerator.addEditorial", "NewsEdito.MSG_CANNOT_RETRIEVE_IMAGE", "imagePath = " + imagePath); } if (img == null) { SilverTrace.info("NewsEdito", "PdfGenerator.addEditorial", "NewsEdito.MSG_CANNOT_RETRIEVE_IMAGE"); } else { subsection.add(img); } } } document.add(chapter); } catch (DocumentException de) { SilverTrace.warn("NewsEdito", "PdfGenerator.addEditorial", "NewsEdito.EX_NO_EDITO_ADDED"); } } } catch (Exception e) { throw new NewsEditoException("PdfGenerator.addEditorial", NewsEditoException.WARNING, "NewsEdito.EX_PROBLEM_TO_ADD_EDITO", e); } }
From source file:com.sumeet.kraiglist.pdfview.PdfReportView.java
@Override protected void buildPdfDocument(Map<String, Object> model, Document pdfdoc, PdfWriter pdfwriter, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession session = request.getSession(); String name = (String) session.getAttribute("firstname"); if (name == null) { name = ""; }/*from w ww . j a v a 2 s . c o m*/ Font font_helvetica_12_normal_black = new Font(Font.HELVETICA, 12, Font.NORMAL, Color.BLACK); Font font_courier_16_italic_blue = new Font(Font.COURIER, 10, Font.ITALIC, Color.BLUE); Font font_courier_16_italic_red = new Font(Font.COURIER, 16, Font.ITALIC, Color.BLUE); Font font_times_16_bold_green = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL, Color.BLACK); Paragraph prg0 = new Paragraph( " Terms of Use of MyNEU KRAIGLIST", font_helvetica_12_normal_black); Paragraph prg1 = new Paragraph( "____________________________________________________________________________________________________________", font_courier_16_italic_red); Paragraph prg2 = new Paragraph(""); Chunk c1 = new Chunk("Hello " + name + ",", font_courier_16_italic_blue); Paragraph prg3 = new Paragraph("PRODUCT SALES : " + "The GSI Products listed on this Site are offered for sale solely pursuant to GSIs standard terms and conditions of sale applicable" + "to such products. The terms and conditions are accessible for viewing by clicking on the link on each product line home page." + "GSI objects to and rejects any other terms that may be proposed by any customer or potential customer. No offers to sell or purchase" + "GSI products are valid and binding on GSI unless and until specifically accepted, in writing, by GSI.", font_times_16_bold_green); //Phrase phr2 = new Phrase("Phrase 2", font_helvetica_16_normal_blue); Paragraph prg4 = new Paragraph(""); Paragraph prg5 = new Paragraph("LICENSE TO USE THIS SITE : " + "We at the GSI Group Inc. and its subsidiaries (GSI) are happy to have you as a visitor. We have established the following" + "terms and conditions, including our Privacy Statement, as a requirement for visitors using our site. In order to use our site, you" + "must agree to these terms and conditions (Terms). BY CHOOSING TO ACCESS AND USE THIS SITE, YOU ARE EXPRESSLY" + "AGREEING TO BE LEGALLY BOUND BY THESE TERMS. IF YOU DO NOT AGREE, DO NOT USE OR VIEW THE SITE." + "These Terms apply only to the use of this Site and do not supercede any other contractual agreement between you and GSI." + "Use of Materials: Upon your agreement to the Terms, GSI grants you the right to view the site and to download materials from" + "this site for your personal, non-commercial use. You are not authorized to use the materials for any other purpose. If you do" + "download or otherwise reproduce the materials from this Site, you must reproduce all of GSIs proprietary markings, such as" + "copyright and trademark notices, in the same form and manner as the original." + "Private Pages: Some parts of this Site are not available to the general public, but only to certain business associates of GSI." + "These sections may only be accessed by authorized entities and are controlled by password-protected access. If you are not" + "authorized to use these sections, then you agree that you will not attempt to gain access. If you are authorized, then by accessing" + "those areas, you expressly agree to the supplemental terms that are posted as part of the access process." + "No Harmful Use: In exchange for our permission to use this Site, you agree that you will not do anything to harm the functioning" + "or content of the Site. You will not attempt to upload, insert or change any information or image to or on this Site, except for providing" + "information where prompted by the Site. You agree that you will not take any action that imposes an unreasonably or disproportionately" + "large load on the Site or interferes with its functioning. You also agree that you will not use any false identity" + "when interacting with the Site, or do anything that is fraudulent, obscene, libelous or legally prohibited." + "You may not use any deep-link, page-scrape, robot, spider or any other automatic device, program, algorithm or methodology" + "or any similar or equivalent manual process to access, acquire, copy or monitor any portion of the Site or any of its content," + "or in any way reproduce or circumvent the navigational structure or presentation of the Site." + "INDEMNITY: YOU AGREE THAT YOU WILL DEFEND, INDEMNIFY AND HOLD HARMLESS GSI, ITS CUSTOMERS, SUPPLIERS" + "AND JOINT VENTURE PARTNERS AND THEIR RESPECTIVE EMPLOYEES, OFFICERS, DIRECTORS, CONTRACTORS," + "VENDORS, ASSIGNEES AND AGENTS FOR AND AGAINST ANY COSTS, CLAIMS, DAMAGES, LOSSES, OR" + "OTHER LIABILITIES ARISING FROM YOUR USE OF THE SITE IN BREACH OF THESE TERMS OR IN VIOLATION OF THE" + "LAW. IF GSI TAKES ANY LEGAL ACTION AGAINST YOU AS A RESULT OF YOUR VIOLATION OF THESE TERMS, YOU" + "AGREE THAT YOU WILL BE RESPONSIBLE FOR AND WILL PAY ALL OF GSIS LEGAL FEES IN CONNECTION WITH" + "SUCH ACTION. ", font_times_16_bold_green); pdfdoc.add(c1); pdfdoc.add(prg0); pdfdoc.add(prg1); pdfdoc.add(prg2); pdfdoc.add(prg3); pdfdoc.add(prg4); pdfdoc.add(prg5); }
From source file:corner.orm.tapestry.jasper.exporter.CornerPdfExporter.java
License:Apache License
/** * ?,,.// w w w .j a v a 2 s .c o m * @see net.sf.jasperreports.engine.export.JRPdfExporter#getFont(java.util.Map) */ protected Font getFont(Map attributes) { JRFont jrFont = new JRBaseFont(attributes); Exception initialException = null; Color forecolor = (Color) attributes.get(TextAttribute.FOREGROUND); /* if (forecolor == null) { forecolor = Color.black; } */ Font font = null; PdfFont pdfFont = null; FontKey key = new FontKey(jrFont.getFontName(), jrFont.isBold(), jrFont.isItalic()); if (fontMap != null && fontMap.containsKey(key)) { pdfFont = (PdfFont) fontMap.get(key); } else { pdfFont = new PdfFont(jrFont.getPdfFontName(), jrFont.getPdfEncoding(), jrFont.isPdfEmbedded(), jrFont.isBold(), jrFont.isItalic()); } try { font = FontFactory.getFont(pdfFont.getPdfFontName(), pdfFont.getPdfEncoding(), pdfFont.isPdfEmbedded(), jrFont.getFontSize(), (pdfFont.isPdfSimulatedBold() ? Font.BOLD : 0) | (pdfFont.isPdfSimulatedItalic() ? Font.ITALIC : 0) | (jrFont.isUnderline() ? Font.UNDERLINE : 0) | (jrFont.isStrikeThrough() ? Font.STRIKETHRU : 0), forecolor); // check if FontFactory didn't find the font if (font.getBaseFont() == null && font.family() == Font.UNDEFINED) { font = null; } } catch (Exception e) { initialException = e; } if (font == null) { byte[] bytes = null; try { bytes = JRLoader.loadBytesFromLocation(pdfFont.getPdfFontName(), classLoader, urlHandlerFactory); } catch (JRException e) { throw new JRRuntimeException("Could not load the following font : " + "\npdfFontName : " + pdfFont.getPdfFontName() + "\npdfEncoding : " + pdfFont.getPdfEncoding() + "\nisPdfEmbedded : " + pdfFont.isPdfEmbedded(), initialException); } BaseFont baseFont = null; try { baseFont = BaseFont.createFont(pdfFont.getPdfFontName(), pdfFont.getPdfEncoding(), pdfFont.isPdfEmbedded(), true, bytes, null); } catch (DocumentException e) { throw new JRRuntimeException(e); } catch (IOException e) { throw new JRRuntimeException(e); } font = new Font(baseFont, jrFont.getFontSize(), ((pdfFont.isPdfSimulatedBold()) ? Font.BOLD : 0) | ((pdfFont.isPdfSimulatedItalic()) ? Font.ITALIC : 0) | (jrFont.isUnderline() ? Font.UNDERLINE : 0) | (jrFont.isStrikeThrough() ? Font.STRIKETHRU : 0), forecolor); } return font; }
From source file:datasoul.servicelist.ServiceListExporterDocument.java
License:Open Source License
private void addSongChords(String[] text) throws DocumentException { Font chordfont = new Font(Font.COURIER, 12, Font.BOLD, Color.BLUE.darker()); Font lyricfont = new Font(Font.COURIER, 12, Font.NORMAL); Paragraph p;/* w w w .jav a 2 s. c o m*/ for (String line : text) { Matcher matcher = Song.CHORDS_REGEX_PATTERN.matcher(line); if (matcher.find()) { if (line.startsWith("=")) { line = line.replaceFirst("=", " "); } p = new Paragraph(line, chordfont); } else { p = new Paragraph(line, lyricfont); } document.add(p); } }
From source file:fr.opensagres.xdocreport.itext.extension.font.AbstractFontRegistry.java
License:Open Source License
public Font getFont(String familyName, String encoding, float size, int style, Color color) { initFontRegistryIfNeeded();/* ww w . j av a 2s.c o m*/ if (familyName != null) { familyName = resolveFamilyName(familyName, style); } try { return FontFactory.getFont(familyName, encoding, size, style, color); } catch (ExceptionConverter e) { // TODO manage options of font not found + add some logs return new Font(Font.UNDEFINED, size, style, color); } }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDFBottom(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde, int padding, int colspan) { PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, Color.WHITE))); celda.setHorizontalAlignment(alineacion); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.WHITE); celda.setColspan(colspan);//from www. java 2 s . c o m celda.setBorder(borde); celda.setPadding(padding); return celda; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDFCarnetOpciones(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde, int padding, int colspan, Color color) { PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, Color.WHITE))); celda.setHorizontalAlignment(alineacion); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.black); celda.setBackgroundColor(color);/* w w w.j av a2 s . c o m*/ celda.setColspan(colspan); celda.setBorderWidth(borde); celda.setPadding(0); celda.setPaddingBottom(padding); return celda; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDFCarnet(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde, int padding, int colspan) { PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, Color.WHITE))); celda.setHorizontalAlignment(alineacion); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.WHITE); celda.setColspan(colspan);//from w w w. j a v a2 s. co m celda.setBorderWidth(0); celda.setBorderWidthBottom(borde); celda.setPadding(0); celda.setPaddingBottom(padding); return celda; }