Example usage for com.lowagie.text Paragraph add

List of usage examples for com.lowagie.text Paragraph add

Introduction

In this page you can find the example usage for com.lowagie.text Paragraph add.

Prototype

public boolean add(Object o) 

Source Link

Document

Adds an Object to the Paragraph.

Usage

From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerInvoiceWriteoffBatchServiceImpl.java

License:Open Source License

protected void writeFileNameSectionTitle(com.lowagie.text.Document pdfDoc, String filenameLine) {
    Font font = FontFactory.getFont(FontFactory.COURIER, 10, Font.BOLD);

    //  file name title, get title only, on windows & unix platforms
    String fileNameOnly = filenameLine.toUpperCase();
    int indexOfSlashes = fileNameOnly.lastIndexOf("\\");
    if (indexOfSlashes < fileNameOnly.length()) {
        fileNameOnly = fileNameOnly.substring(indexOfSlashes + 1);
    }//from  w ww  . j  a va  2s . co  m
    indexOfSlashes = fileNameOnly.lastIndexOf("/");
    if (indexOfSlashes < fileNameOnly.length()) {
        fileNameOnly = fileNameOnly.substring(indexOfSlashes + 1);
    }

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT);
    Chunk chunk = new Chunk(fileNameOnly, font);
    chunk.setBackground(Color.LIGHT_GRAY, 5, 5, 5, 5);
    paragraph.add(chunk);

    //  blank line
    paragraph.add(new Chunk("", font));

    try {
        pdfDoc.add(paragraph);
    } catch (DocumentException e) {
        LOG.error("iText DocumentException thrown when trying to write content.", e);
        throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
    }
}

From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerInvoiceWriteoffBatchServiceImpl.java

License:Open Source License

protected void writeInvoiceSectionTitle(com.lowagie.text.Document pdfDoc, String customerNameLine) {
    Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD + Font.UNDERLINE);

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT);
    paragraph.add(new Chunk(customerNameLine, font));

    //  blank line
    paragraph.add(new Chunk("", font));

    try {/* w  ww.  j  av a 2 s. c  o m*/
        pdfDoc.add(paragraph);
    } catch (DocumentException e) {
        LOG.error("iText DocumentException thrown when trying to write content.", e);
        throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
    }
}

From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerInvoiceWriteoffBatchServiceImpl.java

License:Open Source License

protected void writeInvoiceSectionMessage(com.lowagie.text.Document pdfDoc, String resultLine) {
    Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL);

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT);
    paragraph.add(new Chunk(resultLine, font));

    //  blank line
    paragraph.add(new Chunk("", font));

    try {/*from  www  . j a va2  s .  c o m*/
        pdfDoc.add(paragraph);
    } catch (DocumentException e) {
        LOG.error("iText DocumentException thrown when trying to write content.", e);
        throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
    }
}

From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerLoadServiceImpl.java

License:Open Source License

protected void writeFileNameSectionTitle(Document pdfDoc, String filenameLine) {
    Font font = FontFactory.getFont(FontFactory.COURIER, 10, Font.BOLD);

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Element.ALIGN_LEFT);
    Chunk chunk = new Chunk(filenameLine, font);
    chunk.setBackground(Color.LIGHT_GRAY, 5, 5, 5, 5);
    paragraph.add(chunk);

    //  blank line
    paragraph.add(new Chunk("", font));

    try {//from   w  ww .ja  va 2 s . c om
        pdfDoc.add(paragraph);
    } catch (DocumentException e) {
        LOG.error("iText DocumentException thrown when trying to write content.", e);
        throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
    }
}

From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerLoadServiceImpl.java

License:Open Source License

protected void writeCustomerSectionTitle(Document pdfDoc, String customerNameLine) {
    Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD + Font.UNDERLINE);

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Element.ALIGN_LEFT);
    paragraph.add(new Chunk(customerNameLine, font));

    //  blank line
    paragraph.add(new Chunk("", font));

    try {//from w ww  .  jav  a2s .c  om
        pdfDoc.add(paragraph);
    } catch (DocumentException e) {
        LOG.error("iText DocumentException thrown when trying to write content.", e);
        throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
    }
}

From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerLoadServiceImpl.java

License:Open Source License

protected void writeCustomerSectionResult(Document pdfDoc, String resultLine) {
    Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD);

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Element.ALIGN_LEFT);
    paragraph.add(new Chunk(resultLine, font));

    //  blank line
    paragraph.add(new Chunk("", font));

    try {//from  w  ww.j  a  v  a  2 s.c om
        pdfDoc.add(paragraph);
    } catch (DocumentException e) {
        LOG.error("iText DocumentException thrown when trying to write content.", e);
        throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
    }
}

From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerLoadServiceImpl.java

License:Open Source License

protected void writeMessageEntryLines(Document pdfDoc, List<String[]> messageLines) {
    Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL);

    Paragraph paragraph;
    String messageEntry;/*from   www  .  java 2  s.c om*/
    for (String[] messageLine : messageLines) {
        paragraph = new Paragraph();
        paragraph.setAlignment(Element.ALIGN_LEFT);
        messageEntry = StringUtils.rightPad(messageLine[0], (12 - messageLine[0].length()), " ") + " - "
                + messageLine[1].toUpperCase();
        paragraph.add(new Chunk(messageEntry, font));

        //  blank line
        paragraph.add(new Chunk("", font));

        try {
            pdfDoc.add(paragraph);
        } catch (DocumentException e) {
            LOG.error("iText DocumentException thrown when trying to write content.", e);
            throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
        }
    }
}

From source file:org.kuali.kfs.module.ar.batch.service.impl.LockboxServiceImpl.java

License:Open Source License

protected void writeBatchGroupSectionTitle(com.lowagie.text.Document pdfDoc, String batchSeqNbr,
        java.sql.Date procInvDt, String cashControlDocNumber) {
    Font font = FontFactory.getFont(FontFactory.COURIER, 10, Font.BOLD);

    String lineText = "CASHCTL " + rightPad(cashControlDocNumber, 12) + " " + "BATCH GROUP: "
            + rightPad(batchSeqNbr, 5) + " "
            + rightPad((procInvDt == null ? "NONE" : procInvDt.toString()), 35);

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT);
    Chunk chunk = new Chunk(lineText, font);
    chunk.setBackground(Color.LIGHT_GRAY, 5, 5, 5, 5);
    paragraph.add(chunk);

    //  blank line
    paragraph.add(new Chunk("", font));

    try {/*ww w .  j ava2  s . co  m*/
        pdfDoc.add(paragraph);
    } catch (DocumentException e) {
        LOG.error("iText DocumentException thrown when trying to write content.", e);
        throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
    }
}

From source file:org.kuali.kfs.module.ar.batch.service.impl.LockboxServiceImpl.java

License:Open Source License

protected void writeDetailLine(com.lowagie.text.Document pdfDoc, String detailLineText) {
    if (ObjectUtils.isNotNull(detailLineText)) {
        Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL);

        Paragraph paragraph = new Paragraph();
        paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT);
        paragraph.add(new Chunk(detailLineText, font));

        try {//from  w  w w.  ja v  a  2s. c o  m
            pdfDoc.add(paragraph);
        } catch (DocumentException e) {
            LOG.error("iText DocumentException thrown when trying to write content.", e);
            throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
        }
    }
}

From source file:org.kuali.kfs.module.ar.report.service.impl.ContractsGrantsInvoiceReportServiceImpl.java

License:Open Source License

/**
 * this method generated the actual pdf for the Contracts & Grants LOC Review Document.
 *
 * @param os/*w w  w  .j av  a 2  s .  c  o  m*/
 * @param LOCDocument
 */
protected void generateLOCReviewInPdf(OutputStream os,
        ContractsGrantsLetterOfCreditReviewDocument locDocument) {
    try {
        Document document = new Document(
                new Rectangle(ArConstants.LOCReviewPdf.LENGTH, ArConstants.LOCReviewPdf.WIDTH));
        PdfWriter.getInstance(document, os);
        document.open();

        Paragraph header = new Paragraph();
        Paragraph text = new Paragraph();
        Paragraph title = new Paragraph();

        // Lets write the header
        header.add(new Paragraph(configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_TITLE),
                ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT));
        if (StringUtils.isNotEmpty(locDocument.getLetterOfCreditFundGroupCode())) {
            header.add(new Paragraph(
                    configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_FUND_GROUP_CODE)
                            + locDocument.getLetterOfCreditFundGroupCode(),
                    ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT));
        }
        if (StringUtils.isNotEmpty(locDocument.getLetterOfCreditFundCode())) {
            header.add(new Paragraph(
                    configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_FUND_CODE)
                            + locDocument.getLetterOfCreditFundCode(),
                    ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT));
        }
        header.add(new Paragraph(KFSConstants.BLANK_SPACE));
        header.setAlignment(Element.ALIGN_CENTER);
        title.add(new Paragraph(
                configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_NUMBER)
                        + locDocument.getDocumentNumber(),
                ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));
        Person person = getPersonService()
                .getPerson(locDocument.getFinancialSystemDocumentHeader().getInitiatorPrincipalId());
        // writing the Document details
        title.add(new Paragraph(
                configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_APP_DOC_STATUS)
                        + locDocument.getFinancialSystemDocumentHeader().getApplicationDocumentStatus(),
                ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));
        title.add(
                new Paragraph(
                        configService.getPropertyValueAsString(
                                ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_INITIATOR) + person.getName(),
                        ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));
        title.add(new Paragraph(
                configService
                        .getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_CREATE_DATE)
                        + getDateTimeService().toDateString(
                                locDocument.getFinancialSystemDocumentHeader().getWorkflowCreateDate()),
                ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));

        title.add(new Paragraph(KFSConstants.BLANK_SPACE));
        title.setAlignment(Element.ALIGN_RIGHT);

        text.add(new Paragraph(
                configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_SUBHEADER_AWARDS),
                ArConstants.PdfReportFonts.LOC_REVIEW_SMALL_BOLD));
        text.add(new Paragraph(KFSConstants.BLANK_SPACE));

        document.add(header);
        document.add(title);
        document.add(text);
        PdfPTable table = new PdfPTable(11);
        table.setTotalWidth(ArConstants.LOCReviewPdf.RESULTS_TABLE_WIDTH);
        // fix the absolute width of the table
        table.setLockedWidth(true);

        // relative col widths in proportions - 1/11
        float[] widths = new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f };
        table.setWidths(widths);
        table.setHorizontalAlignment(0);
        addAwardHeaders(table);
        if (CollectionUtils.isNotEmpty(locDocument.getHeaderReviewDetails())
                && CollectionUtils.isNotEmpty(locDocument.getAccountReviewDetails())) {
            for (ContractsGrantsLetterOfCreditReviewDetail item : locDocument.getHeaderReviewDetails()) {
                table.addCell(Long.toString(item.getProposalNumber()));
                table.addCell(item.getAwardDocumentNumber());
                table.addCell(item.getAgencyNumber());
                table.addCell(item.getCustomerNumber());
                table.addCell(getDateTimeService().toDateString(item.getAwardBeginningDate()));
                table.addCell(getDateTimeService().toDateString(item.getAwardEndingDate()));
                table.addCell(
                        contractsGrantsBillingUtilityService.formatForCurrency(item.getAwardBudgetAmount()));
                table.addCell(
                        contractsGrantsBillingUtilityService.formatForCurrency(item.getLetterOfCreditAmount()));
                table.addCell(
                        contractsGrantsBillingUtilityService.formatForCurrency(item.getClaimOnCashBalance()));
                table.addCell(contractsGrantsBillingUtilityService.formatForCurrency(item.getAmountToDraw()));
                table.addCell(contractsGrantsBillingUtilityService
                        .formatForCurrency(item.getAmountAvailableToDraw()));

                PdfPCell cell = new PdfPCell();
                cell.setPadding(ArConstants.LOCReviewPdf.RESULTS_TABLE_CELL_PADDING);
                cell.setColspan(ArConstants.LOCReviewPdf.RESULTS_TABLE_COLSPAN);
                PdfPTable newTable = new PdfPTable(ArConstants.LOCReviewPdf.INNER_TABLE_COLUMNS);
                newTable.setTotalWidth(ArConstants.LOCReviewPdf.INNER_TABLE_WIDTH);
                // fix the absolute width of the newTable
                newTable.setLockedWidth(true);

                // relative col widths in proportions - 1/8
                float[] newWidths = new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f };
                newTable.setWidths(newWidths);
                newTable.setHorizontalAlignment(0);
                addAccountsHeaders(newTable);
                for (ContractsGrantsLetterOfCreditReviewDetail newItem : locDocument
                        .getAccountReviewDetails()) {
                    if (item.getProposalNumber().equals(newItem.getProposalNumber())) {
                        newTable.addCell(newItem.getAccountDescription());
                        newTable.addCell(newItem.getChartOfAccountsCode());
                        newTable.addCell(newItem.getAccountNumber());
                        String accountExpirationDate = KFSConstants.EMPTY_STRING;
                        if (!ObjectUtils.isNull(newItem.getAccountExpirationDate())) {
                            accountExpirationDate = getDateTimeService()
                                    .toDateString(newItem.getAccountExpirationDate());
                        }
                        newTable.addCell(accountExpirationDate);
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getAwardBudgetAmount()));
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getClaimOnCashBalance()));
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getAmountToDraw()));
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getFundsNotDrawn()));
                    }
                }
                cell.addElement(newTable);
                table.addCell(cell);

            }
            document.add(table);
        }
        document.close();
    } catch (DocumentException e) {
        LOG.error("problem during ContractsGrantsInvoiceReportServiceImpl.generateInvoiceInPdf()", e);
    }
}