Java 类com.lowagie.text.Cell 实例源码

项目:seg.jUCMNav    文件:PDFReportDiagram.java   
/**
 * creates the diagram figure header
 * 
 * @param document
 *            the document we are reporting into
 * @param string
 *            the string to show in the figure header
 */
public void createHeader1(Document document, String string) {
    try {

        Table headerTable = ReportUtils.createTable(2, 2, 0, 100);

        Chunk name = new Chunk(string, header1Font);
        Cell nameCell = new Cell(name);
        nameCell.setColspan(2);
        nameCell.setBorderWidthBottom(1.5f);

        headerTable.addCell(nameCell);
        document.add(headerTable);

    } catch (Exception e) {
        jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage());
        e.printStackTrace();

    }
}
项目:itext2    文件:RtfRow.java   
/**
 * Imports a Row and copies all settings
 * 
 * @param row The Row to import
 */
private void importRow(Row row) {
    this.cells = new ArrayList();
    this.width = this.document.getDocumentHeader().getPageSetting().getPageWidth() - this.document.getDocumentHeader().getPageSetting().getMarginLeft() - this.document.getDocumentHeader().getPageSetting().getMarginRight();
    this.width = (int) (this.width * this.parentTable.getTableWidthPercent() / 100);

    int cellRight = 0;
    int cellWidth = 0;
    for(int i = 0; i < row.getColumns(); i++) {
        cellWidth = (int) (this.width * this.parentTable.getProportionalWidths()[i] / 100);
        cellRight = cellRight + cellWidth;

        Cell cell = (Cell) row.getCell(i);
        RtfCell rtfCell = new RtfCell(this.document, this, cell);
        rtfCell.setCellRight(cellRight);
        rtfCell.setCellWidth(cellWidth);
        this.cells.add(rtfCell);
    }
}
项目:gomall.la    文件:SimpleChinesePdfView.java   
/**
 * Generates the header cells, which persist on every page of the PDF
 * document.
 * 
 * @throws BadElementException
 *             IText exception
 */
protected void generateHeaders() throws BadElementException {
    Iterator iterator = this.model.getHeaderCellList().iterator();

    while (iterator.hasNext()) {
        HeaderCell headerCell = (HeaderCell) iterator.next();

        String columnHeader = headerCell.getTitle();

        if (columnHeader == null) {
            columnHeader = StringUtils.capitalize(headerCell.getBeanPropertyName());
        }

        Cell hdrCell = getCell(columnHeader);
        hdrCell.setGrayFill(0.9f);
        hdrCell.setHeader(true);
        tablePDF.addCell(hdrCell);

    }
}
项目:gomall.la    文件:SimpleChinesePdfView.java   
/**
 * Generates all the row cells.
 * 
 * @throws JspException
 *             for errors during value retrieving from the table model
 * @throws BadElementException
 *             errors while generating content
 */
protected void generateRows() throws JspException, BadElementException {
    // get the correct iterator (full or partial list according to the
    // exportFull field)
    RowIterator rowIterator = this.model.getRowIterator(this.exportFull);
    // iterator on rows
    while (rowIterator.hasNext()) {
        Row row = rowIterator.next();

        // iterator on columns
        ColumnIterator columnIterator = row.getColumnIterator(this.model.getHeaderCellList());

        while (columnIterator.hasNext()) {
            Column column = columnIterator.nextColumn();

            // Get the value to be displayed for the column
            Object value = column.getValue(this.decorated);

            Cell cell = getCell(ObjectUtils.toString(value));
            tablePDF.addCell(cell);
        }
    }
}
项目:kfs    文件:Coversheet.java   
/**
 * Get the PDF Table containing trip information like trip id, date, and destination
 *
 * @returns {@link Table} used for a PDF
 */
protected Table getTripInfo() throws BadElementException {
    final Table retval = new Table(3);
    retval.setWidth(100f);
    retval.setBorder(NO_BORDER);
    retval.addCell(getHeaderCell("Trip/Event ID"));

    final Cell dateHeaderCell = getHeaderCell("Date");

    retval.addCell(dateHeaderCell);
    retval.addCell(getHeaderCell("Destination/Event Name"));
    retval.endHeaders();
    retval.addCell(getBorderlessCell(getTripId()));

    final Cell dateCell = getBorderlessCell(getDate());

    retval.addCell(dateCell);
    retval.addCell(getBorderlessCell(getDestination()));
    return retval;
}
项目:kfs    文件:Coversheet.java   
/**
 * Get the PDF Table with personal information about the initiator and traveler
 *
 * @returns {@link Table} used for a PDF
 */
protected Table getPersonalInfo() throws BadElementException {
    final Table retval = new Table(2);
    retval.setWidth(100f);
    retval.setBorder(NO_BORDER);
    retval.addCell(getHeaderCell("Traveler"));

    final Cell initiatorHeaderCell = getHeaderCell("Request Submitted By");

    retval.addCell(initiatorHeaderCell);
    retval.endHeaders();
    retval.addCell(getTravelerInfo());

    final Cell initiatorCell = getInitiatorInfo();

    retval.addCell(initiatorCell);
    return retval;
}
项目:netxilia    文件:SheetPdfProvider.java   
/**
 * Generates the header cells, which persist on every page of the PDF document.
 * 
 * @throws BadElementException
 *             IText exception
 * @throws NetxiliaBusinessException
 * @throws NetxiliaResourceException
 */
protected void generateHeaders(ISheet sheet, Table tablePDF, Font font, int columnCount)
        throws BadElementException, NetxiliaResourceException, NetxiliaBusinessException {

    Cell hdrCell = getCell("", font, Element.ALIGN_CENTER, 50);
    hdrCell.setGrayFill(0.9f);
    hdrCell.setHeader(true);
    tablePDF.addCell(hdrCell);

    List<ColumnData> columnData = sheet.receiveColumns(Range.ALL).getNonBlocking();

    for (int i = 0; i < columnCount; ++i) {
        ColumnData column = i < columnData.size() ? columnData.get(i) : null;
        hdrCell = getCell(CellReference.columnLabel(i), font, Element.ALIGN_CENTER, column != null ? column
                .getWidth() : 120);
        hdrCell.setGrayFill(0.9f);
        hdrCell.setHeader(true);
        tablePDF.addCell(hdrCell);

    }
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:ChangeHistoryReportService.java   
/**
 * Renders the contents of the report.
 *
 * @param response the report data
 * @param document the current report document
 * @throws DocumentException for any other errors encountered
 */
private void renderItems(ChangeHistoryReportResponse response, Document document) throws DocumentException {
    // generate header table
    Table table = new Table(3);
    table.setBorder(Table.TOP | Table.BOTTOM | Table.LEFT | Table.RIGHT);
    Cell cell = new Cell();
    cell.setBorder(Cell.LEFT);
    table.setDefaultCell(cell);
    table.setWidth(100);
    table.setPadding(1);

    table.addCell(new Phrase("CSD #" + response.getCsd(), ReportHelper.TABLE_HEADER_FONT));
    table.addCell(new Phrase(ReportHelper.formatDate(response.getBirthDay()), ReportHelper.TABLE_HEADER_FONT));
    table.addCell(new Phrase(response.getClaimName(), ReportHelper.TABLE_HEADER_FONT));
    document.add(table);

    Map<GroupingKey, List<ChangeHistoryReportResponseItem>> groups = groupItems(response);
    Set<GroupingKey> keySet = groups.keySet();
    for (GroupingKey groupingKey : keySet) {
        renderGroup(document, groupingKey, groups.get(groupingKey));
    }

    if (response.getItems().isEmpty()) {
        document.add(new Paragraph("There are no changes on record.", ReportHelper.TABLE_DATA_FONT));
    }
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:ChangeHistoryReportService.java   
/**
 * Renders all the records that are part of a group.
 *
 * @param document the current report
 * @param groupingKey the grouping key
 * @param list the items in the group
 * @throws DocumentException for any errors encountered
 */
private void renderGroup(Document document, GroupingKey groupingKey, List<ChangeHistoryReportResponseItem> list)
    throws DocumentException {
    Table table = new Table(1);
    table.setBorder(Table.NO_BORDER);
    Cell cell = new Cell();
    cell.setBorder(Cell.NO_BORDER);
    table.setDefaultCell(cell);
    table.setWidth(100);
    table.setPadding(1);

    // table header and column widths
    table.setWidths(new float[] {100});
    String groupLabel = "{0}                               {1}";
    String groupHeader = MessageFormat.format(groupLabel, groupingKey.date, groupingKey.user);
    Cell headerCell = new Cell(new Phrase(groupHeader, ReportHelper.TABLE_HEADER_FONT));
    headerCell.setBorder(Cell.BOTTOM);
    table.addCell(headerCell);
    for (ChangeHistoryReportResponseItem row : list) {
        table.addCell(new Phrase(row.getDescription(), ReportHelper.TABLE_DATA_FONT));
    }
    document.add(table);
    document.add(new Phrase(" ")); // spacer
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:MonthlyAdjustmentReportService.java   
/**
 * Renders the summary of adjustments.
 *
 * @param document the current document
 * @param userChangeCount the map representing the number of changes per user
 * @param userAccounts the map representing the number of accounts per user
 * @throws DocumentException for any errors encountered
 */
private void renderSummary(Document document, Map<String, Integer> userChangeCount,
    Map<String, Set<String>> userAccounts) throws DocumentException {
    Table table = new Table(1);
    table.setBorder(Table.TOP | Table.LEFT | Table.BOTTOM);
    Cell cell = new Cell();
    cell.setBorder(Cell.NO_BORDER);
    table.setDefaultCell(cell);
    table.setWidth(100);
    table.setPadding(1);
    // table header and column widths
    table.setWidths(new float[] {100});
    String groupLabel = "{0} made {1} changes to {2} accounts during this reporting period.";
    for (Map.Entry<String, Integer> user : userChangeCount.entrySet()) {
        Set<String> accountsModified = userAccounts.get(user.getKey());
        String userSummary = MessageFormat.format(groupLabel, user.getKey(), user.getValue(),
            accountsModified.size());
        table.addCell(new Phrase(userSummary, ReportHelper.TABLE_DATA_FONT));
    }
    document.add(table);
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:PaymentPendingApprovalReportService.java   
/**
 * Renders the grand total.
 * @param response the response object
 * @param document the document report
 * @throws DocumentException may be thrown by the iText library while rendering the elements
 */
private void renderGrandTotal(PaymentPendingApprovalReportResponse response, Document document)
    throws DocumentException {
    Table table = new Table(2);
    table.setWidths(new float[]{80, 20});
    table.setBorder(Table.NO_BORDER);
    table.setWidth(40);
    table.setPadding(1);
    Cell cell = new Cell(new Phrase("Grand Total", ReportHelper.TABLE_HEADER_FONT));
    cell.setBorder(Cell.BOTTOM);
    cell.setBorderWidth(1f);
    table.addCell(cell);
    Cell subTotal = new Cell(new Phrase(response.getItems().size() + "", ReportHelper.TABLE_HEADER_FONT));
    subTotal.setBorder(Cell.BOTTOM);
    subTotal.setBorderWidth(1f);
    table.addCell(subTotal);
    document.add(table);
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:PaymentPendingApprovalReportService.java   
/**
 * Render grouping.
 * @param response The response object
 * @param document The document report
 * @throws DocumentException may be thrown by the iText library while rendering the elements
 */
private void renderGrouping(PaymentPendingApprovalReportResponse response, Document document)
    throws DocumentException {
    Table table = new Table(2);
    table.setWidths(new float[]{80, 20});
    table.setBorder(Table.NO_BORDER);
    table.setWidth(40);
    table.setPadding(1);
    Cell cell = new Cell(new Phrase("Recievables Technician", ReportHelper.TABLE_HEADER_FONT));
    cell.setBorder(Cell.TOP | Cell.BOTTOM);
    table.addCell(cell);
    Cell subTotal = new Cell(new Phrase(response.getItems().size() + "", ReportHelper.TABLE_HEADER_FONT));
    subTotal.setBorder(Cell.TOP | Cell.BOTTOM);
    table.addCell(subTotal);
    document.add(table);
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:BalancedScorecardPaymentReportService.java   
/**
 * Adds a total row to the table.
 *
 * @param table
 *         the table.
 * @param contents
 *         the columns contents.
 * @param font
 *         the font to use.
 * @param borderTop
 *         the border top width.
 * @param borderBottom
 *         the border bottom width.
 */
private static void addTotalRow(Table table, Object[] contents, RtfFont font, int borderTop,
                                int borderBottom) {
    Cell labelCell = ReportServiceHelper.createTableCell(contents[0], font, null,
            ReportServiceHelper.RTF_ALIGN_RIGHT, null, 2);
    labelCell.setBorderWidthTop(borderTop);
    labelCell.setBorderWidthBottom(borderBottom);
    table.addCell(labelCell);

    Cell numberCell = ReportServiceHelper.createTableCell(contents[1], font, null,
            ReportServiceHelper.RTF_ALIGN_RIGHT, null, 1);
    numberCell.setBorderWidthTop(borderTop);
    numberCell.setBorderWidthBottom(borderBottom);
    table.addCell(numberCell);

    Cell totalCell = ReportServiceHelper.createTableCell(contents.length == 3 ? contents[2] : null, font, null,
            ReportServiceHelper.RTF_ALIGN_RIGHT, null, 1);
    totalCell.setBorderWidthTop(borderTop);
    totalCell.setBorderWidthBottom(borderBottom);
    table.addCell(totalCell);

    Cell emptyCell = ReportServiceHelper.createEmptyCell(1, null);
    emptyCell.setBorderWidthTop(borderTop);
    emptyCell.setBorderWidthBottom(borderBottom);
    table.addCell(emptyCell);
}
项目:seg.jUCMNav    文件:PDFReportDiagram.java   
/**
 * inserts the diagram figure legend
 * 
 * @param document
 *            the document we are reporting into
 * @param element
 *            the element illustrated by this diagram
 * @param figureNo
 *            the diagram number
 */
public void insertDiagramLegend(Document document, URNmodelElement element, int figureNo) {
    try {
        Table headerTable = ReportUtils.createTable(1, 1, 0, 100);

        Chunk name = new Chunk(Messages.getString("PDFReportDiagram.Figure") + figureNo + " - " + element.getName(), figureLegendFont); //$NON-NLS-1$ //$NON-NLS-2$
        Cell nameCell = new Cell(name);
        nameCell.setColspan(1);
        nameCell.setHorizontalAlignment(Element.ALIGN_CENTER);
        nameCell.setBorderWidthTop(2f);

        headerTable.addCell(nameCell);
        document.add(headerTable);

    } catch (Exception e) {
        jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage());
        e.printStackTrace();

    }
}
项目:seg.jUCMNav    文件:PDFReportDiagram.java   
/**
 * inserts the diagram figure description
 * 
 * @param document
 *            the document we are reporting into
 * @param element
 *            the element illustrated by this diagram
 */
public void insertDiagramDescription(Document document, URNmodelElement element) {
    try {

        Table table = ReportUtils.createTable(1, 2, 0, 100);

        Chunk chunk = new Chunk(Messages.getString("PDFReportDiagram.Description"), descriptionBoldFont); //$NON-NLS-1$
        Cell descriptionCell = new Cell(chunk);
        descriptionCell.setColspan(1);
        descriptionCell.setHorizontalAlignment(Element.ALIGN_LEFT);
        descriptionCell.setBorderWidthBottom(1.5f);

        Chunk descText = new Chunk(element.getDescription(), descriptionFont);

        table.addCell(descriptionCell);
        document.add(table);
        document.add(descText);

    } catch (Exception e) {
        jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage());
        e.printStackTrace();

    }
}
项目:seg.jUCMNav    文件:PDFReportDiagram.java   
protected void insertDiagramSectionHeader(Document document, int[] tableParams, String description) {
    try {

        Table table = ReportUtils.createTable(tableParams[0], tableParams[1], tableParams[2], tableParams[3]);

        Chunk chunk = new Chunk(description, descriptionBoldFont);
        Cell descriptionCell = new Cell(chunk);
        descriptionCell.setColspan(1);
        descriptionCell.setHorizontalAlignment(Element.ALIGN_LEFT);
        descriptionCell.setBorderWidthBottom(1.5f);

        table.addCell(descriptionCell);

        document.add(table);
    } catch (Exception e) {
        jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage());
        e.printStackTrace();

    }
}
项目:seg.jUCMNav    文件:ReportStrategies.java   
/**
 * creates the data dictionary section in the report
 * 
 * @param table
 *            the in which to insert the evaluations
 */

protected void writeEvaluation(Table table, int evalValue ) throws IOException {

    //evalValue = StrategyEvaluationPreferences.getValueToVisualize(evalValue);

    // if 0,100, convert back to -100,100 to have the right color. 
    int colorValue = StrategyEvaluationPreferences.getEquivalentValueInFullRangeIfApplicable( urnSpec,  evalValue );

    Cell evaluationCell = new Cell(evalValue + ""); //$NON-NLS-1$
    evaluationCell.setColspan(STRATEGY_CELL_WIDTH);
    if (colorValue == 0) {
        evaluationCell.setBackgroundColor(new java.awt.Color(255, 255, 151));
    } else if (colorValue == -100) {
        evaluationCell.setBackgroundColor(new java.awt.Color(252, 169, 171));
    } else if (colorValue > -100 && colorValue < 0) {
        evaluationCell.setBackgroundColor(new java.awt.Color(253, 233, 234));
    } else if (colorValue == 100) {
        evaluationCell.setBackgroundColor(new java.awt.Color(210, 249, 172));
    } else if (colorValue > 0 && colorValue < 100) {
        evaluationCell.setBackgroundColor(new java.awt.Color(240, 253, 227));
    }

    table.addCell(evaluationCell);
}
项目:seg.jUCMNav    文件:RTFReportDiagram.java   
/**
 * creates the diagram figure header
 * 
 * @param document
 *            the document we are reporting into
 * @param string
 *            the string to show in the figure header
 */
public void createHeader1(Document document, String string) {
    try {

        Table headerTable = ReportUtils.createTable(2, 2, 0, 100);

        Chunk name = new Chunk(string, header1Font);
        Cell nameCell = new Cell(name);
        nameCell.setColspan(2);
        nameCell.setBorderWidthBottom(1.5f);

        headerTable.addCell(nameCell);
        document.add(headerTable);

    } catch (Exception e) {
        jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage());
        e.printStackTrace();

    }
}
项目:seg.jUCMNav    文件:RTFReportDiagram.java   
/**
 * inserts the diagram figure legend
 * 
 * @param document
 *            the document we are reporting into
 * @param element
 *            the element illustrated by this diagram
 * @param i
 *            the diagram number
 */
public void insertDiagramLegend(Document document, URNmodelElement element, int i) {
    try {
        int figureNo = i + 1;
        Table headerTable = ReportUtils.createTable(1, 1, 0, 100);

        Chunk name = new Chunk(Messages.getString("RTFReportDiagram.Figure") + figureNo + " - " + element.getName(), figureLegendFont); //$NON-NLS-1$ //$NON-NLS-2$
        Cell nameCell = new Cell(name);
        nameCell.setColspan(1);
        nameCell.setHorizontalAlignment(Element.ALIGN_CENTER);
        nameCell.setBorderWidthTop(2f);

        headerTable.addCell(nameCell);
        document.add(headerTable);

    } catch (Exception e) {
        jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage());
        e.printStackTrace();

    }
}
项目:seg.jUCMNav    文件:RTFReportDiagram.java   
/**
 * inserts the diagram figure description
 * 
 * @param document
 *            the document we are reporting into
 * @param element
 *            the element illustrated by this diagram
 */
public void insertDiagramDescription(Document document, URNmodelElement element) {
    try {

        Table table = ReportUtils.createTable(1, 2, 0, 100);

        Chunk chunk = new Chunk(Messages.getString("RTFReportDiagram.Description"), descriptionBoldFont); //$NON-NLS-1$
        Cell descriptionCell = new Cell(chunk);
        descriptionCell.setColspan(1);
        descriptionCell.setHorizontalAlignment(Element.ALIGN_LEFT);
        descriptionCell.setBorderWidthBottom(1.5f);

        Chunk descText = new Chunk(element.getDescription(), descriptionFont);

        table.addCell(descriptionCell);
        document.add(table);
        document.add(descText);

    } catch (Exception e) {
        jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage());
        e.printStackTrace();

    }
}
项目:seg.jUCMNav    文件:ReportScenarios.java   
/**
    * this helper method writes the header of the UCM scenario documentation section
    * 
    * @param document
    *            the document we are reporting into
    * @param message
    *            the string to be displayed in the header
    * @param font
    *            the font we will use to display the header
    */
public void insertHeader(Document document, String message, Font font) {

    try {
        Table table = ReportUtils.createTable(tableParams[0], tableParams[1], tableParams[2], tableParams[3]);

        Chunk chunk = new Chunk(message, font);
        Cell descriptionCell = new Cell(chunk);
        descriptionCell.setColspan(1);
        descriptionCell.setHorizontalAlignment(Element.ALIGN_LEFT);
        descriptionCell.setBorderWidthBottom(1.5f);

        table.addCell(descriptionCell);

        document.add(table);
    } catch (Exception e) {
        jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage());
           e.printStackTrace();
    }
}
项目:itext2    文件:SAXiTextHandler.java   
protected void addImage(Image img) throws EmptyStackException {
    // if there is an element on the stack...
    Object current = stack.pop();
    // ...and it's a Chapter or a Section, the Image can be
    // added directly
    if (current instanceof Chapter
            || current instanceof Section
            || current instanceof Cell) {
        ((TextElementArray) current).add(img);
        stack.push(current);
        return;
    }
    // ...if not, we need to to a lot of stuff
    else {
        Stack newStack = new Stack();
        while (!(current instanceof Chapter
                || current instanceof Section || current instanceof Cell)) {
            newStack.push(current);
            if (current instanceof Anchor) {
                img.setAnnotation(new Annotation(0, 0, 0,
                        0, ((Anchor) current).getReference()));
            }
            current = stack.pop();
        }
        ((TextElementArray) current).add(img);
        stack.push(current);
        while (!newStack.empty()) {
            stack.push(newStack.pop());
        }
        return;
    }
}
项目:itext2    文件:ElementFactory.java   
/**
 * Creates a Cell object based on a list of properties.
 * @param attributes
 * @return a Cell
 */
public static Cell getCell(Properties attributes) {
    Cell cell = new Cell();
    String value;

    cell.setHorizontalAlignment(attributes
            .getProperty(ElementTags.HORIZONTALALIGN));
    cell.setVerticalAlignment(attributes
            .getProperty(ElementTags.VERTICALALIGN));

    value = attributes.getProperty(ElementTags.WIDTH);
    if (value != null) {
        cell.setWidth(value);
    }
    value = attributes.getProperty(ElementTags.COLSPAN);
    if (value != null) {
        cell.setColspan(Integer.parseInt(value));
    }
    value = attributes.getProperty(ElementTags.ROWSPAN);
    if (value != null) {
        cell.setRowspan(Integer.parseInt(value));
    }
    value = attributes.getProperty(ElementTags.LEADING);
    if (value != null) {
        cell.setLeading(Float.parseFloat(value + "f"));
    }
    cell.setHeader(Utilities.checkTrueOrFalse(attributes,
            ElementTags.HEADER));
    if (Utilities.checkTrueOrFalse(attributes, ElementTags.NOWRAP)) {
        cell.setMaxLines(1);
    }
    setRectangleProperties(cell, attributes);
    return cell;
}
项目:itext2    文件:TableWithImageTest.java   
/**
 * A very simple PdfPTable example.
 * 
 */
@Test
public void main() throws Exception {
    // step 1: creation of a document-object
    Document document = new Document();
    // step 2:
    // we create a writer that listens to the document
    // and directs a PDF-stream to a file
    PdfWriter.getInstance(document, PdfTestBase.getOutputStream("imageTable.pdf"));
    // step 3: we open the document
    document.open();
    // step 4: we create a table and add it to the document
    Table table = new Table(2, 2); // 2 rows, 2 columns
    table.addCell(new Cell(Image.getInstance(PdfTestBase.RESOURCES_DIR + "otsoe.jpg")));
    table.addCell(new Cell(Image.getInstance(PdfTestBase.RESOURCES_DIR + "iText.gif")));
    Cell c1 = new Cell();
    c1.add(Image.getInstance(PdfTestBase.RESOURCES_DIR + "iText.gif"));
    table.addCell(c1);
    Cell c2 = new Cell();
    c2.add(Image.getInstance(PdfTestBase.RESOURCES_DIR + "otsoe.jpg"));
    table.addCell(c2);
    document.add(table);
    document.add(new Paragraph("converted to PdfPTable:"));
    table.setConvert2pdfptable(true);
    document.add(table);

    // step 5: we close the document
    document.close();
}
项目:itext2    文件:ExtendedHeaderFooterTest.java   
/**
 * Extended headers / footers example
 * 
 * 
 */
@Test
public void main() throws Exception {
    Document document = new Document();
    RtfWriter2.getInstance(document, PdfTestBase.getOutputStream("ExtendedHeaderFooter.rtf"));

    // Create the Paragraphs that will be used in the header.
    Paragraph date = new Paragraph("01.01.2010");
    date.setAlignment(Paragraph.ALIGN_RIGHT);
    Paragraph address = new Paragraph("TheFirm\nTheRoad 24, TheCity\n" + "+00 99 11 22 33 44");

    // Create the RtfHeaderFooter with an array containing the Paragraphs to
    // add
    RtfHeaderFooter header = new RtfHeaderFooter(new Element[] { date, address });

    // Set the header
    document.setHeader(header);

    // Create the table that will be used as the footer
    Table footer = new Table(2);
    footer.setBorder(0);
    footer.getDefaultCell().setBorder(0);
    footer.setWidth(100);
    footer.addCell(new Cell("(c) Mark Hall"));
    Paragraph pageNumber = new Paragraph("Page ");

    // The RtfPageNumber is an RTF specific element that adds a page number
    // field
    pageNumber.add(new RtfPageNumber());
    pageNumber.setAlignment(Paragraph.ALIGN_RIGHT);
    footer.addCell(new Cell(pageNumber));

    // Create the RtfHeaderFooter and set it as the footer to use
    document.setFooter(new RtfHeaderFooter(footer));

    document.open();

    document.add(new Paragraph("This document has headers and footers created"
            + " using the RtfHeaderFooter class."));

    document.close();

}
项目:communote-server    文件:RtfNoteWriter.java   
/**
 * This message creates the footer element for the exported document.
 *
 * @param queryInstance
 *            The query instance to extract needed data from.
 * @param user
 *            The user.
 * @param resourcesManager
 *            The resources manager to retreive resources from.
 * @return An object to be used as a header.
 * @throws MalformedURLException
 *             {@link MalformedURLException}.
 * @throws BadElementException
 *             {@link BadElementException}.
 */
private Element getFooter(NoteQueryParameters queryInstance, User user,
        ResourceBundleManager resourcesManager) throws MalformedURLException,
        BadElementException {
    Table table = new Table(2);
    table.setWidths(new float[] { 60, 40 });
    table.setWidth(100);
    table.setPadding(5);
    table.setBorder(Table.TOP);
    Cell serviceCell = new Cell();
    serviceCell.setBorder(Cell.TOP);
    serviceCell.add(RtfElementFactory.createChunk(
            resourcesManager.getText("export.post.footer.service", user.getLanguageLocale())
            + " ", null));
    serviceCell.add(RtfElementFactory.createChunk(resourcesManager.getText(
            "export.post.footer.service.provider", user.getLanguageLocale())));
    Cell pageNumberCell = new Cell();
    pageNumberCell.setHorizontalAlignment(Cell.ALIGN_RIGHT);
    pageNumberCell.setBorder(Cell.TOP);
    pageNumberCell.add(RtfElementFactory.createChunk(resourcesManager.getText(
            "export.post.footer.page", user.getLanguageLocale()) + " "));
    pageNumberCell.add(new RtfPageNumber());
    pageNumberCell
    .add(RtfElementFactory.createChunk(" "
            + resourcesManager.getText("export.post.footer.of",
                    user.getLanguageLocale()) + " "));
    pageNumberCell.add(new RtfTotalPageNumber());

    table.addCell(serviceCell);
    table.addCell(pageNumberCell);
    return table;
}
项目:communote-server    文件:RtfNoteWriter.java   
/**
 * This method creates the information cell.
 *
 * @param post
 *            VO holding all information about the note to process ======= The note.
 * @param dateFormatter
 *            Date formatter.
 * @param resourcesManager
 *            the resource bundle manager to use for localization
 * @param locale
 *            The locale to use.
 * @return The information cell as {@link Cell}.
 */
private Cell getInfoCell(NoteData post, Locale locale, DateFormat dateFormatter,
        ResourceBundleManager resourcesManager) {
    Paragraph paragraph = new Paragraph();
    paragraph.setLeading(10);
    paragraph.setFont(FONT_META_INFORMATION);
    paragraph.add(RtfElementFactory.createChunk("\n", FONT_META_INFORMATION));
    paragraph
    .add(RtfElementFactory.createChunk(
            resourcesManager.getText("export.post.title.author", locale),
            FONT_META_INFORMATION));
    paragraph.add(RtfElementFactory.createChunk(":\t" + post.getUser().getFirstName() + " "
            + post.getUser().getLastName() + " (" + post.getUser().getAlias() + ")",
            FONT_META_INFORMATION));
    handleUsersToBeNotified(post.getNotifiedUsers(), paragraph, locale, resourcesManager);
    paragraph.add(RtfElementFactory.createChunk("\n", FONT_META_INFORMATION));
    paragraph.add(RtfElementFactory.createChunk(
            resourcesManager.getText("export.post.title.blog", locale), FONT_META_INFORMATION));
    paragraph.add(RtfElementFactory.createChunk(":\t" + post.getBlog().getTitle(),
            FONT_META_INFORMATION));
    handleTags(post.getTags(), locale, resourcesManager, paragraph);
    handleParentNote(post, locale, dateFormatter, resourcesManager, paragraph);
    handleModificationDate(post, locale, dateFormatter, resourcesManager, paragraph);
    Cell infoCell = new Cell();
    infoCell.setBorder(Cell.BOTTOM | Cell.RIGHT);
    infoCell.add(paragraph);
    return infoCell;
}
项目:sakai    文件:SpreadsheetDataFileWriterPdf.java   
private Cell getHeaderCell(String headerTxt) throws BadElementException{
    //set header cells:                             
    Cell c = new Cell(new Chunk(headerTxt, getBoldFont()));
    c.setHeader(true);
    c.setBackgroundColor(Color.LIGHT_GRAY);

    return c;
}
项目:kfs    文件:Coversheet.java   
/**
 * Information about the person that initiated the {@link TravelReimbursementDocument}
 */
protected Cell getInitiatorInfo() throws BadElementException {
    final StringBuilder strBuilder = new StringBuilder();
    strBuilder.append(getInitiatorName()).append("\n")
        .append(getInitiatorPrincipalName()).append("\n")
        .append(getInitiatorPhone()).append("\n")
        .append(getInitiatorEmail()).append("\n");
    final Cell retval = getBorderlessCell(strBuilder.toString());
    return retval;
}
项目:kfs    文件:Coversheet.java   
/**
 * Information about the traveler described in the trip for the {@link TravelReimbursementDocument}
 *
 */
protected Cell getTravelerInfo() throws BadElementException {
    final StringBuilder strBuilder = new StringBuilder();
    strBuilder.append(getTravelerName()).append("\n")
        .append(getTravelerPrincipalName()).append("\n")
        .append(getTravelerPhone()).append("\n")
        .append(getTravelerEmail()).append("\n");
    final Cell retval = getBorderlessCell(strBuilder.toString());
    return retval;
}
项目:kfs    文件:Coversheet.java   
/**
 * Helper method to create a Header Cell from text
 *
 * @returns {@link Cell} with the header flag set
 */
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;
}
项目:kfs    文件:Coversheet.java   
/**
 * Helper method to create a Header Cell from text
 *
 * @returns {@link Cell} with the header flag set
 */
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;
}
项目:sakai    文件:SpreadsheetDataFileWriterPdf.java   
private Cell getHeaderCell(String headerTxt) throws BadElementException{
    //set header cells:                             
    Cell c = new Cell(new Chunk(headerTxt, getBoldFont()));
    c.setHeader(true);
    c.setBackgroundColor(Color.LIGHT_GRAY);

    return c;
}
项目:netxilia    文件:SheetPdfProvider.java   
/**
 * Generates all the row cells.
 * 
 * @throws JspException
 *             for errors during value retrieving from the table model
 * @throws BadElementException
 *             errors while generating content
 * @throws NetxiliaBusinessException
 * @throws NetxiliaResourceException
 */
protected void generateRows(ISheet sheet, boolean summarySheet, Table tablePDF, Font font, int columnCount)
        throws JspException, BadElementException, NetxiliaResourceException, NetxiliaBusinessException {
    Styles rightAlign = Styles.styles("a-r");
    List<RowData> rowData = sheet.receiveRows(Range.ALL).getNonBlocking();
    List<ColumnData> columnData = sheet.receiveColumns(Range.ALL).getNonBlocking();

    Matrix<CellData> cellData = sheet.receiveCells(AreaReference.ALL).getNonBlocking();
    for (RowData row : rowData) {
        String rowHdr = "";
        if (summarySheet) {
            rowHdr += "S";
        }
        rowHdr += Integer.toString(row.getIndex() + 1);
        Cell rowHdrCell = getCell(rowHdr, font, Element.ALIGN_LEFT, -1);
        rowHdrCell.setGrayFill(0.9f);
        tablePDF.addCell(rowHdrCell);

        int c = 0;

        for (CellData cell : cellData.getRow(row.getIndex())) {
            RichValue formattedValue = styleService.formatCell(sheet.getWorkbook().getId(), cell, rowData.get(cell
                    .getReference().getRowIndex()), columnData.get(cell.getReference().getColumnIndex()));
            // TODO check for aligns
            int horizAlign = Element.ALIGN_LEFT;
            if (formattedValue.getStyles() != null && formattedValue.getStyles().contains(rightAlign)) {
                horizAlign = Element.ALIGN_RIGHT;
            }
            Cell pdfCell = getCell(formattedValue.getDisplay(), font, horizAlign, -1);
            tablePDF.addCell(pdfCell);
            c++;
        }
        for (; c < columnCount; ++c) {
            tablePDF.addCell(getCell("", font, Element.ALIGN_LEFT, -1));
        }
    }
}
项目:netxilia    文件:SheetPdfProvider.java   
/**
 * Returns a formatted cell for the given value.
 * 
 * @param value
 *            cell value
 * @return Cell
 * @throws BadElementException
 *             errors while generating content
 */
private Cell getCell(String value, Font font, int horizAlign, int width) throws BadElementException {
    Cell cell = new Cell(new Chunk(StringUtils.trimToEmpty(value), font));
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(horizAlign);
    cell.setLeading(8);
    if (width > 0) {
        cell.setWidth(width);
    }
    return cell;
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:ManualPaymentReportService.java   
/**
 * Renders the summary table.
 * @param grandTotal the report total
 * @param response the report model
 * @param document the current document
 * @throws DocumentException may be thrown by the iText library while rendering the elements
 */
private void renderSummaryTable(ManualPaymentReportResponse response, Document document, BigDecimal grandTotal)
    throws DocumentException {
    // render grand total
    // table styling
    Table table = new Table(7);
    table.setBorder(Table.NO_BORDER);
    Cell cell = new Cell();
    cell.setBorder(Cell.NO_BORDER);
    table.setDefaultCell(cell);
    table.setWidth(100);
    table.setPadding(1);

    // table header and column widths
    table.setWidths(new float[] {17, 10, 10, 10, 12, 17, 24});
    // label for the total
    Cell summaryCell = new Cell(new Phrase("Grand Total:", ReportHelper.TABLE_HEADER_FONT));
    summaryCell.setColspan(3);
    summaryCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(summaryCell);

    // group total value
    Cell subTotalCell = ReportHelper.moneyCell(ReportHelper.formatMoney(grandTotal),
        ReportHelper.TABLE_HEADER_FONT);
    table.addCell(subTotalCell);

    // complete the table with empty cells
    Cell spacerCell = new Cell(new Phrase("in " + response.getItems().size() + " Payment(s)",
        ReportHelper.TABLE_HEADER_FONT));
    spacerCell.setColspan(3);
    table.addCell(spacerCell);

    document.add(table);
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:MonthlyAdjustmentReportService.java   
/**
 * Renders all the records that are part of a group.
 *
 * @param document the current report
 * @param groupingKey the grouping key
 * @param items the items in the group
 * @throws DocumentException for any errors encountered
 */
private void renderGroup(Document document, GroupingKey groupingKey,
    List<MonthlyAdjustmentReportResponseItem> items) throws DocumentException {

    Table table = new Table(2);
    table.setBorder(Table.NO_BORDER);
    Cell cell = new Cell();
    cell.setBorder(Cell.NO_BORDER);
    table.setDefaultCell(cell);
    table.setWidth(100);
    table.setPadding(1);

    // table header and column widths
    table.setWidths(new float[] {10, 90});

    String groupLabel = "{0}  {1} changed account #{2}";
    String groupHeader = MessageFormat.format(groupLabel, groupingKey.date, groupingKey.user,
        groupingKey.claimNumber);
    Cell headerCell = new Cell(new Phrase(groupHeader, ReportHelper.TABLE_HEADER_FONT));
    headerCell.setColspan(2);
    headerCell.setBorder(Cell.BOTTOM);
    table.addCell(headerCell);
    for (MonthlyAdjustmentReportResponseItem row : items) {
        table.addCell(new Phrase(ReportHelper.formatDate(row.getDate(), "hh:mm a"), ReportHelper.TABLE_DATA_FONT));
        table.addCell(new Phrase(row.getDescription(), ReportHelper.TABLE_DATA_FONT));
    }
    document.add(table);
    document.add(new Phrase(" ")); // spacer
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:ReportServiceHelper.java   
/**
 * Creates a cell for RTF table.
 *
 * @param content
 *         the content.
 * @param font
 *         the font to use.
 * @param backgroundColor
 *         the background color.
 * @param alignment
 *         the alignment to use.
 * @param border
 *         the border.
 * @param colSpan
 *         how many columns the cell will span.
 * @return the created cell.
 */
static Cell createTableCell(Object content, RtfFont font,
                            Color backgroundColor, Integer alignment, Integer border,
                            int colSpan) {
    Cell cell = new Cell();
    if (border != null) {
        cell.setBorder(border);
    }
    if (backgroundColor != null) {
        cell.setBackgroundColor(backgroundColor);
    }
    if (content != null) {
        if (alignment != null) {
            cell.setHorizontalAlignment(alignment);
        }
        cell.setColspan(colSpan);
        String value;
        if (content instanceof BigDecimal) {
            value = Helper.getMoney((BigDecimal) content);
        } else if (content instanceof Number) {
            value = NumberFormat.getIntegerInstance(Locale.ENGLISH).format(content);
        } else {
            value = content.toString();
        }
        cell.add(new com.lowagie.text.Paragraph(value, font));
    }
    return cell;
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:AccountTypeTotalsReportService.java   
/**
 * Adds the footer style row for the field to the RTF table.
 *
 * @param table
 *         the table.
 * @param font
 *         the font to use.
 * @param name
 *         the field name.
 * @param value
 *         the field value.
 */
private static void addFooter(Table table, RtfFont font, String name,
                              Integer value) {
    Cell emptyCell = new Cell();
    emptyCell.setBorder(ReportServiceHelper.RTF_NO_BORDER);
    table.addCell(emptyCell);

    Cell footerNameCell = new Cell();
    footerNameCell.setBorderColorTop(Color.BLACK);
    footerNameCell.setBorderWidthTop(1);
    footerNameCell
            .setHorizontalAlignment(ReportServiceHelper.RTF_ALIGN_LEFT);
    footerNameCell.add(new com.lowagie.text.Phrase(name, font));
    footerNameCell.setBorder(ReportServiceHelper.RTF_BORDER_TOP);
    table.addCell(footerNameCell);

    Cell footerValueCell = new Cell();
    footerValueCell.setBorderColorTop(Color.BLACK);
    footerValueCell.setBorderWidthTop(1);
    if (value != null) {
        footerValueCell
                .setHorizontalAlignment(ReportServiceHelper.RTF_ALIGN_RIGHT);
        footerValueCell.add(new com.lowagie.text.Phrase(value.toString(),
                font));
    }
    footerValueCell.setBorder(ReportServiceHelper.RTF_BORDER_TOP);
    table.addCell(footerValueCell);
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:LockboxFileImportReportService.java   
/**
 * Adds the group borders to the given cell.
 *
 * @param cell the cell to add borders to
 * @param firstRow flag indicating this is the first in the group
 * @param lastRow flag indicating this is the last in the group
 * @return the decorated cell
 */
private Cell addBorders(Cell cell, boolean firstRow, boolean lastRow) {
    if (firstRow) {
        cell.setBorder(Cell.TOP);
    }
    if (lastRow) {
        cell.setBorder(Cell.BOTTOM);
    }
    if (lastRow && firstRow) {
        cell.setBorder(Cell.BOTTOM | Cell.TOP);
    }
    return cell;
}