Example usage for com.lowagie.text.pdf PdfPCell setHorizontalAlignment

List of usage examples for com.lowagie.text.pdf PdfPCell setHorizontalAlignment

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfPCell setHorizontalAlignment.

Prototype

public void setHorizontalAlignment(int horizontalAlignment) 

Source Link

Document

Sets the horizontal alignment for the cell.

Usage

From source file:org.cocktail.superplan.server.gestionimpression.TabularEdtReport.java

License:CeCILL license

public NSData genererPdf(NSArray creneaux, NSTimestamp debutSemaine, String semaine, String libelleFormation)
        throws DocumentException {

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    Document document = new Document();
    PdfWriter.getInstance(document, os);
    document.open();/* w  w w  . ja  v  a  2s.com*/
    document.setMargins(0, 0, 0, 0);

    Font font = new Font(Font.TIMES_ROMAN, 12, Font.BOLD, Color.DARK_GRAY);

    PdfPTable headerTable = new PdfPTable(1);

    PdfPCell cell = new PdfPCell();
    Phrase ph = new Phrase();
    ph.add(new Chunk(libelleFormation, font));
    cell.setPhrase(ph);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    headerTable.addCell(cell);

    font = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL, Color.DARK_GRAY);
    cell = new PdfPCell();
    ph = new Phrase();
    ph.add(new Chunk(semaine, font));
    cell.setPhrase(ph);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    headerTable.addCell(cell);

    headerTable.setWidthPercentage(100);
    headerTable.setSpacingAfter(5.0f);

    document.add(headerTable);

    PdfPTable pdfTable = creerCreneauxTable(creneaux, debutSemaine);

    pdfTable.setWidthPercentage(100);

    document.add(pdfTable);
    document.close();
    return new NSData(os.toByteArray());
}

From source file:org.drools.verifier.doc.DroolsDocsComponentFactory.java

License:Apache License

public void onEndPage(PdfWriter writer, Document document) {

    try {//from   w  ww.ja v  a 2s.com
        Image image = Image.getInstance(DroolsDocsBuilder.class.getResource("guvnor-webapp.png")); // TODO this image never existed
        image.setAlignment(Image.RIGHT);
        image.scaleAbsolute(100, 30);
        Rectangle page = document.getPageSize();
        PdfPTable head = new PdfPTable(2);

        PdfPCell cell1 = new PdfPCell(image);
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setBorder(0);

        head.addCell(cell1);

        PdfPCell cell2 = new PdfPCell(new Phrase(currentDate, DroolsDocsComponentFactory.HEADER_FOOTER_TEXT));
        cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell2.setBorder(0);

        head.addCell(cell2);

        head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        head.writeSelectedRows(0, -1, document.leftMargin(),
                page.getHeight() - document.topMargin() + head.getTotalHeight(), writer.getDirectContent());

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

From source file:org.gtdfree.addons.PDFExportAddOn.java

License:Open Source License

@Override
public void export(GTDModel model, ActionsCollection collection, OutputStream out,
        ExportAddOn.ExportOrder order, FileFilter ff, boolean compact) throws Exception {

    fontSelector = new FontSelector();
    fontSelectorB = new FontSelector();
    fontSelectorB2 = new FontSelector();
    fontSelectorB4 = new FontSelector();

    baseFont = fontModel.getBaseFont();/*from  w  w w .  j  a  va 2s . co m*/

    for (BaseFont bf : fontModel.getFonts()) {
        fontSelector.addFont(new Font(bf, baseFontSize));
        fontSelectorB.addFont(new Font(bf, baseFontSize, Font.BOLD));
        fontSelectorB2.addFont(new Font(bf, baseFontSize + 2, Font.BOLD));
        fontSelectorB4.addFont(new Font(bf, baseFontSize + 4, Font.BOLD));
    }

    boolean emptyH2 = false;
    boolean emptyH3 = false;

    PdfPTable actionTable = null;

    Document doc = new Document();

    if (sizeSet) {
        doc.setPageSize(pageSize);
    }
    if (marginSet) {
        doc.setMargins(marginLeft, marginRight, marginTop, marginBottom);
    }

    //System.out.println("PDF size "+doc.getPageSize().toString());
    //System.out.println("PDF m "+marginLeft+" "+marginRight+" "+marginTop+" "+marginBottom);

    @SuppressWarnings("unused")
    PdfWriter pw = PdfWriter.getInstance(doc, out);

    doc.addCreationDate();
    doc.addTitle("GTD-Free PDF");
    doc.addSubject("GTD-Free data exported as PDF");

    HeaderFooter footer = new HeaderFooter(newParagraph(), true);
    footer.setAlignment(HeaderFooter.ALIGN_CENTER);
    footer.setBorder(HeaderFooter.TOP);
    doc.setFooter(footer);

    doc.open();

    Phrase ch = newTitle("GTD-Free Data");
    Paragraph p = new Paragraph(ch);
    p.setAlignment(Paragraph.ALIGN_CENTER);

    PdfPTable t = new PdfPTable(1);
    t.setWidthPercentage(100f);
    PdfPCell c = newCell(p);
    c.setBorder(Table.BOTTOM);
    c.setBorderWidth(2.5f);
    c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    c.setPadding(5f);
    t.addCell(c);
    doc.add(t);

    Iterator<Object> it = collection.iterator(order);

    while (it.hasNext()) {
        Object o = it.next();

        if (o == ActionsCollection.ACTIONS_WITHOUT_PROJECT) {

            if (order == ExportAddOn.ExportOrder.FoldersProjectsActions) {

                doc.add(newSubSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT));

                emptyH2 = false;
                emptyH3 = true;
            } else {

                doc.add(newSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT));

                emptyH2 = true;
                emptyH3 = false;
            }

            continue;
        }

        if (o instanceof Folder) {

            Folder f = (Folder) o;

            if (actionTable != null) {
                doc.add(actionTable);
                actionTable = null;
            }

            if (f.isProject()) {

                if (order == ExportAddOn.ExportOrder.ProjectsActions
                        || order == ExportAddOn.ExportOrder.ProjectsFoldersActions) {

                    if (emptyH2 || emptyH3) {
                        p = newParagraph(NONE_DOT);
                        doc.add(p);
                    }

                    doc.add(newSection(f.getName()));

                    if (compact) {
                        if (f.getDescription() != null && f.getDescription().length() > 0) {
                            p = newParagraph(f.getDescription());
                            p.setIndentationLeft(10f);
                            p.setIndentationRight(10f);
                            doc.add(p);
                        }
                    } else {
                        t = new PdfPTable(2);
                        t.setKeepTogether(true);
                        t.setSpacingBefore(5f);
                        t.setWidthPercentage(66f);
                        t.setWidths(new float[] { 0.33f, 0.66f });

                        c = newCell("ID");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.getId())));
                        t.addCell(c);
                        c = newCell("Type");
                        t.addCell(c);
                        c = newCell(newStrongParagraph("Project"));
                        t.addCell(c);
                        c = newCell("Open");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount())));
                        t.addCell(c);
                        c = newCell("All");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.size())));
                        t.addCell(c);
                        c = newCell("Description");
                        t.addCell(c);
                        c = newDescriptionCell(f.getDescription());
                        t.addCell(c);

                        doc.add(t);
                    }

                    emptyH2 = true;
                    emptyH3 = false;

                } else {

                    if (emptyH3) {
                        p = newParagraph(NONE_DOT);
                        doc.add(p);
                    }

                    doc.add(newSubSection("Project:" + " " + f.getName()));

                    emptyH2 = false;
                    emptyH3 = true;
                }

                continue;

            }
            if (order == ExportAddOn.ExportOrder.FoldersActions
                    || order == ExportAddOn.ExportOrder.FoldersProjectsActions) {

                if (emptyH2 || emptyH3) {
                    p = newParagraph(NONE_DOT);
                    doc.add(p);
                }

                doc.add(newSection(f.getName()));

                if (compact) {
                    if (f.getDescription() != null && f.getDescription().length() > 0) {
                        p = newParagraph(f.getDescription());
                        p.setIndentationLeft(10f);
                        p.setIndentationRight(10f);
                        doc.add(p);
                    }
                } else {

                    t = new PdfPTable(2);
                    t.setKeepTogether(true);
                    t.setSpacingBefore(5f);
                    t.setWidthPercentage(66f);
                    t.setWidths(new float[] { 0.33f, 0.66f });

                    c = newCell("ID");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.getId())));
                    t.addCell(c);

                    String type = "";
                    if (f.isAction()) {
                        type = "Action list";
                    } else if (f.isInBucket()) {
                        type = "In-Bucket";
                    } else if (f.isQueue()) {
                        type = "Next action queue";
                    } else if (f.isReference()) {
                        type = "Reference list";
                    } else if (f.isSomeday()) {
                        type = "Someday/Maybe list";
                    } else if (f.isBuildIn()) {
                        type = "Default list";
                    }

                    c = newCell("Type");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(type));
                    t.addCell(c);
                    c = newCell("Open");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount())));
                    t.addCell(c);
                    c = newCell("All");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.size())));
                    t.addCell(c);
                    c = newCell("Description");
                    t.addCell(c);
                    c = newDescriptionCell(f.getDescription());
                    t.addCell(c);

                    doc.add(t);
                }

                emptyH2 = true;
                emptyH3 = false;

            } else {

                if (emptyH3) {
                    p = newParagraph(NONE_DOT);
                    doc.add(p);
                }

                doc.add(newSubSection("List:" + " " + f.getName()));

                emptyH2 = false;
                emptyH3 = true;

            }

            continue;

        }

        if (o instanceof Action) {
            emptyH2 = false;
            emptyH3 = false;

            Action a = (Action) o;

            if (compact) {

                if (actionTable == null) {
                    actionTable = new PdfPTable(5);
                    actionTable.setWidthPercentage(100f);
                    actionTable.setHeaderRows(1);
                    actionTable.setSpacingBefore(5f);
                    c = newHeaderCell("ID");
                    actionTable.addCell(c);
                    c = newHeaderCell("Pri.");
                    actionTable.addCell(c);
                    c = newHeaderCell("Description");
                    actionTable.addCell(c);
                    c = newHeaderCell("Reminder");
                    actionTable.addCell(c);
                    c = newHeaderCell(CHECK_RESOLVED);
                    actionTable.addCell(c);

                    float width = doc.getPageSize().getWidth() - doc.getPageSize().getBorderWidthLeft()
                            - doc.getPageSize().getBorderWidthRight();
                    int i = model.getLastActionID();
                    float step = baseFontSize - 1;
                    int steps = (int) Math.floor(Math.log10(i)) + 1;
                    // ID column
                    float col1 = 8 + steps * step;
                    // Priority column
                    float col2 = 4 + 3 * (baseFontSize + 4);
                    // Reminder column
                    float col4 = 10 + step * 11;
                    // Resolved column
                    float col5 = 8 + baseFontSize;
                    // Description column
                    float col3 = width - col1 - col2 - col4 - col5;
                    actionTable.setWidths(new float[] { col1, col2, col3, col4, col5 });

                }

                addSingleActionRow(a, actionTable);

            } else {
                addSingleActionTable(model, doc, a);
            }
        }

    }

    if (actionTable != null) {
        doc.add(actionTable);
        actionTable = null;
    }
    if (emptyH2 || emptyH3) {

        p = newParagraph(NONE_DOT);
        doc.add(p);
    }

    //w.writeCharacters("Exported: "+ApplicationHelper.toISODateTimeString(new Date()));

    doc.close();
}

From source file:org.gtdfree.addons.PDFExportAddOn.java

License:Open Source License

private PdfPCell newHeaderCell(String string) throws DocumentException, IOException {
    Paragraph p = new Paragraph(fontSelectorB.process(string));
    PdfPCell c = newCell(p);
    c.setHorizontalAlignment(Rectangle.ALIGN_CENTER);
    return c;/*w ww .  j  ava  2 s.co m*/
}

From source file:org.gtdfree.addons.PDFExportAddOn.java

License:Open Source License

/**
 * @param model/*w  w w  .  j a  v a  2s  .co m*/
 * @param doc
 * @param a
 * @throws DocumentException
 * @throws IOException
 * @throws BadElementException
 */
private void addSingleActionTable(GTDModel model, Document doc, Action a)
        throws DocumentException, IOException, BadElementException {
    Chunk ch;
    PdfPTable t;
    PdfPCell c;
    t = new PdfPTable(3);
    t.setSpacingBefore(5f);
    t.setWidthPercentage(100f);

    Paragraph ph = newParagraph();
    ch = newChunk(ID);
    ph.add(ch);
    ch = newChunk(String.valueOf(a.getId()));
    ch.getFont().setStyle(Font.BOLD);
    ph.add(ch);
    c = newCell(ph);
    t.addCell(c);

    ph = newParagraph();
    ch = newChunk(CREATED);
    ph.add(ch);
    ch = newChunk(ApplicationHelper.toISODateTimeString(a.getCreated()));
    ch.getFont().setStyle(Font.BOLD);
    ph.add(ch);
    c = newCell(ph);
    t.addCell(c);

    ph = newParagraph();
    if (a.isOpen()) {
        ch = newChunk(OPEN);
        ch.getFont().setStyle(Font.BOLD);
        ch.getFont().setColor(COLOR_OPEN);
        ph.add(ch);
        ch = newOpenChunk();
        ph.add(ch);
    } else if (a.isResolved()) {
        ch = newChunk(RESOLVED);
        ch.getFont().setStyle(Font.BOLD);
        ch.getFont().setColor(COLOR_RESOLVED);
        ph.add(ch);
        ch = newResolvedChunk();
        ph.add(ch);
    } else if (a.isDeleted()) {
        ch = newChunk(DELETED);
        ch.getFont().setStyle(Font.BOLD);
        ch.getFont().setColor(COLOR_DELETED);
        ph.add(ch);
        ch = newDeletedChunk();
        ph.add(ch);
    } else {
        ch = newChunk(STALLED);
        ch.getFont().setStyle(Font.BOLD);
        ch.getFont().setColor(COLOR_DELETED);
        ph.add(ch);
        ch = newStalledChunk();
        ph.add(ch);
    }
    c = newCell(ph);
    c.setHorizontalAlignment(Cell.ALIGN_RIGHT);
    t.addCell(c);

    ph = newParagraph();
    ch = newChunk(PRIORITY);
    ph.add(ch);
    ch = newChunk(a.getPriority() == null ? NONE : a.getPriority().toString());
    ch.getFont().setStyle(Font.BOLD);
    ph.add(ch);
    ch = newChunk(" ");
    ch.getFont().setStyle(Font.BOLD);
    ph.add(ch);

    if (a.getPriority() == null || a.getPriority() == Priority.None) {
        ch = newNoneStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
    } else if (a.getPriority() == Priority.Low) {
        ch = newLowStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
    } else if (a.getPriority() == Priority.Medium) {
        ch = newLowStarChunk();
        ph.add(ch);
        ch = newMediumStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
    } else if (a.getPriority() == Priority.High) {
        ch = newLowStarChunk();
        ph.add(ch);
        ch = newMediumStarChunk();
        ph.add(ch);
        ch = newHighStarChunk();
        ph.add(ch);
    }

    c = newCell(ph);
    t.addCell(c);

    ph = newParagraph();
    ch = newChunk(REMINDER);
    ph.add(ch);
    ch = newChunk(a.getRemind() != null ? ApplicationHelper.toISODateString(a.getRemind()) : NONE);
    ch.getFont().setStyle(Font.BOLD);
    ph.add(ch);
    c = newCell(ph);
    t.addCell(c);

    ph = newParagraph();
    ch = newChunk(PROJECT);
    ph.add(ch);
    if (a.getProject() != null) {
        ch = newChunk(model.getProject(a.getProject()).getName());
    } else {
        ch = newChunk(NONE);
    }
    ch.getFont().setStyle(Font.BOLD);
    ph.add(ch);
    c = newCell(ph);
    t.addCell(c);

    c = newDescriptionCell(a.getDescription());
    c.setColspan(3);
    t.addCell(c);

    if (a.getUrl() != null) {

        ch = newChunk(a.getUrl().toString());
        ch.setAnchor(a.getUrl());
        ch.getFont().setColor(Color.BLUE);

        c = newCell(new Paragraph(ch));
        c.setColspan(3);
        t.addCell(c);
    }

    doc.add(t);
}

From source file:org.gtdfree.addons.PDFExportAddOn.java

License:Open Source License

private void addSingleActionRow(Action a, PdfPTable t)
        throws DocumentException, IOException, BadElementException {

    Chunk ch;/*from  w  ww . j  a  va 2s.c  o  m*/
    PdfPCell c;

    // ID row
    Paragraph ph = newParagraph(String.valueOf(a.getId()));
    c = newCell(ph);
    c.setHorizontalAlignment(Cell.ALIGN_RIGHT);

    t.addCell(c);

    // Priority
    ph = newParagraph();
    if (a.getPriority() == null || a.getPriority() == Priority.None) {
        ch = newNoneStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
    } else if (a.getPriority() == Priority.Low) {
        ch = newLowStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
    } else if (a.getPriority() == Priority.Medium) {
        ch = newLowStarChunk();
        ph.add(ch);
        ch = newMediumStarChunk();
        ph.add(ch);
        ch = newNoneStarChunk();
        ph.add(ch);
    } else if (a.getPriority() == Priority.High) {
        ch = newLowStarChunk();
        ph.add(ch);
        ch = newMediumStarChunk();
        ph.add(ch);
        ch = newHighStarChunk();
        ph.add(ch);
    }
    c = newCell(ph);
    t.addCell(c);

    // description

    c = newDescriptionCell(a.getDescription());
    t.addCell(c);

    // reminder 

    ph = newParagraph(a.getRemind() != null ? ApplicationHelper.toDateString(a.getRemind()) : EMPTY);
    c = newCell(ph);
    c.setHorizontalAlignment(Cell.ALIGN_RIGHT);
    t.addCell(c);

    // status

    ph = newParagraph();
    if (a.isOpen()) {
        ch = newOpenChunk();
        ph.add(ch);
    } else if (a.isResolved()) {
        ch = newResolvedChunk();
        ph.add(ch);
    } else if (a.isDeleted()) {
        ch = newDeletedChunk();
        ph.add(ch);
    } else {
        ch = newStalledChunk();
        ph.add(ch);
    }
    c = newCell(ph);
    c.setHorizontalAlignment(Cell.ALIGN_RIGHT);
    t.addCell(c);

    /*if (a.getUrl()!=null) {
               
       ch= newChunk(a.getUrl().toString());
       ch.setAnchor(a.getUrl());
       ch.getFont().setColor(Color.BLUE);
               
       c= newCell(new Paragraph(ch));
       c.setColspan(3);
       t.addCell(c);
    }*/

}

From source file:org.kuali.kfs.gl.report.TransactionReport.java

License:Open Source License

/**
 * Appends the scrubber totals/statistics and error report to the given (iText) document object.
 * /* w  w w  .ja va2  s.c o m*/
 * @param document the PDF document
 * @param headerFont font for header
 * @param textFont font for report text
 * @param errorSortedList list of error'd transactions
 * @param reportErrors map containing transactions and the errors associated with each transaction
 * @param reportSummary list of summary objects
 * @param runDate date report was run
 * @throws DocumentException
 */
public void appendReport(Document document, Font headerFont, Font textFont, List<Transaction> errorSortedList,
        Map<Transaction, List<Message>> reportErrors, List<Summary> reportSummary, Date runDate)
        throws DocumentException {
    // Sort what we get
    Collections.sort(reportSummary);

    float[] summaryWidths = { 80, 20 };
    PdfPTable summary = new PdfPTable(summaryWidths);
    summary.setWidthPercentage(40);
    PdfPCell cell = new PdfPCell(new Phrase("S T A T I S T I C S", headerFont));
    cell.setColspan(2);
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    summary.addCell(cell);

    for (Iterator iter = reportSummary.iterator(); iter.hasNext();) {
        Summary s = (Summary) iter.next();

        cell = new PdfPCell(new Phrase(s.getDescription(), textFont));
        cell.setBorder(Rectangle.NO_BORDER);
        summary.addCell(cell);

        if ("".equals(s.getDescription())) {
            cell = new PdfPCell(new Phrase("", textFont));
            cell.setBorder(Rectangle.NO_BORDER);
            summary.addCell(cell);
        } else {
            DecimalFormat nf = new DecimalFormat("###,###,###,##0");
            cell = new PdfPCell(new Phrase(nf.format(s.getCount()), textFont));
            cell.setBorder(Rectangle.NO_BORDER);
            cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            summary.addCell(cell);
        }
    }
    cell = new PdfPCell(new Phrase(""));
    cell.setColspan(2);
    cell.setBorder(Rectangle.NO_BORDER);
    summary.addCell(cell);

    document.add(summary);

    if (reportErrors != null && reportErrors.size() > 0) {
        float[] warningWidths = { 4, 3, 6, 5, 5, 4, 5, 5, 4, 5, 5, 9, 4, 36 };
        PdfPTable warnings = new PdfPTable(warningWidths);
        warnings.setHeaderRows(2);
        warnings.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("W A R N I N G S", headerFont));
        cell.setColspan(14);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        warnings.addCell(cell);

        // Add headers
        cell = new PdfPCell(new Phrase("Year", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("COA", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Account", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Sacct", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Obj", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("SObj", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("BalTyp", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("ObjTyp", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Prd", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("DocType", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Origin", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("DocNbr", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Seq", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Warning", headerFont));
        warnings.addCell(cell);

        for (Iterator errorIter = errorSortedList.iterator(); errorIter.hasNext();) {
            Transaction tran = (Transaction) errorIter.next();
            boolean first = true;

            List errors = (List) reportErrors.get(tran);
            for (Iterator listIter = errors.iterator(); listIter.hasNext();) {
                String msg = null;
                Object m = listIter.next();
                if (m instanceof Message) {
                    Message mm = (Message) m;
                    msg = mm.getMessage();
                } else {
                    if (m == null) {
                        msg = "";
                    } else {
                        msg = m.toString();
                    }
                }

                if (first) {
                    first = false;

                    if (tran.getUniversityFiscalYear() == null) {
                        cell = new PdfPCell(new Phrase("NULL", textFont));
                    } else {
                        cell = new PdfPCell(new Phrase(tran.getUniversityFiscalYear().toString(), textFont));
                    }
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getChartOfAccountsCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getAccountNumber(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getSubAccountNumber(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialObjectCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialSubObjectCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialBalanceTypeCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialObjectTypeCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getUniversityFiscalPeriodCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialDocumentTypeCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialSystemOriginationCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getDocumentNumber(), textFont));
                    warnings.addCell(cell);
                    if (tran.getTransactionLedgerEntrySequenceNumber() == null) {
                        cell = new PdfPCell(new Phrase("NULL", textFont));
                    } else {
                        cell = new PdfPCell(new Phrase(
                                tran.getTransactionLedgerEntrySequenceNumber().toString(), textFont));
                    }
                    warnings.addCell(cell);
                } else {
                    cell = new PdfPCell(new Phrase("", textFont));
                    cell.setColspan(13);
                    warnings.addCell(cell);
                }
                cell = new PdfPCell(new Phrase(msg, textFont));
                warnings.addCell(cell);
            }
        }
        document.add(warnings);
    }
}

From source file:org.kuali.kfs.module.endow.report.util.EndowmentReportPrintBase.java

License:Educational Community License

/**
 * Creates a call with given font, alignments, and borderline
 * //  www.j  a  va 2  s. c o m
 * @param contents
 * @param font
 * @param horizontalAlignment
 * @param verticalAlignment
 * @param borderLine
 * @return
 */
public PdfPCell createCell(String contents, Font font, int horizontalAlignment, int verticalAlignment,
        boolean borderLine) {
    if (contents == null)
        contents = "";
    Phrase phr = new Phrase(contents, font);
    PdfPCell cell = new PdfPCell(phr);
    cell.setHorizontalAlignment(horizontalAlignment);
    if (!borderLine) {
        cell.setBorderWidth(0);
    }
    cell.setVerticalAlignment(verticalAlignment);
    return cell;
}

From source file:org.kuali.kfs.module.purap.pdf.BulkReceivingPdf.java

License:Open Source License

private void loadHeaderTable() throws Exception {

    float[] headerWidths = { 0.20f, 0.80f };

    headerTable = new PdfPTable(headerWidths);
    headerTable.setWidthPercentage(100);
    headerTable.setHorizontalAlignment(Element.ALIGN_CENTER);
    headerTable.setSplitLate(false);/*from  w  ww.j a va2 s . co m*/
    headerTable.getDefaultCell().setBorderWidth(0);
    headerTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    headerTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_CENTER);

    /**
     * Logo display
     */
    if (StringUtils.isNotBlank(logoImage)) {
        logo = Image.getInstance(logoImage);
        logo.scalePercent(3, 3);
        headerTable.addCell(new Phrase(new Chunk(logo, 0, 0)));
    } else {
        headerTable.addCell(new Phrase(new Chunk("")));
    }

    /**
     * Nested table in tableHeader to display title and doc number
     */
    float[] nestedHeaderWidths = { 0.70f, 0.30f };
    nestedHeaderTable = new PdfPTable(nestedHeaderWidths);
    nestedHeaderTable.setSplitLate(false);
    PdfPCell cell;

    /**
     * Title
     */
    cell = new PdfPCell(new Paragraph("RECEIVING TICKET", ver_15_normal));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorderWidth(0);
    nestedHeaderTable.addCell(cell);

    /**
     * Doc Number
     */
    Paragraph p = new Paragraph();
    p.add(new Chunk("Doc Number: ", ver_11_normal));
    p.add(new Chunk(blkRecDoc.getDocumentNumber().toString(), cour_10_normal));
    cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setBorderWidth(0);
    nestedHeaderTable.addCell(cell);

    // Add the nestedHeaderTable to the headerTable
    cell = new PdfPCell(nestedHeaderTable);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorderWidth(0);
    headerTable.addCell(cell);
}

From source file:org.kuali.kfs.module.purap.pdf.BulkReceivingPdf.java

License:Open Source License

private PdfPCell getPDFCell(String fieldTitle, String fieldValue) {

    Paragraph p = new Paragraph();
    p.add(new Chunk("  " + fieldTitle, ver_5_normal));

    if (StringUtils.isNotEmpty(fieldValue)) {
        p.add(new Chunk("     " + fieldValue, cour_10_normal));
    } else {/*w w w.  j av  a 2 s . c  o m*/
        p.add(new Chunk("  "));
    }

    PdfPCell cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);

    return cell;
}