Example usage for com.lowagie.text FontFactory HELVETICA

List of usage examples for com.lowagie.text FontFactory HELVETICA

Introduction

In this page you can find the example usage for com.lowagie.text FontFactory HELVETICA.

Prototype

String HELVETICA

To view the source code for com.lowagie.text FontFactory HELVETICA.

Click Source Link

Document

This is a possible value of a base 14 type 1 font

Usage

From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java

License:Open Source License

/**
 * This method adds any error to the report
 * // w  w w.ja  v a  2  s. c o m
 * @param errorMsg
 */
private void generateReportErrorLog(String errorMsg) {
    try {
        Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL);
        Paragraph p1 = new Paragraph();

        int rowsWritten = 0;
        if (!errorMsg.equals("")) {
            this.generateErrorColumnHeaders();

            p1 = new Paragraph(new Chunk(errorMsg, font));
            this.document.add(p1);
            line++;
        }
    } catch (Exception de) {
        throw new RuntimeException(
                "DepreciationReport.generateReportErrorLog(List<String> reportLog) - Report Generation Failed: "
                        + de.getMessage());
    }
}

From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java

License:Open Source License

/**
 * This method creates a report group for the error message on the report
 * /*from w  ww.  j a  v  a2s .co m*/
 * @throws DocumentException
 */
private void generateErrorColumnHeaders() throws DocumentException {
    try {
        int headerwidths[] = { 60 };

        Table aTable = new Table(1, 1); // 2 columns, 1 rows.

        aTable.setAutoFillEmptyCells(true);
        aTable.setPadding(3);
        aTable.setWidths(headerwidths);
        aTable.setWidth(100);

        Cell cell;

        Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL);

        cell = new Cell(new Phrase("Error(s)", font));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setGrayFill(0.9f);
        aTable.addCell(cell);

        this.document.add(aTable);

    } catch (Exception e) {
        throw new RuntimeException(
                "DepreciationReport.generateErrorColumnHeaders() - Error: " + e.getMessage());
    }
}

From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java

License:Open Source License

/**
 * This method creates the headers for the report statistics
 *//*from w w  w.j  a  v a 2s.  c  o m*/
private void generateColumnHeaders() {
    try {
        int headerwidths[] = { 40, 15 };

        Table aTable = new Table(2, 1); // 2 columns, 1 rows.

        aTable.setAutoFillEmptyCells(true);
        aTable.setPadding(3);
        aTable.setWidths(headerwidths);
        aTable.setWidth(100);

        Cell cell;

        Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL);

        cell = new Cell(new Phrase(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(
                CamsKeyConstants.Depreciation.MSG_REPORT_DEPRECIATION_HEADING1), font));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setGrayFill(0.9f);
        aTable.addCell(cell);

        cell = new Cell(new Phrase(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(
                CamsKeyConstants.Depreciation.MSG_REPORT_DEPRECIATION_HEADING2), font));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setGrayFill(0.9f);
        aTable.addCell(cell);
        this.document.add(aTable);

    } catch (Exception e) {
        throw new RuntimeException("DepreciationReport.generateColumnHeaders() - Error: " + e.getMessage());
    }
}

From source file:org.kuali.kfs.module.tem.pdf.Coversheet.java

License:Open Source License

/**
 * Creates instructions section of the coverpage
 *
 * @returns a {@link Paragraph} for the PDF
 *//*from   w ww  . j a  v a 2  s  . com*/
protected Paragraph getInstructionsParagraph() {
    final Font headerFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
    final Font normalFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL);
    final Paragraph retval = new Paragraph();
    retval.add(new Chunk("Instructions", headerFont));
    retval.add(Chunk.NEWLINE);
    retval.add(new Phrase(getInstructions(), normalFont));
    return retval;
}

From source file:org.kuali.kfs.module.tem.pdf.Coversheet.java

License:Open Source License

/**
 * Creates mailTo section for the coversheet. The MailTo section is where the coversheet will be mailed.
 *
 * @returns a {@link Paragraph} for the PDF
 *///ww w.  ja  v  a 2 s .  co m
protected Paragraph getMailtoParagraph() {
    final Font headerFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
    final Font normalFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL);
    final Paragraph retval = new Paragraph();
    retval.add(new Chunk("Mail coversheet to:", headerFont));
    retval.add(Chunk.NEWLINE);
    retval.add(new Phrase(getMailTo(), normalFont));
    return retval;
}

From source file:org.kuali.kfs.module.tem.pdf.Coversheet.java

License:Open Source License

/**
 * Helper method to create a Header Cell from text
 *
 * @returns {@link Cell} with the header flag set
 *//* w  ww . j  ava2 s  .  com*/
protected Cell getBorderlessCell(final String text) throws BadElementException {
    final Font normalFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL);
    final Cell retval = new Cell(new Chunk(text, normalFont));
    retval.setBorder(NO_BORDER);
    return retval;
}

From source file:org.kuali.kfs.module.tem.pdf.Coversheet.java

License:Open Source License

/**
 * Helper method to create a Header Cell from text
 *
 * @returns {@link Cell} with the header flag set
 *//* w w  w.  j av a2 s  .  c o  m*/
protected Cell getHeaderCell(final String text) throws BadElementException {
    final Font headerFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
    final Cell retval = new Cell(new Chunk(text, headerFont));
    retval.setBorder(NO_BORDER);
    retval.setHeader(true);
    return retval;
}

From source file:org.kuali.kfs.module.tem.pdf.Coversheet.java

License:Open Source License

/**
 * @see org.kuali.kfs.module.tem.pdf.PdfStream#print(java.io.OutputStream)
 * @throws Exception//from   ww w.  ja va2s.  c o m
 */
@Override
public void print(final OutputStream stream) throws Exception {
    final Font titleFont = FontFactory.getFont(FontFactory.HELVETICA, 20, Font.BOLD);
    final Font headerFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
    final Font normalFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL);

    final Document doc = new Document();
    final PdfWriter writer = PdfWriter.getInstance(doc, stream);
    doc.open();
    if (getDocumentNumber() != null) {
        Image image = Image.getInstance(new BarcodeHelper().generateBarcodeImage(getDocumentNumber()), null);
        doc.add(image);
    }

    final Paragraph title = new Paragraph("TEM Coversheet", titleFont);
    doc.add(title);

    final Paragraph faxNumber = new Paragraph(
            "Fax this page to " + SpringContext.getBean(ParameterService.class)
                    .getParameterValueAsString(TravelReimbursementDocument.class, FAX_NUMBER),
            normalFont);
    doc.add(faxNumber);

    final Paragraph header = new Paragraph("", headerFont);
    header.setAlignment(ALIGN_RIGHT);
    header.add("Document Number: " + getDocumentNumber());
    doc.add(header);
    doc.add(getInstructionsParagraph());
    doc.add(getMailtoParagraph());
    doc.add(Chunk.NEWLINE);
    doc.add(getTripInfo());
    doc.add(Chunk.NEWLINE);
    doc.add(getPersonalInfo());
    doc.add(Chunk.NEWLINE);
    doc.add(getExpenses());

    drawAlignmentMarks(writer.getDirectContent());

    doc.close();
    writer.close();
}

From source file:org.netxilia.server.rest.pdf.SheetPdfProvider.java

License:Open Source License

@Override
public void writeTo(SheetFullName sheetName, Class<?> clazz, Type type, Annotation[] ann, MediaType mediaType,
        MultivaluedMap<String, Object> headers, OutputStream out) throws IOException, WebApplicationException {

    if (sheetName == null) {
        return;/*  www .j a va2 s .  co  m*/
    }

    /**
     * This is the table, added as an Element to the PDF document. It contains all the data, needed to represent the
     * visible table into the PDF
     */
    Table tablePDF;

    /**
     * The default font used in the document.
     */
    Font smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL, new Color(0, 0, 0));
    ISheet summarySheet = null;
    ISheet sheet = null;
    try {
        sheet = workbookProcessor.getWorkbook(sheetName.getWorkbookId()).getSheet(sheetName.getSheetName());
        try {
            // get the corresponding summary sheet
            SheetFullName summarySheetName = SheetFullName.summarySheetName(sheetName,
                    userService.getCurrentUser());
            summarySheet = workbookProcessor.getWorkbook(summarySheetName.getWorkbookId())
                    .getSheet(summarySheetName.getSheetName());

        } catch (Exception e) {
            // no summary sheet - go without one
        }

        // Initialize the Document and register it with PdfWriter listener and the OutputStream
        Document document = new Document(PageSize.A4.rotate(), 60, 60, 40, 40);
        document.addCreationDate();
        HeaderFooter footer = new HeaderFooter(new Phrase("", smallFont), true);
        footer.setBorder(Rectangle.NO_BORDER);
        footer.setAlignment(Element.ALIGN_CENTER);

        PdfWriter.getInstance(document, out);

        // Fill the virtual PDF table with the necessary data
        // Initialize the table with the appropriate number of columns
        tablePDF = initTable(sheet);
        // take tha maximum numbers of columns
        int columnCount = sheet.getDimensions().getNonBlocking().getColumnCount();
        if (summarySheet != null) {
            columnCount = Math.max(columnCount, summarySheet.getDimensions().getNonBlocking().getColumnCount());
        }
        generateHeaders(sheet, tablePDF, smallFont, columnCount);

        tablePDF.endHeaders();
        generateRows(sheet, false, tablePDF, smallFont, columnCount);
        if (summarySheet != null) {
            generateRows(summarySheet, true, tablePDF, smallFont, columnCount);
        }

        document.open();
        document.setFooter(footer);
        document.add(tablePDF);
        document.close();

        out.flush();
        out.close();

    } catch (Exception e) {
        throw new IOException(e);
    }
}

From source file:org.posterita.businesslogic.administration.CustomerManager.java

License:Open Source License

public static String fidelityCard(Properties ctx, ArrayList<CustomerBean> customerList)
        throws OperationException {
    String reportName = RandomStringGenerator.randomstring() + ".pdf";
    String reportPath = ReportManager.getReportPath(reportName);

    boolean shouldPrintCard = false;

    for (CustomerBean b : customerList) {
        if (b.getIsActive()) {
            shouldPrintCard = true;/* ww  w . j  ava 2  s.c  o  m*/
            break;
        }
    }

    if (!shouldPrintCard) {
        throw new NoCustomerFoundException("Cannot print fidelity card. Cause no active customers were found.");
    }

    Document document = new Document(PageSize.A4, 3, 3, 2, 4);//l,r,t,b

    try {
        //          step 2:
        // we create a writer that listens to the document
        // and directs a PDF-stream to a file
        PdfWriter.getInstance(document, new FileOutputStream(reportPath));

        // step 3: we open the document
        document.open();

        PdfPTable main = new PdfPTable(2);
        main.setWidthPercentage(71.0f);
        main.getDefaultCell().setBorderColor(Color.gray);

        PdfPCell cell = new PdfPCell();
        cell.setMinimumHeight(150.0f);

        Font smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD);
        //Font spaceFont = FontFactory.getFont(FontFactory.HELVETICA,6,Font.BOLD);
        //Font spaceFont2 = FontFactory.getFont(FontFactory.HELVETICA,15,Font.BOLD);

        //ResourceBundle rb = ResourceBundle.getBundle("MessageResources");

        for (CustomerBean bean : customerList) {
            if (bean.getIsActive()) {
                String name = bean.getPartnerName();
                String name1 = "";
                String add2 = "";
                String add1 = "";
                String city = "";

                if (bean.getAddress1() != null)
                    add1 = bean.getAddress1();

                if (bean.getAddress2() != null)
                    add2 = bean.getAddress2();

                if (bean.getCity() != null)
                    city = bean.getCity();

                String Address = "   " + add1;
                String Add2 = " " + add2;
                String Add3 = "   " + city;

                String BackPriv1Path = PathInfo.PROJECT_HOME + "/images/BackPriv1.jpg";
                String backPriv2Path = PathInfo.PROJECT_HOME + "/images/backPriv2.jpg";
                String frontImgPath = PathInfo.PROJECT_HOME + "/images/pc.png";

                float WIDTH = 205;
                float HEIGHT = 135;

                Image Back1 = Image.getInstance(BackPriv1Path);
                Back1.scaleAbsolute(WIDTH - 40, HEIGHT / 3);
                Image Back2 = Image.getInstance(backPriv2Path);
                Back2.scaleAbsolute(WIDTH, HEIGHT / 3);
                Image frontImg = Image.getInstance(frontImgPath);
                frontImg.scaleAbsolute(WIDTH, HEIGHT);

                if (bean.getSurname() != null && bean.getSurname().trim().length() > 0)
                    name1 = "   " + name + " " + name1 + bean.getSurname();

                byte[] barcode = BarcodeManager.getBarcodeAsByte(bean.getBpartnerId().toString());
                Image barcodeImg = Image.getInstance(barcode);
                barcodeImg.setRotation(1.57f);
                barcodeImg.scaleAbsolute(HEIGHT - 55f, WIDTH / 5);

                //document.add(barcodeImg);
                PdfPTable card = new PdfPTable(2);
                card.getDefaultCell().setBorderWidth(0.0f);

                PdfPCell c = null;
                card.setWidthPercentage(50.0f);

                PdfPTable t = new PdfPTable(1);
                PdfPTable nametable = new PdfPTable(1);

                c = new PdfPCell(Back1);
                c.setBorderWidth(0.0f);
                nametable.addCell(c);

                c = new PdfPCell(new Phrase(name1, smallFont));
                c.setHorizontalAlignment(Element.ALIGN_CENTER);
                c.setVerticalAlignment(Element.ALIGN_CENTER);
                c.setBorderWidth(0.0f);
                nametable.addCell(c);

                c = new PdfPCell(new Phrase(Address, smallFont));
                c.setHorizontalAlignment(Element.ALIGN_CENTER);
                c.setVerticalAlignment(Element.ALIGN_CENTER);
                c.setBorderWidth(0.0f);
                //c.setColspan(2);
                nametable.addCell(c);

                c = new PdfPCell(new Phrase(Add2, smallFont));
                c.setHorizontalAlignment(Element.ALIGN_CENTER);
                c.setVerticalAlignment(Element.ALIGN_CENTER);
                c.setBorderWidth(0.0f);
                //c.setColspan(2);
                nametable.addCell(c);

                c = new PdfPCell(new Phrase(Add3, smallFont));
                c.setHorizontalAlignment(Element.ALIGN_CENTER);
                c.setVerticalAlignment(Element.ALIGN_CENTER);
                c.setBorderWidth(0.0f);
                //c.setColspan(2);
                nametable.addCell(c);

                //nametable.getDefaultCell();
                nametable.getDefaultCell().setBorderWidth(0.0f);
                nametable.setHorizontalAlignment(Element.ALIGN_CENTER);
                card.addCell(nametable);

                c = new PdfPCell(barcodeImg);
                c.setBorderWidth(0.0f);
                //c.setColspan(2);
                c.setHorizontalAlignment(Element.ALIGN_RIGHT);
                c.setVerticalAlignment(Element.ALIGN_MIDDLE);
                c.setPadding(5.0f);
                card.addCell(c);

                c = new PdfPCell(Back2);
                c.setBorderWidth(0.0f);
                c.setColspan(2);
                card.addCell(c);

                c = new PdfPCell(new Phrase(name1, smallFont));
                c.setBorderWidth(0.0f);
                t.addCell(c);

                c = new PdfPCell(new Phrase(Address, smallFont));
                c.setBorderWidth(0.0f);
                t.addCell(c);

                c = new PdfPCell(new Phrase(Add3, smallFont));
                c.setBorderWidth(0.0f);
                t.addCell(c);

                PdfPTable card1 = new PdfPTable(1);
                card.getDefaultCell().setBorderWidth(0.0f);

                PdfPCell c1 = null;
                card.setWidthPercentage(50.0f);

                c1 = new PdfPCell(frontImg);
                c1.setBorderWidth(0.0f);
                card1.addCell(c1);

                main.addCell(card);
                main.addCell(card1);
            }

        }
        document.add(main);

    }
    // TODO handle the following exception neatly
    catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }

    // step 5: we close the document
    document.close();
    return reportName;
}