List of usage examples for com.lowagie.text FontFactory HELVETICA
String HELVETICA
To view the source code for com.lowagie.text FontFactory HELVETICA.
Click Source Link
From source file:io.vertigo.dynamo.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
/** * Effectue le rendu des headers.//from w ww .j ava2s .c om * * @param parameters Paramtres * @param datatable Table */ private static void renderHeaders(final ExportSheet parameters, final Table datatable) throws BadElementException { // size of columns // datatable.setWidths(headerwidths); // datatable.setWidth(100f); // table header final Font font = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD); datatable.getDefaultCell().setBorderWidth(2); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); // datatable.getDefaultCell().setGrayFill(0.75f); for (final ExportField exportColumn : parameters.getExportFields()) { datatable.addCell(new Phrase(exportColumn.getLabel().getDisplay(), font)); } // end of the table header datatable.endHeaders(); }
From source file:io.vertigo.dynamo.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
/** * Effectue le rendu de la liste./* w w w . ja v a2 s . c o m*/ * * @param parameters Paramtres * @param datatable Table */ private void renderList(final ExportSheet parameters, final Table datatable) throws BadElementException { // data rows final Font font = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); final Font whiteFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); whiteFont.setColor(Color.WHITE); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); // datatable.getDefaultCell().setGrayFill(0); // Parcours des DTO de la DTC for (final DtObject dto : parameters.getDtList()) { for (final ExportField exportColumn : parameters.getExportFields()) { final DtField dtField = exportColumn.getDtField(); final Object value = dtField.getDataAccessor().getValue(dto); final int horizontalAlignement; if (value instanceof Number || value instanceof Date) { horizontalAlignement = Element.ALIGN_RIGHT; } else if (value instanceof Boolean) { horizontalAlignement = Element.ALIGN_CENTER; } else { horizontalAlignement = Element.ALIGN_LEFT; } datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement); String text = ExportUtil.getText(persistenceManager, referenceCache, denormCache, dto, exportColumn); if (text == null) { text = ""; } datatable.addCell(new Phrase(8, text, font)); } } }
From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
private void renderObject(final ExportSheet exportSheet, final Table datatable) throws BadElementException { final Font labelFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD); final Font valueFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); for (final ExportField exportColumn : exportSheet.getExportFields()) { datatable.getDefaultCell().setBorderWidth(2); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(new Phrase(exportColumn.getLabel().getDisplay(), labelFont)); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); final DtField dtField = exportColumn.getDtField(); final Object value = dtField.getDataAccessor().getValue(exportSheet.getDtObject()); final int horizontalAlignement; if (value instanceof Number || value instanceof LocalDate || value instanceof Instant) { horizontalAlignement = Element.ALIGN_RIGHT; } else if (value instanceof Boolean) { horizontalAlignement = Element.ALIGN_CENTER; } else {/*from w w w.ja va 2 s. c o m*/ horizontalAlignement = Element.ALIGN_LEFT; } datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement); String text = ExportUtil.getText(storeManager, referenceCache, denormCache, exportSheet.getDtObject(), exportColumn); if (text == null) { text = ""; } datatable.addCell(new Phrase(8, text, valueFont)); } }
From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
/** * Effectue le rendu des headers./*from www.j a v a 2 s. c om*/ * * @param parameters Paramtres * @param datatable Table */ private static void renderHeaders(final ExportSheet parameters, final Table datatable) throws BadElementException { // table header final Font font = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD); datatable.getDefaultCell().setBorderWidth(2); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); for (final ExportField exportColumn : parameters.getExportFields()) { datatable.addCell(new Phrase(exportColumn.getLabel().getDisplay(), font)); } // end of the table header datatable.endHeaders(); }
From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
/** * Effectue le rendu de la liste./*from w w w . j a v a 2s.co m*/ * * @param parameters Paramtres * @param datatable Table */ private void renderList(final ExportSheet parameters, final Table datatable) throws BadElementException { // data rows final Font font = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); final Font whiteFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); whiteFont.setColor(Color.WHITE); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); // Parcours des DTO de la DTC for (final DtObject dto : parameters.getDtList()) { for (final ExportField exportColumn : parameters.getExportFields()) { final DtField dtField = exportColumn.getDtField(); final Object value = dtField.getDataAccessor().getValue(dto); final int horizontalAlignement; if (value instanceof Number || value instanceof LocalDate || value instanceof Instant) { horizontalAlignement = Element.ALIGN_RIGHT; } else if (value instanceof Boolean) { horizontalAlignement = Element.ALIGN_CENTER; } else { horizontalAlignement = Element.ALIGN_LEFT; } datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement); String text = ExportUtil.getText(storeManager, referenceCache, denormCache, dto, exportColumn); if (text == null) { text = ""; } datatable.addCell(new Phrase(8, text, font)); } } }
From source file:mitm.common.pdf.MessagePDFBuilder.java
License:Open Source License
private FontSelector createBodyFontSelector() { return createFontSelector(FontFactory.HELVETICA, bodyFontSize, Font.NORMAL, Color.BLACK); }
From source file:mitm.common.pdf.MessagePDFBuilder.java
License:Open Source License
private FontSelector createHeaderFontSelector() { return createFontSelector(FontFactory.HELVETICA, headerFontSize, Font.BOLD, Color.BLACK); }
From source file:mx.randalf.digital.ocr.hocrtopdf.HocrToPdf.java
License:Open Source License
public void hocrToPdf(File fImg, File fHtml, File fPdf) throws IOException, DocumentException, Exception { URL inputHOCRFile = null;/*from w w w.j a v a 2 s . c om*/ FileOutputStream outputPDFStream = null; // The resolution of a PDF file (using iText) is 72pt per inch float pointsPerInch = 72.0f; Source source = null; StartTag pageTag = null; Pattern imagePattern = null; Matcher imageMatcher = null; // Load the image Image pageImage = null; float dotsPerPointX; float dotsPerPointY; float pageImagePixelHeight; Document pdfDocument = null; PdfWriter pdfWriter = null; Font defaultFont = null; PdfContentByte cb = null; Pattern bboxPattern = null; Pattern bboxCoordinatePattern = null; StartTag ocrLineTag = null; try { try { inputHOCRFile = new URL("file://" + fHtml.getAbsolutePath()); } catch (MalformedURLException e) { throw e; } try { outputPDFStream = new FileOutputStream(fPdf); } catch (FileNotFoundException e) { throw e; } // Using the jericho library to parse the HTML file source = new Source(inputHOCRFile); // Find the tag of class ocr_page in order to load the scanned image pageTag = source.findNextStartTag(0, "class", "ocr_page", false); imagePattern = Pattern.compile("image\\s+([^;]+)"); imageMatcher = imagePattern.matcher(pageTag.getElement().getAttributeValue("title")); if (!imageMatcher.find()) { throw new Exception("Could not find a tag of class \"ocr_page\", aborting."); } try { pageImage = Image.getInstance(new URL("file://" + fImg.getAbsolutePath())); } catch (MalformedURLException e) { throw e; } dotsPerPointX = pageImage.getDpiX() / pointsPerInch; dotsPerPointY = pageImage.getDpiY() / pointsPerInch; pageImagePixelHeight = pageImage.getHeight(); pdfDocument = new Document( new Rectangle(pageImage.getWidth() / dotsPerPointX, pageImage.getHeight() / dotsPerPointY)); pdfWriter = PdfWriter.getInstance(pdfDocument, outputPDFStream); pdfDocument.open(); // first define a standard font for our text defaultFont = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD, CMYKColor.BLACK); // Put the text behind the picture (reverse for debugging) cb = pdfWriter.getDirectContentUnder(); //PdfContentByte cb = pdfWriter.getDirectContent(); pageImage.scaleToFit(pageImage.getWidth() / dotsPerPointX, pageImage.getHeight() / dotsPerPointY); pageImage.setAbsolutePosition(0, 0); // Put the image in front of the text (reverse for debugging) pdfWriter.getDirectContent().addImage(pageImage); //pdfWriter.getDirectContentUnder().addImage(pageImage); // In order to place text behind the recognised text snippets we are interested in the bbox property bboxPattern = Pattern.compile("bbox(\\s+\\d+){4}"); // This pattern separates the coordinates of the bbox property bboxCoordinatePattern = Pattern.compile("(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)"); // Only tags of the ocr_line class are interesting ocrLineTag = source.findNextStartTag(0, "class", "ocr_line", false); while (ocrLineTag != null) { au.id.jericho.lib.html.Element lineElement = ocrLineTag.getElement(); Matcher bboxMatcher = bboxPattern.matcher(lineElement.getAttributeValue("title")); if (bboxMatcher.find()) { // We found a tag of the ocr_line class containing a bbox property Matcher bboxCoordinateMatcher = bboxCoordinatePattern.matcher(bboxMatcher.group()); bboxCoordinateMatcher.find(); int[] coordinates = { Integer.parseInt((bboxCoordinateMatcher.group(1))), Integer.parseInt((bboxCoordinateMatcher.group(2))), Integer.parseInt((bboxCoordinateMatcher.group(3))), Integer.parseInt((bboxCoordinateMatcher.group(4))) }; String line = lineElement.getContent().extractText(); // float bboxWidthPt = (coordinates[2] - coordinates[0]) / dotsPerPointX; float bboxHeightPt = (coordinates[3] - coordinates[1]) / dotsPerPointY; // Put the text into the PDF cb.beginText(); // Comment the next line to debug the PDF output (visible Text) cb.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_INVISIBLE); // TODO: Scale the text width to fit the OCR bbox cb.setFontAndSize(defaultFont.getBaseFont(), Math.round(bboxHeightPt)); cb.moveText((float) (coordinates[0] / dotsPerPointX), (float) ((pageImagePixelHeight - coordinates[3]) / dotsPerPointY)); cb.showText(line); cb.endText(); } ocrLineTag = source.findNextStartTag(ocrLineTag.getEnd(), "class", "ocr_line", false); } } catch (NumberFormatException e) { throw e; } catch (MalformedURLException e) { throw e; } catch (FileNotFoundException e) { throw e; } catch (BadElementException e) { throw e; } catch (IOException e) { throw e; } catch (DocumentException e) { throw e; } catch (Exception e) { throw e; } finally { if (pdfDocument != null) { pdfDocument.close(); } if (outputPDFStream != null) { outputPDFStream.close(); } } }
From source file:net.bull.javamelody.internal.web.pdf.PdfCoreReport.java
License:Apache License
private void writeGraphs(Collection<JRobin> jrobins, Map<String, byte[]> mySmallGraphs) throws IOException, DocumentException { if (collector.isStopped()) { // pas de graphs, ils seraient en erreur sans timer // mais un message d'avertissement la place final String message = getString("collect_server_misusage"); final Paragraph jrobinParagraph = new Paragraph(message, PdfFonts.BOLD.getFont()); jrobinParagraph.setAlignment(Element.ALIGN_CENTER); addToDocument(jrobinParagraph);/* w w w. j a va 2 s .c o m*/ return; } if (collector.isStorageUsedByMultipleInstances()) { final String message = getString("storage_used_by_multiple_instances") + "\n\n"; final Paragraph jrobinParagraph = new Paragraph(message, PdfFonts.BOLD.getFont()); jrobinParagraph.setAlignment(Element.ALIGN_CENTER); addToDocument(jrobinParagraph); } final Paragraph jrobinParagraph = new Paragraph("", FontFactory.getFont(FontFactory.HELVETICA, 9f, Font.NORMAL)); jrobinParagraph.setAlignment(Element.ALIGN_CENTER); jrobinParagraph.add(new Phrase("\n\n\n\n")); final Collection<byte[]> graphs; if (mySmallGraphs != null) { // si les graphiques ont t prinitialiss (en Swing) alors on les utilise graphs = mySmallGraphs.values(); } else { if (jrobins.isEmpty()) { return; } graphs = new ArrayList<byte[]>(jrobins.size()); for (final JRobin jrobin : jrobins) { graphs.add(jrobin.graph(range, SMALL_GRAPH_WIDTH, SMALL_GRAPH_HEIGHT)); } } int i = 0; for (final byte[] graph : graphs) { if (i % 3 == 0 && i != 0) { // un retour aprs httpSessions et avant activeThreads pour l'alignement jrobinParagraph.add(new Phrase("\n\n\n\n\n")); } final Image image = Image.getInstance(graph); image.scalePercent(50); jrobinParagraph.add(new Phrase(new Chunk(image, 0, 0))); jrobinParagraph.add(new Phrase(" ")); i++; } jrobinParagraph.add(new Phrase("\n")); addToDocument(jrobinParagraph); }
From source file:net.bull.javamelody.internal.web.pdf.PdfFonts.java
License:Apache License
private static Font getFont(float size, int style) { return FontFactory.getFont(FontFactory.HELVETICA, size, style); }