Example usage for com.lowagie.text Font NORMAL

List of usage examples for com.lowagie.text Font NORMAL

Introduction

In this page you can find the example usage for com.lowagie.text Font NORMAL.

Prototype

int NORMAL

To view the source code for com.lowagie.text Font NORMAL.

Click Source Link

Document

this is a possible style.

Usage

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

License:Open Source License

/**
 * This method adds the log lines into the report
 * /*from   ww  w .j  a v a  2  s  .  c  o m*/
 * @param reportLog
 */
private void generateReportLogBody(List<String[]> reportLog) {
    try {
        Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL);
        int columnwidths[];
        columnwidths = new int[] { 40, 15 };

        Table aTable = new Table(2, linesPerPage);
        int rowsWritten = 0;
        for (String[] columns : reportLog) {
            if (pageNumber == 0 || line >= linesPerPage) {
                if (pageNumber > 0) {
                    this.document.add(aTable);
                }
                int elementsLeft = reportLog.size() - rowsWritten;
                int rowsNeeded = (elementsLeft >= linesPerPage ? linesPerPage : elementsLeft);
                this.document.newPage();

                this.generateColumnHeaders();

                aTable = new Table(2, rowsNeeded); // 12 columns, 11 rows.

                aTable.setAutoFillEmptyCells(true);
                aTable.setPadding(3);
                aTable.setWidths(columnwidths);
                aTable.setWidth(100);
                aTable.setBorder(Rectangle.NO_BORDER);

                line = 0;
                pageNumber++;
            }
            rowsWritten++;

            Cell cell;
            cell = new Cell(new Phrase(columns[0], font));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            aTable.addCell(cell);

            cell = new Cell(new Phrase(columns[1], font));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            aTable.addCell(cell);
            line++;
        }
        this.document.add(aTable);
    } catch (DocumentException de) {
        throw new RuntimeException(
                "DepreciationReport.generateReportLogBody(List<String[]> reportLog) - error: "
                        + de.getMessage());
    }
}

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  . j av  a2  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
 * //  w  w  w  . ja  v  a 2  s  .  com
 * @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
 *//*w  ww.ja va2  s  .  c om*/
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   www . j  a v a  2s . 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.  c  o  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
 *//*from ww  w .  ja va  2 s. c  o  m*/
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

/**
 * @see org.kuali.kfs.module.tem.pdf.PdfStream#print(java.io.OutputStream)
 * @throws Exception/*from  www  . j  a  v  a  2s.  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.kuali.kfs.pdp.batch.service.impl.DailyReportServiceImpl.java

License:Educational Community License

public DailyReportServiceImpl() {
    headerFont = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD);
    textFont = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL);
}

From source file:org.kuali.kra.printing.service.impl.PrintingServiceImpl.java

License:Educational Community License

/**
 * @param pdfBytesList//from  ww w . j  a va  2s .c  om
 *            List containing the PDF data bytes
 * @param bookmarksList
 *            List of bookmarks corresponding to the PDF bytes.
 * @return
 * @throws PrintingException
 */

protected byte[] mergePdfBytes(List<byte[]> pdfBytesList, List<String> bookmarksList,
        boolean headerFooterRequired) throws PrintingException {
    Document document = null;
    PdfWriter writer = null;
    ByteArrayOutputStream mergedPdfReport = new ByteArrayOutputStream();
    int totalNumOfPages = 0;
    PdfReader[] pdfReaderArr = new PdfReader[pdfBytesList.size()];
    int pdfReaderCount = 0;
    for (byte[] fileBytes : pdfBytesList) {
        LOG.debug("File Size " + fileBytes.length + " For " + bookmarksList.get(pdfReaderCount));
        PdfReader reader = null;
        try {
            reader = new PdfReader(fileBytes);
            pdfReaderArr[pdfReaderCount] = reader;
            pdfReaderCount = pdfReaderCount + 1;
            totalNumOfPages += reader.getNumberOfPages();
        } catch (IOException e) {
            LOG.error(e.getMessage(), e);
        }
    }
    HeaderFooter footer = null;
    if (headerFooterRequired) {
        Calendar calendar = dateTimeService.getCurrentCalendar();
        String dateString = formateCalendar(calendar);
        StringBuilder footerPhStr = new StringBuilder();
        footerPhStr.append(" of ");
        footerPhStr.append(totalNumOfPages);
        footerPhStr.append(getWhitespaceString(WHITESPACE_LENGTH_76));
        footerPhStr.append(getWhitespaceString(WHITESPACE_LENGTH_76));
        footerPhStr.append(getWhitespaceString(WHITESPACE_LENGTH_60));
        footerPhStr.append(dateString);
        Font font = FontFactory.getFont(FontFactory.TIMES, 8, Font.NORMAL, Color.BLACK);
        Phrase beforePhrase = new Phrase("Page ", font);
        Phrase afterPhrase = new Phrase(footerPhStr.toString(), font);
        footer = new HeaderFooter(beforePhrase, afterPhrase);
        footer.setAlignment(Element.ALIGN_BASELINE);
        footer.setBorderWidth(0f);
    }
    for (int count = 0; count < pdfReaderArr.length; count++) {
        PdfReader reader = pdfReaderArr[count];
        int nop;
        if (reader == null) {
            LOG.debug("Empty PDF byetes found for " + bookmarksList.get(count));
            continue;
        } else {
            nop = reader.getNumberOfPages();
        }

        if (count == 0) {
            document = nop > 0 ? new com.lowagie.text.Document(reader.getPageSizeWithRotation(1))
                    : new com.lowagie.text.Document();
            try {
                writer = PdfWriter.getInstance(document, mergedPdfReport);
            } catch (DocumentException e) {
                LOG.error(e.getMessage(), e);
                throw new PrintingException(e.getMessage(), e);
            }
            if (footer != null) {
                document.setFooter(footer);
            }
            // writer.setPageEvent(new Watermark());  //  add watermark object here
            document.open();
        }

        PdfContentByte cb = writer.getDirectContent();
        int pageCount = 0;
        while (pageCount < nop) {
            document.setPageSize(reader.getPageSize(++pageCount));
            document.newPage();
            if (footer != null) {
                document.setFooter(footer);
            }
            PdfImportedPage page = writer.getImportedPage(reader, pageCount);

            cb.addTemplate(page, 1, 0, 0, 1, 0, 0);

            PdfOutline root = cb.getRootOutline();
            if (pageCount == 1) {
                String pageName = bookmarksList.get(count);
                cb.addOutline(new PdfOutline(root, new PdfDestination(PdfDestination.FITH), pageName),
                        pageName);
            }
        }
    }
    if (document != null) {
        try {
            document.close();
            return mergedPdfReport.toByteArray();
        } catch (Exception e) {
            LOG.error("Exception occured because the generated PDF document has no pages", e);
        }
    }
    return null;
}