Java 类com.lowagie.text.pdf.PdfPCell 实例源码

项目:sistra    文件:Lista.java   
public void write(PDFDocument document, PdfPTable tabla) throws DocumentException {
    com.lowagie.text.List list = new com.lowagie.text.List(false,10f);
    list.setListSymbol(new Chunk("\u2022"));

    PdfPCell cell = new PdfPCell();

    if(!titulo.equals(""))
    {
       cell.addElement(new Phrase(titulo,document.getContext().getDefaultFont()));
    }

    for(int i=0; i<campos.size(); i++)
    {
        list.add(new ListItem((String)campos.get(i),document.getContext().getDefaultFont()));
    }

    cell.addElement(list);
    cell.setPaddingLeft(30f);
    cell.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
    cell.setColspan(2);
    tabla.addCell(cell);

}
项目:AgileAlligators    文件:DefaultPdfDataEntryFormService.java   
private void insertTable_TextRow( PdfWriter writer, PdfPTable mainTable, String text, Font font )
{
    boolean hasBorder = false;

    // Add Organization ID/Period textfield
    // Create A table to add for each group AT HERE
    PdfPTable table = new PdfPTable( 1 );
    table.setHorizontalAlignment( Element.ALIGN_LEFT );

    addCell_Text( table, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), text, Element.ALIGN_LEFT, font );

    // Add to the main table
    PdfPCell cell_withInnerTable = new PdfPCell( table );

    cell_withInnerTable.setBorder( Rectangle.NO_BORDER );

    mainTable.addCell( cell_withInnerTable );
}
项目:unitimes    文件:PdfClassListTableBuilder.java   
protected PdfPCell pdfBuildPrefGroupLabel(CourseOffering co, PreferenceGroup prefGroup, String indentSpaces, boolean isEditable, String prevLabel) {
    if (prefGroup instanceof Class_) {
        Color color = (isEditable?Color.BLACK:Color.GRAY);
        String label = prefGroup.toString();
        Class_ aClass = (Class_) prefGroup;
        label = aClass.getClassLabel(co);
        if (prevLabel != null && label.equals(prevLabel)){
            label = "";
        }
        PdfPCell cell = createCell();
        addText(cell, indentSpaces+label, co.isIsControl(), false, Element.ALIGN_LEFT, color, true);
     InstructionalMethod im = aClass.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalMethod();
        if (im != null)
        addText(cell, " (" + im.getReference() + ")", false, false, Element.ALIGN_LEFT, color, false);
        return cell;
    } else return super.pdfBuildPrefGroupLabel(co, prefGroup, indentSpaces, isEditable, null);
}
项目:unitimes    文件:PdfClassListTableBuilder.java   
@Override
protected PdfPCell pdfBuildNote(PreferenceGroup prefGroup, boolean isEditable, UserContext user){
    Color color = (isEditable?sEnableColor:sDisableColor);
    PdfPCell cell = createCell();

    if (prefGroup instanceof Class_) {
        Class_ c = (Class_) prefGroup;
        String offeringNote = c.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalOffering().getNotes();
        String classNote = c.getNotes();
        String note = (offeringNote == null || offeringNote.isEmpty() ? classNote : offeringNote + (classNote == null || classNote.isEmpty() ? "" : "\n" + classNote));
        if (note != null && !note.isEmpty()) {
            if (note.length() <= 30  || user == null || CommonValues.NoteAsFullText.eq(user.getProperty(UserProperty.ManagerNoteDisplay))){
                addText(cell, note, false, false, Element.ALIGN_LEFT, color, true);
            } else {
                if (classNote != null && !classNote.isEmpty()) note = classNote;
                addText(cell, (note.length() <= 30 ? note : note.substring(0, 30) + "..."), false, false, Element.ALIGN_LEFT, color, true);
            }
        }
    }

    return cell;
}
项目:unitimes    文件:PdfClassAssignmentReportListTableBuilder.java   
@Override
protected PdfPCell pdfBuildDatePatternCell(ClassAssignmentProxy classAssignment, PreferenceGroup prefGroup, boolean isEditable){
    Assignment a = null;
    if (getDisplayTimetable() && isShowTimetable() && classAssignment!=null && prefGroup instanceof Class_) {
        try {
            a = classAssignment.getAssignment((Class_)prefGroup);
        } catch (Exception e) {
            Debug.error(e);
        }
    }
    DatePattern dp = (a != null ? a.getDatePattern() : prefGroup.effectiveDatePattern());
    PdfPCell cell = createCell();
    if (dp!=null) {
        Color color = (isEditable?sEnableColor:sDisableColor);
        addText(cell,dp.getName(), false, false, Element.ALIGN_CENTER, color, true);
    }
       return cell;
   }
项目:unitimes    文件:PdfClassAssignmentReportListTableBuilder.java   
@Override
protected PdfPCell pdfBuildInstructor(PreferenceGroup prefGroup, boolean isEditable){
    Color color = (isEditable?sEnableColor:sDisableColor);
    PdfPCell cell = createCell();

    if (prefGroup instanceof Class_) {
        Class_ aClass = (Class_) prefGroup;
        if (aClass.isDisplayInstructor()) {
            TreeSet sortedInstructors = new TreeSet(new InstructorComparator());
            sortedInstructors.addAll(aClass.getClassInstructors());
            for (Iterator i=sortedInstructors.iterator(); i.hasNext();) {
                ClassInstructor ci = (ClassInstructor)i.next();
                String label = ci.getInstructor().getName(getInstructorNameFormat());
                addText(cell, label, false, false, Element.ALIGN_LEFT, color, true);
            }
        }
    }

    return cell;
}
项目:unitimes    文件:PdfInstructionalOfferingTableBuilder.java   
private PdfPCell pdfSubjectAndCourseInfo(InstructionalOffering io, CourseOffering co) {
    PdfPCell cell = createCell();
     addText(cell, (co != null ? co.getSubjectAreaAbbv()+" "+co.getCourseNbr():""), true, false, Element.ALIGN_LEFT, (co.isIsControl().booleanValue()?sEnableColor:sDisableColor), true);
    InstructionalMethod im = (co != null && co.getInstructionalOffering().getInstrOfferingConfigs().size() == 1 ? co.getInstructionalOffering().getInstrOfferingConfigs().iterator().next().getInstructionalMethod() : null);
    if (im != null) {
        if (co.getCourseType() != null) {
            addText(cell, " (" + co.getCourseType().getReference() + ", " + im.getReference() + ")", false, false, Element.ALIGN_LEFT, (co.isIsControl().booleanValue()?sEnableColor:sDisableColor), false);
        } else {
            addText(cell, " (" + im.getReference() + ")", false, false, Element.ALIGN_LEFT, (co.isIsControl().booleanValue()?sEnableColor:sDisableColor), false);
        }
    } else if (co.getCourseType() != null) {
addText(cell, " (" + co.getCourseType().getReference() + ")", false, false, Element.ALIGN_LEFT, (co.isIsControl().booleanValue()?sEnableColor:sDisableColor), false);
    }
     for (Iterator it = io.courseOfferingsMinusSortCourseOfferingForSubjectArea(co.getSubjectArea().getUniqueId()).iterator(); it.hasNext(); ) {
        CourseOffering tempCo = (org.unitime.timetable.model.CourseOffering) it.next();
         addText(cell,  indent+""+tempCo.getSubjectAreaAbbv()+" "+tempCo.getCourseNbr() + " " + (tempCo.getCourseType() != null ? " (" + tempCo.getCourseType().getReference() + ")" : ""), false, false, Element.ALIGN_LEFT, sDisableColor, true);
     }
     return cell;
 }
项目:unitimes    文件:PdfInstructionalOfferingTableBuilder.java   
private PdfPCell pdfBuildTimePatternCell(PreferenceGroup prefGroup, boolean isEditable){
    Color color = (isEditable?sEnableColor:sDisableColor);
    PdfPCell cell = createCell();
    for (Iterator i=prefGroup.effectiveTimePatterns().iterator(); i.hasNext();) {
        TimePattern tp = (TimePattern)i.next();
        addText(cell, tp.getName(), false, false, Element.ALIGN_CENTER, color, true);  
    }
    if (prefGroup instanceof Class_ && prefGroup.effectiveTimePatterns().isEmpty()) {
        Class_ clazz = (Class_)prefGroup;
        DurationModel dm = clazz.getSchedulingSubpart().getInstrOfferingConfig().getDurationModel();
        Integer ah = dm.getArrangedHours(clazz.getSchedulingSubpart().getMinutesPerWk(), clazz.effectiveDatePattern());
        if (ah == null) {
            addText(cell, "Arr Hrs", false, false, Element.ALIGN_CENTER, color, true);
        } else {
            addText(cell, "Arr "+ah+" Hrs", false, false, Element.ALIGN_CENTER, color, true);
        }
    }
    return cell;
}
项目:unitimes    文件:PdfInstructionalOfferingTableBuilder.java   
private PdfPCell pdfBuildPrefGroupDemand(PreferenceGroup prefGroup, boolean isEditable){
    if (prefGroup instanceof Class_) {
    Class_ c = (Class_) prefGroup;
    if (StudentClassEnrollment.sessionHasEnrollments(c.getSessionId())){
        PdfPCell tc = createCell();
        if (c.getEnrollment() != null){
            addText(tc, c.getEnrollment().toString());
        } else {
            addText(tc, "0");
        }
        tc.setHorizontalAlignment(Element.ALIGN_RIGHT);
        return(tc);
    }
}
    return createCell();
  }
项目:unitimes    文件:PdfInstructionalOfferingTableBuilder.java   
private PdfPCell pdfBuildSnapshotLimit(PreferenceGroup prefGroup, boolean isEditable){
    Color color = (isEditable?sEnableColor:sDisableColor);

    PdfPCell cell = createCell();

    if (prefGroup instanceof Class_){
        Class_ aClass = (Class_) prefGroup;
    boolean unlimited = aClass.getSchedulingSubpart().getInstrOfferingConfig().isUnlimitedEnrollment().booleanValue();
    if (!unlimited) {
        String limitString = null;

            if (aClass.getSnapshotLimit() == null) {
                    limitString = "";
            } else {
                limitString = aClass.getSnapshotLimit().toString();
            }
        addText(cell, limitString, false, false, Element.ALIGN_RIGHT, color, true);
    }
    } 

    return cell;
}
项目:unitimes    文件:PdfInstructionalOfferingTableBuilder.java   
protected PdfPCell pdfBuildInstructorAssignment(PreferenceGroup prefGroup, boolean isEditable){
    Color color = (isEditable?sEnableColor:sDisableColor);
    PdfPCell cell = createCell();

    if (prefGroup instanceof Class_) {
        Class_ c = (Class_) prefGroup;
        if (c.isInstructorAssignmentNeeded()) {
            addText(cell, (c.effectiveNbrInstructors() > 1 ? c.effectiveNbrInstructors() + " \u00d7 " : "") +
                    Formats.getNumberFormat("0.##").format(c.effectiveTeachingLoad()) + " " + MSG.teachingLoadUnits(),
                    false, false, Element.ALIGN_RIGHT, color, false);
        } else if (c.getSchedulingSubpart().isInstructorAssignmentNeeded()) {
            addText(cell, MSG.cellNoInstructorAssignment(), false, false, Element.ALIGN_RIGHT, color, false);
        }
    } else if (prefGroup instanceof SchedulingSubpart) {
        SchedulingSubpart ss = (SchedulingSubpart)prefGroup;
        if (ss.isInstructorAssignmentNeeded()) {
            addText(cell, (ss.getNbrInstructors() > 1 ? ss.getNbrInstructors() + " \u00d7 " : "") +
                    Formats.getNumberFormat("0.##").format(ss.getTeachingLoad()) + " " + MSG.teachingLoadUnits(),
                    false, false, Element.ALIGN_RIGHT, color, false);
        }
    }

    return cell;
}
项目:unitimes    文件:PdfInstructionalOfferingTableBuilder.java   
protected PdfPCell pdfBuildInstructor(PreferenceGroup prefGroup, boolean isEditable){
    Color color = (isEditable?sEnableColor:sDisableColor);
    PdfPCell cell = createCell();

    if (prefGroup instanceof Class_) {
        Class_ aClass = (Class_) prefGroup;
        TreeSet sortedInstructors = new TreeSet(new InstructorComparator());
        sortedInstructors.addAll(aClass.getClassInstructors());
        for (Iterator i=sortedInstructors.iterator(); i.hasNext();) {
            ClassInstructor ci = (ClassInstructor)i.next();
            String label = ci.getInstructor().getName(getInstructorNameFormat());
            if (ci.getResponsibility() != null && ci.getResponsibility().getAbbreviation() != null && !ci.getResponsibility().getAbbreviation().isEmpty())
                label += " (" + ci.getResponsibility().getAbbreviation() + ")";
            boolean italic = !aClass.isDisplayInstructor().booleanValue();
            boolean bold = ci.isLead().booleanValue();
            addText(cell, label, bold, italic, Element.ALIGN_LEFT, color, true);
        }
    }

    return cell;
}
项目:unitimes    文件:PdfInstructionalOfferingTableBuilder.java   
private PdfPCell pdfBuildSchedulePrintNote(PreferenceGroup prefGroup, boolean isEditable, UserContext user) {
    Color color = (isEditable?sEnableColor:sDisableColor);
    PdfPCell cell = createCell();

    if (prefGroup instanceof Class_) {
        Class_ c = (Class_) prefGroup;
        if (c.getSchedulePrintNote()!=null) {
            if (c.getSchedulePrintNote().length() <= 20 || user == null || CommonValues.NoteAsFullText.eq(user.getProperty(UserProperty.SchedulePrintNoteDisplay))){
                addText(cell, c.getSchedulePrintNote(), false, false, Element.ALIGN_LEFT, color, true);
            } else {
                addText(cell, c.getSchedulePrintNote().substring(0,20) + "...", false, false, Element.ALIGN_LEFT, color, true);                 
            }
        }
    }

    return cell;
}
项目:unitimes    文件:PdfInstructionalOfferingTableBuilder.java   
private PdfPCell pdfBuildSchedulePrintNote(InstructionalOffering io, boolean isEditable, UserContext user){
    Color color = (isEditable?sEnableColor:sDisableColor);
    PdfPCell cell = createCell();

    StringBuffer note = new StringBuffer("");
Set s = io.getCourseOfferings();
for (Iterator i=s.iterator(); i.hasNext(); ) {
    CourseOffering coI = (CourseOffering) i.next();
    if (coI.getScheduleBookNote()!=null && coI.getScheduleBookNote().trim().length()>0) {
        if (note.length()>0)
            note.append("\n");
        if (coI.getScheduleBookNote().length() <= 20 || Constants.showCrsOffrAsFullText(user)){
            note.append(coI.getScheduleBookNote());
        } else {
            note.append(coI.getScheduleBookNote().substring(0, 20) + "...");
        }
    }
}

addText(cell, note.toString(), false, false, Element.ALIGN_LEFT, color, true);
      return(cell);
  }
项目:unitimes    文件:PdfInstructionalOfferingTableBuilder.java   
protected PdfPCell pdfBuildNote(PreferenceGroup prefGroup, boolean isEditable, UserContext user){
    Color color = (isEditable?sEnableColor:sDisableColor);
    PdfPCell cell = createCell();

    if (prefGroup instanceof Class_) {
        Class_ c = (Class_) prefGroup;
        if (c.getNotes()!=null) {
            if (c.getNotes().length() <= 30  || user == null || CommonValues.NoteAsFullText.eq(user.getProperty(UserProperty.ManagerNoteDisplay))){
                addText(cell, c.getNotes(), false, false, Element.ALIGN_LEFT, color, true);
            } else {
                addText(cell, c.getNotes().substring(0, 30) + "...", false, false, Element.ALIGN_LEFT, color, true);
            }
        }
    }

    return cell;
}
项目:unitimes    文件:PdfInstructionalOfferingTableBuilder.java   
private PdfPCell pdfBuildManager(PreferenceGroup prefGroup, boolean isEditable){
    Color color = (isEditable?sEnableColor:sDisableColor);
    PdfPCell cell = createCell();

    Department managingDept = null;
    if (prefGroup instanceof Class_) {
        managingDept = ((Class_)prefGroup).getManagingDept();
    } else if (prefGroup instanceof SchedulingSubpart) {
        managingDept = ((SchedulingSubpart)prefGroup).getManagingDept();
    }
    if (managingDept!=null) {
        addText(cell, managingDept.getShortLabel(), false, false, Element.ALIGN_LEFT, color, true);
    }

    return cell;
}
项目:unitimes    文件:PdfInstructionalOfferingTableBuilder.java   
private PdfPCell pdfBuildExamPeriod(ExamAssignmentProxy examAssignment, TreeSet exams, boolean isEditable) {
    StringBuffer sb = new StringBuffer();
    for (Iterator i=exams.iterator();i.hasNext();) {
        Exam exam = (Exam)i.next();
        if (examAssignment!=null && examAssignment.getExamTypeId().equals(exam.getExamType().getUniqueId())) {
            ExamAssignment ea = examAssignment.getAssignment(exam.getUniqueId());
            if (ea==null && !isShowExamName()) continue;
            sb.append(ea==null?"":ea.getPeriodAbbreviation());
        } else {
            if (exam.getAssignedPeriod()==null && !isShowExamName()) continue;
            sb.append(exam.getAssignedPeriod()==null?"":exam.getAssignedPeriod().getAbbreviation());
        }
        if (i.hasNext()) sb.append("\n");
    }
    Color color = (isEditable?sEnableColor:sDisableColor);
    PdfPCell cell = createCell();
    addText(cell, sb.toString(), false, false, Element.ALIGN_LEFT, color, true);
    return cell;
}
项目:unitimes    文件:PdfInstructionalOfferingTableBuilder.java   
private PdfPCell pdfBuildExamRoom(ExamAssignmentProxy examAssignment, TreeSet exams, boolean isEditable) {
    StringBuffer sb = new StringBuffer();
    for (Iterator i=exams.iterator();i.hasNext();) {
        Exam exam = (Exam)i.next();
        if (examAssignment!=null && examAssignment.getExamTypeId().equals(exam.getExamType().getUniqueId())) {
            ExamAssignment ea = examAssignment.getAssignment(exam.getUniqueId());
            if (ea==null && !isShowExamName()) continue;
            sb.append(ea==null?"":ea.getRoomsName(", "));
        } else {
            if (exam.getAssignedPeriod()==null && !isShowExamName()) continue;
            for (Iterator j=new TreeSet(exam.getAssignedRooms()).iterator();j.hasNext();) {
                Location location = (Location)j.next();
                sb.append(location.getLabel());
                if (j.hasNext()) sb.append(", ");
            }
        }
        if (i.hasNext()) sb.append("\n");
    }
    Color color = (isEditable?sEnableColor:sDisableColor);
    PdfPCell cell = createCell();
    addText(cell, sb.toString(), false, false, Element.ALIGN_LEFT, color, true);
    return cell;
}
项目:unitimes    文件:PdfWebTable.java   
private float addImage(PdfPCell cell, String name) {
    try {
        java.awt.Image awtImage = (java.awt.Image)iImages.get(name);
        if (awtImage==null) return 0;
        Image img = Image.getInstance(awtImage, Color.WHITE);
        Chunk ck = new Chunk(img, 0, 0);
        if (cell.getPhrase()==null) {
            cell.setPhrase(new Paragraph(ck));
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        } else {
            cell.getPhrase().add(ck);
        }
        return awtImage.getWidth(null);
    } catch (Exception e) {
        return 0;
    }
}
项目:unitimes    文件:PdfWebTable.java   
private float addText(PdfPCell cell, String text, boolean bold, boolean italic, boolean underline, Color color, Color bgColor) {
    Font font = PdfFont.getFont(bold, italic, underline, color);
    Chunk chunk = new Chunk(text, font);
    if (bgColor!=null) chunk.setBackground(bgColor);
    if (cell.getPhrase()==null) {
        cell.setPhrase(new Paragraph(chunk));
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    } else {
        cell.getPhrase().add(chunk);
    }
    float width = 0; 
    if (text.indexOf('\n')>=0) {
        for (StringTokenizer s = new StringTokenizer(text,"\n"); s.hasMoreTokens();)
            width = Math.max(width,font.getBaseFont().getWidthPoint(s.nextToken(), font.getSize()));
    } else 
        width = Math.max(width,font.getBaseFont().getWidthPoint(text, font.getSize()));
    return width;
}
项目:itext2    文件:SimpleCell.java   
/**
 * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell, com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[])
 */
public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
    float sp_left = spacing_left;
    if (Float.isNaN(sp_left)) sp_left = 0f;
    float sp_right = spacing_right;
    if (Float.isNaN(sp_right)) sp_right = 0f;
    float sp_top = spacing_top;
    if (Float.isNaN(sp_top)) sp_top = 0f;
    float sp_bottom = spacing_bottom;
    if (Float.isNaN(sp_bottom)) sp_bottom = 0f;
    Rectangle rect = new Rectangle(position.getLeft(sp_left), position.getBottom(sp_bottom), position.getRight(sp_right), position.getTop(sp_top));
    rect.cloneNonPositionParameters(this);
    canvases[PdfPTable.BACKGROUNDCANVAS].rectangle(rect);
    rect.setBackgroundColor(null);
    canvases[PdfPTable.LINECANVAS].rectangle(rect);
}
项目:itext2    文件:Cell.java   
/**
 * Creates a PdfPCell based on this Cell object.
 * @return a PdfPCell
 * @throws BadElementException
 */
public PdfPCell createPdfPCell() throws BadElementException {
    if (rowspan > 1) throw new BadElementException("PdfPCells can't have a rowspan > 1");
    if (isTable()) return new PdfPCell(((Table)arrayList.get(0)).createPdfPTable());
    PdfPCell cell = new PdfPCell();
    cell.setVerticalAlignment(verticalAlignment);
    cell.setHorizontalAlignment(horizontalAlignment);
    cell.setColspan(colspan);
    cell.setUseBorderPadding(useBorderPadding);
    cell.setUseDescender(useDescender);
    cell.setLeading(getLeading(), 0);
    cell.cloneNonPositionParameters(this);
    cell.setNoWrap(getMaxLines() == 1);
    for (Iterator i = getElements(); i.hasNext(); ) {
           Element e = (Element)i.next();
           if (e.type() == Element.PHRASE || e.type() == Element.PARAGRAPH) {
               Paragraph p = new Paragraph((Phrase)e);
               p.setAlignment(horizontalAlignment);
               e = p;
           }
        cell.addElement(e);
    }
    return cell;
}
项目:itext2    文件:RtfRow.java   
/**
 * Imports a PdfPRow and copies all settings
 * 
 * @param row The PdfPRow to import
 * @since 2.1.3
 */
private void importRow(PdfPRow 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;
    PdfPCell[] cells = row.getCells();
    for(int i = 0; i < cells.length; i++) {
        cellWidth = (int) (this.width * this.parentTable.getProportionalWidths()[i] / 100);
        cellRight = cellRight + cellWidth;

        PdfPCell cell = cells[i];
        RtfCell rtfCell = new RtfCell(this.document, this, cell);
        rtfCell.setCellRight(cellRight);
        rtfCell.setCellWidth(cellWidth);
        this.cells.add(rtfCell);
    }
}
项目:itext2    文件:ImageCellTest.java   
/**
 * A cell with an image.
 * 
 */
@Test
public void main() throws Exception {

    // step 1: creation of a document-object
    Document document = new Document();

    // step 2:
    PdfWriter.getInstance(document, PdfTestBase.getOutputStream("ImageCell.pdf"));

    // step 3: we open the document
    document.open();
    Image image = Image.getInstance(PdfTestBase.RESOURCES_DIR + "otsoe.jpg");
    float[] widths = { 1f, 4f };
    PdfPTable table = new PdfPTable(widths);
    table.addCell("This is my dog");
    table.addCell(image);
    table.addCell("This two");
    table.addCell(new PdfPCell(image, true));
    table.addCell("This three");
    table.addCell(new PdfPCell(image, false));
    document.add(table);

    // step 5: we close the document
    document.close();
}
项目:itext2    文件:TableBordersTest.java   
private static PdfPCell makeCell(String text, int vAlignment, int hAlignment, Font font, float leading,
        float padding, Rectangle borders, boolean ascender, boolean descender) {
    Paragraph p = new Paragraph(text, font);
    p.setLeading(leading);

    PdfPCell cell = new PdfPCell(p);
    cell.setLeading(leading, 0);
    cell.setVerticalAlignment(vAlignment);
    cell.setHorizontalAlignment(hAlignment);
    cell.cloneNonPositionParameters(borders);
    cell.setUseAscender(ascender);
    cell.setUseDescender(descender);
    cell.setUseBorderPadding(true);
    cell.setPadding(padding);
    return cell;
}
项目:sistra    文件:Tabla.java   
private void writeColumns(PDFDocument document, PdfPTable tb)
    {
        PdfPTable tabla = new PdfPTable(anchoColumnas);     
        tabla.setWidthPercentage(100);
//      this.tabla.setSplitRows(true);

        Font font = document.getContext().getDefaultFont();
        PdfPCell cell;
        cell = createCell("",Rectangle.LEFT | Rectangle.RIGHT);
        tabla.addCell(cell);
        for(int i=0; i<columnas.size(); i++)
        {
            cell = createCell((String)columnas.get(i),document.getContext().getColor(204,204,204),
                      Rectangle.ALIGN_CENTER,font);
            tabla.addCell(cell);
        }
        cell = createCell("",Rectangle.LEFT | Rectangle.RIGHT);
        tabla.addCell(cell);
        addTabla(tb,tabla);
    }
项目:sistra    文件:Tabla.java   
private void writeCampos(PDFDocument document, PdfPTable tb)
{
    PdfPTable tabla = new PdfPTable(anchoColumnas);
    PdfPCell cell;
    tabla.setWidthPercentage(100);
    Font font = document.getContext().getDefaultFont();
    for(int i=0; i<campos.size();i++)
    {
        cell = createCell("",Rectangle.LEFT | Rectangle.RIGHT);
        tabla.addCell(cell);
        Vector cp = (Vector)campos.get(i);
        for(int j=0; j<cp.size(); j++)
        {
            cell = createCell((String)cp.get(j),font);
            tabla.addCell(cell);
        }
        cell = createCell("",Rectangle.LEFT | Rectangle.RIGHT);
        tabla.addCell(cell);
    }
    addTabla(tb,tabla);
}
项目:OSCAR-ConCert    文件:SummaryOfActionsAndCommentsReportGenerator.java   
private PdfPTable createNeedHeader(String name) throws DocumentException {
    Font whiteFont = new Font(Font.HELVETICA,14,Font.BOLD,Color.WHITE);
    PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(100);
    table.setWidths(new float[]{0.10f,0.20f,0.70f});
    PdfPCell emptyCell = new PdfPCell();
    emptyCell.setBorder(0);
    table.addCell(emptyCell);

    PdfPCell headerCell = new PdfPCell();
    headerCell.setColspan(2);
    headerCell.setPhrase(new Phrase(name,whiteFont));
    headerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    headerCell.setBackgroundColor(Color.LIGHT_GRAY);
    table.addCell(headerCell);
    return table;
}
项目:dhis2-core    文件:DefaultPdfDataEntryFormService.java   
private void insertTable_HiddenValue( PdfPTable mainTable, Rectangle rectangle, PdfWriter writer, String fieldName,
    String value )
    throws IOException, DocumentException
{
    boolean hasBorder = false;

    // Add Organization ID/Period textfield
    // Create A table to add for each group AT HERE
    PdfPTable table = new PdfPTable( 1 ); // Code 1

    addCell_WithTextField( table, rectangle, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), fieldName, value );

    // Add to the main table
    PdfPCell cell_withInnerTable = new PdfPCell( table );
    // cell_withInnerTable.setPadding(0);
    cell_withInnerTable.setBorder( Rectangle.NO_BORDER );
    mainTable.addCell( cell_withInnerTable );
}
项目:dhis2-core    文件:DefaultPdfDataEntryFormService.java   
private void insertTable_TextRow( PdfWriter writer, PdfPTable mainTable, String text, Font font )
{
    boolean hasBorder = false;

    // Add Organization ID/Period textfield
    // Create A table to add for each group AT HERE
    PdfPTable table = new PdfPTable( 1 );
    table.setHorizontalAlignment( Element.ALIGN_LEFT );

    addCell_Text( table, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), text, Element.ALIGN_LEFT, font );

    // Add to the main table
    PdfPCell cell_withInnerTable = new PdfPCell( table );

    cell_withInnerTable.setBorder( Rectangle.NO_BORDER );

    mainTable.addCell( cell_withInnerTable );
}
项目:dhis2-core    文件:DefaultPdfDataEntryFormService.java   
private void addCell_WithTextField( PdfPTable table, Rectangle rect, PdfWriter writer, PdfPCell cell, String strfldName,
    int fieldCellType, String value )
    throws IOException, DocumentException
{
    TextField nameField = new TextField( writer, rect, strfldName );

    nameField.setBorderWidth( 1 );
    nameField.setBorderColor( Color.BLACK );
    nameField.setBorderStyle( PdfBorderDictionary.STYLE_SOLID );
    nameField.setBackgroundColor( COLOR_BACKGROUDTEXTBOX );

    nameField.setText( value );

    nameField.setAlignment( Element.ALIGN_RIGHT );
    nameField.setFont( pdfFormFontSettings.getFont( PdfFormFontSettings.FONTTYPE_BODY ).getBaseFont() );

    cell.setCellEvent( new PdfFieldCell( nameField.getTextField(), rect.getWidth(), rect.getHeight(), fieldCellType, writer ) );

    table.addCell( cell );
}
项目:dhis2-core    文件:DefaultPdfDataEntryFormService.java   
private void addCell_WithDropDownListField( PdfPTable table, Rectangle rect, PdfWriter writer, PdfPCell cell, String strfldName, String[] optionList,
    String[] valueList ) throws IOException, DocumentException
{
    TextField textList = new TextField( writer, rect, strfldName );

    textList.setChoices( optionList );
    textList.setChoiceExports( valueList );

    textList.setBorderWidth( 1 );
    textList.setBorderColor( Color.BLACK );
    textList.setBorderStyle( PdfBorderDictionary.STYLE_SOLID );
    textList.setBackgroundColor( COLOR_BACKGROUDTEXTBOX );

    PdfFormField dropDown = textList.getComboField();

    cell.setCellEvent( new PdfFieldCell( dropDown, rect.getWidth(), rect.getHeight(), writer ) );

    table.addCell( cell );
}
项目:javamelody    文件:PdfDatabaseInformationsReport.java   
private void writeRow(String[] row) {
    final PdfPCell defaultCell = getDefaultCell();
    defaultCell.setVerticalAlignment(Element.ALIGN_TOP);
    for (final String value : row) {
        if (value == null || value.isEmpty()) {
            addCell("");
        } else {
            if (isNumber(value)) {
                defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            } else {
                defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            }
            addCell(value);
        }
    }
}
项目:javamelody    文件:PdfProcessInformationsReport.java   
private void writeProcessInformations(ProcessInformations processInformations) {
    final PdfPCell defaultCell = getDefaultCell();
    defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    addCell(processInformations.getUser());
    defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    addCell(integerFormat.format(processInformations.getPid()));
    if (!windows) {
        addCell(percentFormat.format(processInformations.getCpuPercentage()));
        addCell(percentFormat.format(processInformations.getMemPercentage()));
    }
    addCell(integerFormat.format(processInformations.getVsz()));
    if (!windows) {
        addCell(integerFormat.format(processInformations.getRss()));
        defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
        addCell(processInformations.getTty());
        addCell(processInformations.getStat());
        defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        addCell(processInformations.getStart());
    }
    addCell(processInformations.getCpuTime());
    defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    addCell(processInformations.getCommand());
}
项目:javamelody    文件:PdfHeapHistogramReport.java   
private void writeClassInfoRow(ClassInfo classInfo, long totalInstances, long totalBytes,
        boolean sourceDisplayed) {
    final PdfPCell defaultCell = getDefaultCell();
    defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    addCell(classInfo.getName());
    defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    final long bytes = classInfo.getBytes();
    final long instancesCount = classInfo.getInstancesCount();
    addCell(integerFormat.format(bytes / 1024));
    addCell(integerFormat.format(bytes * 100 / totalBytes));
    addCell(integerFormat.format(instancesCount));
    addCell(integerFormat.format(instancesCount * 100 / totalInstances));
    defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    if (sourceDisplayed) {
        final String source = classInfo.getSource();
        if (source == null) {
            addCell("");
        } else {
            addCell(source);
        }
    }
}
项目:javamelody    文件:PdfRequestAndGraphDetailReport.java   
private void writeRequests() throws IOException, DocumentException {
    final Map<String, Long> childRequests = request.getChildRequestsExecutionsByRequestId();
    final boolean hasChildren = !childRequests.isEmpty();
    final Counter parentCounter = getCounterByRequestId(request);
    final boolean allChildHitsDisplayed = parentCounter != null
            && parentCounter.getChildCounterName() != null && request.hasChildHits();

    final PdfPCell defaultCell = getDefaultCell();
    defaultCell.setLeading(2, 1);
    defaultCell.setPaddingTop(0);

    nextRow();
    writeRequest(request, -1, allChildHitsDisplayed);

    if (hasChildren) {
        writeChildRequests(childRequests, allChildHitsDisplayed);
    }
}
项目:javamelody    文件:PdfRequestAndGraphDetailReport.java   
private void writeRequestValues(CounterRequest aRequest, boolean allChildHitsDisplayed) {
    final PdfPCell defaultCell = getDefaultCell();
    defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    addCell(integerFormat.format(aRequest.getMean()));
    addCell(integerFormat.format(aRequest.getMaximum()));
    addCell(integerFormat.format(aRequest.getStandardDeviation()));
    if (aRequest.getCpuTimeMean() >= 0) {
        addCell(integerFormat.format(aRequest.getCpuTimeMean()));
    } else {
        addCell("");
    }
    addCell(systemErrorFormat.format(aRequest.getSystemErrorPercentage()));
    if (allChildHitsDisplayed) {
        final boolean childHitsDisplayed = aRequest.hasChildHits();
        if (childHitsDisplayed) {
            addCell(integerFormat.format(aRequest.getChildHitsMean()));
        } else {
            addCell("");
        }
        if (childHitsDisplayed) {
            addCell(integerFormat.format(aRequest.getChildDurationsMean()));
        } else {
            addCell("");
        }
    }
}
项目:javamelody    文件:PdfJndiReport.java   
private void writeJndiBinding(JndiBinding jndiBinding) throws BadElementException, IOException {
    final PdfPCell defaultCell = getDefaultCell();
    defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    final String name = jndiBinding.getName();
    final String className = jndiBinding.getClassName();
    final String contextPath = jndiBinding.getContextPath();
    final String value = jndiBinding.getValue();
    if (contextPath != null) {
        final Image image = getFolderImage();
        final Phrase phrase = new Phrase("", cellFont);
        phrase.add(new Chunk(image, 0, 0));
        phrase.add(" ");
        phrase.add(name);
        addCell(phrase);
    } else {
        addCell(name);
    }
    addCell(className != null ? className : "");
    addCell(value != null ? value : "");
}
项目:javamelody    文件:PdfCacheInformationsReport.java   
private void writeCacheInformations(CacheInformations cacheInformations) {
    final PdfPCell defaultCell = getDefaultCell();
    defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    addCell(cacheInformations.getName());
    defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    if (configurationEnabled) {
        addCell(integerFormat.format(cacheInformations.getInMemoryPercentUsed()));
    }
    addCell(integerFormat.format(cacheInformations.getInMemoryObjectCount()));
    addCell(integerFormat.format(cacheInformations.getOnDiskObjectCount()));
    if (hitsRatioEnabled) {
        addCell(integerFormat.format(cacheInformations.getInMemoryHitsRatio()));
        addCell(integerFormat.format(cacheInformations.getHitsRatio()));
    }
    if (configurationEnabled) {
        defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
        addCell(cacheInformations.getConfiguration());
    }
}
项目:javamelody    文件:PdfJobInformationsReport.java   
private void writeJobInformations(JobInformations jobInformations)
        throws BadElementException, IOException {
    final PdfPCell defaultCell = getDefaultCell();
    defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    addCell(jobInformations.getGroup());
    addCell(jobInformations.getName());
    addCell(jobInformations.getJobClassName());
    defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    final CounterRequest counterRequest = getCounterRequest(jobInformations);
    // counterRequest ne peut pas être null ici
    if (counterRequest.getMean() >= 0) {
        addCell(formatDuration(counterRequest.getMean()));
    } else {
        addCell("");
    }
    // rq: on n'affiche pas ici le nb d'exécutions, le maximum, l'écart-type
    // ou le pourcentage d'erreurs, uniquement car cela ferait trop de colonnes dans la page
    writeJobTimes(jobInformations, counterRequest);
    defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    if (jobInformations.isPaused()) {
        addCell(getString("oui"));
    } else {
        addCell(getString("non"));
    }
}