List of usage examples for com.lowagie.text Font HELVETICA
int HELVETICA
To view the source code for com.lowagie.text Font HELVETICA.
Click Source Link
From source file:org.silverpeas.components.almanach.control.AlmanachPdfGenerator.java
License:Open Source License
private static void generateAlmanach(Chapter chapter, AlmanachSessionController almanach, List<DisplayableEventOccurrence> occurrences, String mode) { boolean monthScope = AlmanachPdfGenerator.PDF_MONTH_EVENTSONLY.equals(mode) || AlmanachPdfGenerator.PDF_MONTH_ALLDAYS.equals(mode); boolean yearScope = AlmanachPdfGenerator.PDF_YEAR_EVENTSONLY.equals(mode); int currentDay = -1; Calendar calendar = Calendar.getInstance(); calendar.setTime(almanach.getCurrentDay()); calendar.set(Calendar.DAY_OF_MONTH, 1); int currentMonth = calendar.get(Calendar.MONTH); int currentYear = calendar.get(Calendar.YEAR); if (yearScope) { // start from begin of current year calendar.set(Calendar.MONTH, 0); }//from w w w. j a va 2 s . c om // for each day of the current month while ((monthScope && currentMonth == calendar.get(Calendar.MONTH)) || (yearScope && currentYear == calendar.get(Calendar.YEAR))) { Section section = null; if (AlmanachPdfGenerator.PDF_MONTH_ALLDAYS.equals(mode)) { section = chapter.addSection(generateParagraph(calendar, almanach), 0); } Font titleTextFont = new Font(Font.BOLD, 12, Font.SYMBOL, new Color(0, 0, 0)); // get the events of the current day for (DisplayableEventOccurrence occurrence : occurrences) { EventDetail event = occurrence.getEventDetail(); String theDay = DateUtil.date2SQLDate(calendar.getTime()); String startDay = DateUtil.date2SQLDate(occurrence.getStartDate().asDate()); String startHour = event.getStartHour(); String endHour = event.getEndHour(); if (startDay.compareTo(theDay) > 0) { continue; } String endDay = startDay; if (event.getEndDate() != null) { endDay = DateUtil.date2SQLDate(occurrence.getEndDate().asDate()); } if (endDay.compareTo(theDay) < 0) { continue; } if (calendar.get(Calendar.DAY_OF_MONTH) != currentDay) { if (AlmanachPdfGenerator.PDF_MONTH_EVENTSONLY.equals(mode) || AlmanachPdfGenerator.PDF_YEAR_EVENTSONLY.equals(mode)) { section = chapter.addSection(generateParagraph(calendar, almanach), 0); } currentDay = calendar.get(Calendar.DAY_OF_MONTH); } Font textFont; if (event.getPriority() == 0) { textFont = new Font(Font.HELVETICA, 10, Font.NORMAL, new Color(0, 0, 0)); } else { textFont = new Font(Font.HELVETICA, 10, Font.BOLD, new Color(0, 0, 0)); } String eventTitle = event.getTitle(); if (startDay.compareTo(theDay) == 0 && startHour != null && startHour.length() != 0) { eventTitle += " (" + startHour; if (endDay.compareTo(theDay) == 0 && endHour != null && endHour.length() != 0) { eventTitle += "-" + endHour; } eventTitle += ")"; } section.add(new Paragraph(eventTitle, titleTextFont)); if (StringUtil.isDefined(event.getPlace())) { section.add(new Paragraph(event.getPlace(), titleTextFont)); } if (StringUtil.isDefined(event.getDescription(almanach.getLanguage()))) { section.add(new Paragraph(event.getDescription(almanach.getLanguage()), textFont)); } section.add(new Paragraph("\n")); } // end for calendar.add(Calendar.DAY_OF_MONTH, 1); } }
From source file:org.silverpeas.components.kmelia.workflowextensions.SendInKmelia.java
License:Open Source License
private void generatePDFStepHeader(HistoryStep step, com.lowagie.text.Document document) { try {/*from w ww .ja va2 s . c o m*/ String activity = ""; if (step.getResolvedState() != null) { State resolvedState = step.getProcessInstance().getProcessModel().getState(step.getResolvedState()); activity = resolvedState.getLabel(getRole(), getLanguage()); } String sAction; try { if ("#question#".equals(step.getAction())) { sAction = getString("processManager.question"); } else if ("#response#".equals(step.getAction())) { sAction = getString("processManager.response"); } else if ("#reAssign#".equals(step.getAction())) { sAction = getString("processManager.reAffectation"); } else { Action action = step.getProcessInstance().getProcessModel().getAction(step.getAction()); sAction = action.getLabel(getRole(), getLanguage()); } } catch (WorkflowException we) { sAction = "##"; } String actor = step.getUser().getFullName(); String date = DateUtil.getOutputDateAndHour(step.getActionDate(), getLanguage()); String header = ""; if (StringUtil.isDefined(activity)) { header += activity + " - "; } header += sAction + " (" + actor + " - " + date + ")"; Font fontHeader = new Font(Font.HELVETICA, 12, Font.NORMAL); PdfPCell pCell = new PdfPCell(new Phrase(header, fontHeader)); pCell.setFixedHeight(28); pCell.setBackgroundColor(new Color(239, 239, 239)); pCell.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPTable pTable = new PdfPTable(1); pTable.setWidthPercentage(100); pTable.addCell(pCell); document.add(pTable); } catch (Exception e) { SilverLogger.getLogger(this).error(e.getMessage(), e); } }
From source file:org.silverpeas.components.kmelia.workflowextensions.SendInKmelia.java
License:Open Source License
private void generatePDFStepContent(HistoryStep step, com.lowagie.text.Document document) { try {/* w w w . j av a 2 s . c o m*/ Form form; if ("#question#".equals(step.getAction()) || "#response#".equals(step.getAction())) { // TODO form = null; } else { form = getProcessInstance().getProcessModel().getPresentationForm(step.getAction(), getRole(), getLanguage()); } XmlForm xmlForm = (XmlForm) form; if (xmlForm != null && step.getActionRecord() != null) { DataRecord data = step.getActionRecord(); // Force simpletext displayers because itext cannot display HTML Form fields (select, // radio...) float[] colsWidth = { 25, 75 }; PdfPTable tableContent = new PdfPTable(colsWidth); tableContent.setWidthPercentage(100); String fieldValue = ""; Font fontLabel = new Font(Font.HELVETICA, 10, Font.BOLD); Font fontValue = new Font(Font.HELVETICA, 10, Font.NORMAL); List<FieldTemplate> fieldTemplates = xmlForm.getFieldTemplates(); for (FieldTemplate fieldTemplate1 : fieldTemplates) { try { GenericFieldTemplate fieldTemplate = (GenericFieldTemplate) fieldTemplate1; String fieldLabel = fieldTemplate.getLabel("fr"); Field field = data.getField(fieldTemplate.getFieldName()); String componentId = step.getProcessInstance().getProcessModel().getModelId(); // wysiwyg field if ("wysiwyg".equals(fieldTemplate.getDisplayerName())) { String file = WysiwygFCKFieldDisplayer.getFile(componentId, getProcessInstance().getInstanceId(), fieldTemplate.getFieldName(), getLanguage()); // Extract the text content of the html code Source source = new Source(new FileInputStream(file)); fieldValue = source.getTextExtractor().toString(); } // Field file type else if (FileField.TYPE.equals(fieldTemplate.getDisplayerName()) && StringUtil.isDefined(field.getValue())) { SimpleDocument doc = AttachmentServiceProvider.getAttachmentService() .searchDocumentById(new SimpleDocumentPK(field.getValue(), componentId), null); if (doc != null) { fieldValue = doc.getFilename(); } } // Field date type else if ("date".equals(fieldTemplate.getTypeName())) { fieldValue = DateUtil.getOutputDate(field.getValue(), "fr"); } // Others fields type else { fieldTemplate.setDisplayerName("simpletext"); fieldValue = field.getValue(getLanguage()); } PdfPCell cell = new PdfPCell(new Phrase(fieldLabel, fontLabel)); cell.setBorderWidth(0); cell.setPaddingBottom(5); tableContent.addCell(cell); cell = new PdfPCell(new Phrase(fieldValue, fontValue)); cell.setBorderWidth(0); cell.setPaddingBottom(5); tableContent.addCell(cell); } catch (Exception e) { SilverLogger.getLogger(this).error(e.getMessage(), e); } } document.add(tableContent); } } catch (Exception e) { SilverLogger.getLogger(this).error(e.getMessage(), e); } }
From source file:org.sonar.report.pdf.Toc.java
License:Open Source License
@Override public void onChapter(PdfWriter writer, Document document, float position, Paragraph title) { // toc.add(new Paragraph(title.getContent() + " page " + document.getPageNumber())); content.getDefaultCell().setBorderColorBottom(Color.LIGHT_GRAY); content.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); content.getDefaultCell().setUseBorderPadding(true); content.addCell(new Phrase(title.getContent(), new Font(Font.HELVETICA, 11))); content.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); content.addCell(new Phrase("Page " + document.getPageNumber(), new Font(Font.HELVETICA, 11))); content.getDefaultCell().setBorderColorBottom(Color.WHITE); content.getDefaultCell().setUseBorderPadding(false); }
From source file:org.sonar.report.pdf.Toc.java
License:Open Source License
@Override public void onSection(PdfWriter writer, Document document, float position, int depth, Paragraph title) { content.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); switch (depth) { case 2:/*from ww w . j a v a2 s. com*/ content.getDefaultCell().setIndent(10); content.addCell(new Phrase(title.getContent(), new Font(Font.HELVETICA, 10))); content.getDefaultCell().setIndent(0); content.addCell(""); break; default: content.getDefaultCell().setIndent(20); content.addCell(new Phrase(title.getContent(), new Font(Font.HELVETICA, 9))); content.getDefaultCell().setIndent(0); content.addCell(""); } }
From source file:org.sonarqube.report.extendedpdf.ExtendedToc.java
License:Open Source License
@Override public void onChapter(PdfWriter writer, Document document, float position, Paragraph title) { content.getDefaultCell().setBorderColorBottom(Color.LIGHT_GRAY); content.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); content.getDefaultCell().setUseBorderPadding(true); content.addCell(new Phrase(title.getContent(), new Font(Font.HELVETICA, 11))); content.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); content.addCell(new Phrase("Page " + document.getPageNumber(), new Font(Font.HELVETICA, 11))); content.getDefaultCell().setBorderColorBottom(Color.WHITE); content.getDefaultCell().setUseBorderPadding(false); }
From source file:questions.objects.DifferentLeadings.java
public static void main(String[] args) { Document document = new Document(PageSize.A7); try {//from www . j a v a 2s .co m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); document.open(); Chunk space = new Chunk(' '); String text = "Quick brown fox jumps over the lazy dog."; Phrase phrase1 = new Phrase(text, new Font(Font.HELVETICA, 12)); Phrase phrase2 = new Phrase(new Chunk(text, new Font(Font.TIMES_ROMAN, 24))); Phrase phrase3 = new Phrase(text, new Font(Font.COURIER, 8)); Phrase phrase4 = new Phrase(text, new Font(Font.HELVETICA, 4)); Paragraph paragraph = new Paragraph(); paragraph.add(phrase1); paragraph.add(space); paragraph.add(phrase2); paragraph.add(space); paragraph.add(phrase3); paragraph.add(space); paragraph.add(phrase4); paragraph.setMultipliedLeading(1.5f); paragraph.setAlignment(Element.ALIGN_JUSTIFIED); ColumnText column = new ColumnText(writer.getDirectContent()); column.setSimpleColumn(document.left(), document.bottom(), document.right(), document.top()); column.addElement(paragraph); column.go(); document.newPage(); document.add(paragraph); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:rollyroll.com.servlet.ModuloServlet.java
private void exportar_ModulosaPDF(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try {// www .java2 s. c o m // String[] headers = new String[]{"CODIGO", "NOMBRE", "ACCION", "ORDEN", "ICONO", "ESTADO"}; String[] headers = new String[] { "NOMBRE", "ACCION", "ICONO" }; ArrayList<Modulo> lista = null; lista = moduloService.listar_Modulos(); PdfPTable table = new PdfPTable(headers.length); table.setHorizontalAlignment(0); table.setWidthPercentage(95); float[] espaciocolumna = new float[] { 25f, 38f, 50f }; table.setWidths(espaciocolumna); for (int i = 0; i < headers.length; i++) { String header = headers[i]; PdfPCell cell = new PdfPCell(); cell.setBackgroundColor(Color.YELLOW); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell.setPhrase(new Phrase(header.toUpperCase(), new Font(Font.HELVETICA, 10, Font.BOLD))); table.addCell(cell); } table.completeRow(); PdfPCell cell; // int codigomodulo = 0; String nombremodulo = ""; String accionmodulo = ""; // int ordenmodulo = 0; String iconomodulo = ""; // int estadomodulo = 0; for (Modulo modulo : lista) { // codigomodulo += Integer.parseInt(modulo.getCodigomodulo()); nombremodulo += modulo.getNombremodulo(); accionmodulo += modulo.getAccionmodulo(); // ordenmodulo += Integer.parseInt(modulo.getOrdenmoduloS()); iconomodulo += modulo.getIconomodulo(); // estadomodulo += Byte.parseByte(modulo.getEstadomoduloS()); // cell = new PdfPCell(); // cell.setPhrase(new Phrase(modulo.getCodigomoduloS(), new Font(Font.HELVETICA, 10, Font.NORMAL))); // cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); // table.addCell(cell); // cell = new PdfPCell(); cell.setPhrase(new Phrase(modulo.getNombremodulo(), new Font(Font.HELVETICA, 10, Font.NORMAL))); cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(); cell.setPhrase(new Phrase(modulo.getAccionmodulo(), new Font(Font.HELVETICA, 10, Font.NORMAL))); cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.addCell(cell); // cell = new PdfPCell(); // cell.setPhrase(new Phrase(modulo.getOrdenmoduloS(), new Font(Font.HELVETICA, 10, Font.NORMAL))); // cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); // table.addCell(cell); cell = new PdfPCell(); cell.setPhrase(new Phrase(modulo.getIconomodulo(), new Font(Font.HELVETICA, 10, Font.NORMAL))); cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.addCell(cell); // cell = new PdfPCell(); // cell.setPhrase(new Phrase(modulo.getEstadomoduloS(), new Font(Font.HELVETICA, 10, Font.NORMAL))); // cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); // table.addCell(cell); } table.completeRow(); //incia diseo de documento exportado Document document = new Document(PageSize.A4.rotate(), 20, 5, 5, 5); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open(); document.addTitle("Reporte de Ventas Generales"); document.add( new Paragraph("Reporte: Ventas Generales 2016", new Font(Font.HELVETICA, 16, Font.UNDERLINE))); document.add(new Paragraph("_")); document.add(table); document.add(Chunk.NEWLINE); document.add(new Paragraph( "Leyenda: AB: Inicio, BA: Retorno (Importante: No se consideran unidades sin GPS)")); document.addAuthor("Quispe Roque Alex Christian"); table = new PdfPTable(4); table.setHorizontalAlignment(0); table.setWidthPercentage(40); espaciocolumna = new float[] { 10f, 40f, 20f, 20f }; table.setWidths(espaciocolumna); cell = new PdfPCell(); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell.setPhrase(new Phrase("RESUMEN", new Font(Font.HELVETICA, 10, Font.BOLD))); cell.setColspan(7); table.addCell(cell); table.completeRow(); //aqui iniciamos asignacion de datos //=================================================================== // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setBackgroundColor(Color.yellow); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("FLOTA OPERATIVA", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase(lista.size() + "", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("UNIDADES", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // table.completeRow(); // // //================================================================================== // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("2", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setBackgroundColor(Color.yellow); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("NRO DE VIAJES", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase((totalAB + totalBA) + "", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("VIAJES", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // table.completeRow(); //================================================================================== document.add(Chunk.NEWLINE); document.add(table); document.left(1); document.top(1); document.close(); response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); // response.setHeader("Content-Disposition", "attachment; filename=ReporteGeneraldeModulos.pdf"); response.setHeader("Content-Disposition", "filename=ReporteGeneraldeModulos.pdf"); response.setHeader("Pragma", "public"); response.setContentType("application/pdf"); response.setContentLength(baos.size()); ServletOutputStream out = response.getOutputStream(); baos.writeTo(out); out.flush(); } catch (Exception e) { RequestDispatcher rd2; rd2 = request.getRequestDispatcher("vista/include/error_404.jsp"); rd2.forward(request, response); System.out.println( "rollyroll.com.servlet.ModuloServlet.exportar_ModulosaPDF() => ERROR GRAVE AL GENERAR PDF"); e.getMessage(); } }
From source file:se.idega.idegaweb.commune.school.business.StudentAddressLabelsWriter.java
License:Open Source License
/** * Creates PDF address labels for the specified school classes. *//*from w w w .j av a 2 s. co m*/ protected MemoryFileBuffer getPDFBuffer(IWApplicationContext iwac, Collection receivers) throws Exception { this.business = getSchoolCommuneBusiness(iwac); this.userBusiness = getCommuneUserBusiness(iwac); IWResourceBundle iwrb = iwac.getIWMainApplication().getBundle(CommuneBlock.IW_BUNDLE_IDENTIFIER) .getResourceBundle(iwac.getApplicationSettings().getApplicationLocale()); MemoryFileBuffer buffer = new MemoryFileBuffer(); MemoryOutputStream mos = new MemoryOutputStream(buffer); Document document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter writer = PdfWriter.getInstance(document, mos); document.addTitle("Student address labels"); document.addAuthor("Idega Reports"); document.addSubject("Student address labels"); document.open(); this.font = new Font(Font.HELVETICA, 9, Font.BOLD); int studentCount = 0; Iterator iter = receivers.iterator(); while (iter.hasNext()) { if (studentCount > 0 && studentCount % NR_OF_ADDRESSES_PER_PAGE == 0) { document.newPage(); } addAddress(writer, iwrb, (MailReceiver) iter.next(), studentCount++); } if (studentCount == 0) { throw new Exception("No students."); } document.close(); writer.setPdfVersion(PdfWriter.VERSION_1_2); buffer.setMimeType(MIME_PDF); return buffer; }
From source file:se.idega.idegaweb.commune.school.report.business.ReportPDFWriter.java
License:Open Source License
private MemoryFileBuffer getPDFBuffer() throws DocumentException { MemoryFileBuffer buffer = new MemoryFileBuffer(); MemoryOutputStream mos = new MemoryOutputStream(buffer); Document document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter writer = PdfWriter.getInstance(document, mos); String titleKey = this._reportModel.getReportTitleLocalizationKey(); String title = localize(titleKey, titleKey); this._normalFont = new Font(Font.HELVETICA, 7, Font.NORMAL); this._boldFont = new Font(Font.HELVETICA, 7, Font.BOLD); document.addTitle(title);/*from ww w.ja v a2 s .c o m*/ document.addAuthor("Agura IT Reports"); document.addSubject(title); document.open(); String dateString = new Date(System.currentTimeMillis()).toString(); document.add(new Phrase(title + " " + dateString + "\n\n", this._boldFont)); document.add(new Phrase("\n", this._boldFont)); int cols = this._reportModel.getColumnSize() + 1; Table table = new Table(cols); this._widths = new int[cols]; for (int i = 0; i < cols; i++) { this._widths[i] = 1; } table.setSpacing(1.5f); buildColumnHeaders(table); buildRowHeaders(table); buildReportCells(table); int totalWidth = 0; for (int i = 0; i < cols; i++) { this._widths[i] += 1; totalWidth += this._widths[i]; } int width = (100 * totalWidth) / 95; if (width > 100) { width = 100; } table.setWidth(width); table.setWidths(this._widths); document.add(table); document.close(); writer.setPdfVersion(PdfWriter.VERSION_1_2); return buffer; }