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

项目:MountainQuest-PL    文件:CoverPageGenerator.java   
@Override
public PdfPTable generatePage() throws Exception {
    Image image = Image.getInstance(imageFile.toURL());
    float heightToWidthRatio = (210f / 297f);
    Image imageCropped = ImageUtils.cropImageToMeetRatio(pdfWriter, image, heightToWidthRatio);

    PdfPCell cell = new PdfPCell(imageCropped, true);
    cell.setBorder(0);
    cell.setPadding(COVER_MARGIN);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setExtraParagraphSpace(0);
    cell.setRightIndent(0);

    PdfPTable table = new PdfPTable(1);
    ;
    table.setWidthPercentage(100f);
    table.setWidths(new int[]{1});
    table.setExtendLastRow(true);
    table.addCell(cell);

    return table;
}
项目:NICON    文件:ExporOnlyViagemPdf.java   
private PdfPTable cellRodape(String value, boolean l,boolean r,int align)
{
    Font fontCorpoTableO= FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED ,7.5f);
    PdfPTable pTable = new PdfPTable(1);
    pTable.setWidthPercentage(100f);
    PdfPCell cellValue = new PdfPCell(new Phrase(value,fontCorpoTableO));
    if(l){cellValue.setBorderWidthLeft(0);}
    if(r){cellValue.setBorderWidthRight(0);}
   switch (align) 
   {
       case Element.ALIGN_RIGHT:cellValue.setHorizontalAlignment(Element.ALIGN_RIGHT);break;
       case Element.ALIGN_LEFT:cellValue.setHorizontalAlignment(Element.ALIGN_LEFT);break;
       case Element.ALIGN_CENTER:cellValue.setHorizontalAlignment(Element.ALIGN_CENTER);break;
       default:break;
   }
    pTable.addCell(cellValue);
    return pTable;
}
项目:ureport    文件:PageHeaderFooterEvent.java   
private PdfPCell buildPdfPCell(HeaderFooter phf,String text,int type){
    PdfPCell cell=new PdfPCell();
    cell.setPadding(0);
    cell.setBorder(Rectangle.NO_BORDER);
    Font font=FontBuilder.getFont(phf.getFontFamily(), phf.getFontSize(), phf.isBold(), phf.isItalic(),phf.isUnderline());
    String fontColor=phf.getForecolor();
    if(StringUtils.isNotEmpty(fontColor)){
        String[] color=fontColor.split(",");
        font.setColor(Integer.valueOf(color[0]), Integer.valueOf(color[1]), Integer.valueOf(color[2]));         
    }
    Paragraph graph=new Paragraph(text,font);
    cell.setPhrase(graph);
    switch(type){
    case 1:
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        break;
    case 2:
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        break;
    case 3:
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        break;
    }
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    return cell;
}
项目:pdf-renderer    文件:CellFactory.java   
public PdfPCell getFillCell(){
    PdfPCell fillCell = new PdfPCell();
    fillCell.setBorderWidth( 0f );
    fillCell.setLeft(0);
    fillCell.setTop(0);
    fillCell.setRight( 0 );
    fillCell.setBottom( 0 );
    fillCell.setUseAscender( true );
    fillCell.setIndent(0);
    fillCell.setHorizontalAlignment( Element.ALIGN_LEFT );
    fillCell.setVerticalAlignment( Element.ALIGN_BOTTOM );
    fillCell.setPaddingLeft( 0f);
    fillCell.setPaddingBottom(0f);
    fillCell.setPaddingRight(0f );
    fillCell.setPaddingTop( 0f );
    fillCell.setBorder( 0 );
    renderEmptyCell(fillCell);

    return fillCell;
}
项目:bioinformatics    文件:PdfReportUtil.java   
private static PdfPCell getPhotoCell(BufferedImage bufferedImage, float scalePercent, boolean isHorizontallyCentered) throws BadElementException, IOException {
    Image jpeg = Image.getInstance(bufferedImage, null);
    jpeg.scalePercent(scalePercent);
    jpeg.setAlignment(Image.MIDDLE);
    PdfPCell photoCell = new PdfPCell(jpeg);
    photoCell.setBorder(0);
    if (isHorizontallyCentered) {
        photoCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    } else {
        photoCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    }

    photoCell.setVerticalAlignment(Element.ALIGN_TOP);
    int height = (int) Math.ceil(bufferedImage.getHeight() * scalePercent / 100);
    photoCell.setFixedHeight(height);
    return photoCell;
}
项目:bdf2    文件:AbstractPdfReportBuilder.java   
private void createGridColumnHeader(PdfPTable table, Collection<ColumnHeader> topHeaders, int maxHeaderLevel) throws Exception {
    for (int i = 1; i < 50; i++) {
        List<ColumnHeader> result = new ArrayList<ColumnHeader>();
        generateGridHeadersByLevel(topHeaders, i, result);
        for (ColumnHeader header : result) {
            PdfPCell cell = new PdfPCell(createParagraph(header));
            if (header.getBgColor() != null) {
                int[] colors = header.getBgColor();
                cell.setBackgroundColor(new BaseColor(colors[0], colors[1], colors[2]));
            }
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(header.getAlign());
            cell.setColspan(header.getColspan());
            if (header.getColumnHeaders().size() == 0) {
                int rowspan = maxHeaderLevel - (header.getLevel() - 1);
                if (rowspan > 0) {
                    cell.setRowspan(rowspan);
                }
            }
            table.addCell(cell);
        }
    }
}
项目:bdf2    文件:AbstractPdfReportBuilder.java   
private void createGridTableDatas(PdfPTable table, Collection<ReportData> datas) {
    for (ReportData data : datas) {
        PdfPCell cell = new PdfPCell(createParagraph(data.getTextChunk()));
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        int level = this.calculateIndentationCount(data.getTextChunk().getText());
        if (data.getBgColor() != null) {
            int[] colors = data.getBgColor();
            cell.setBackgroundColor(new BaseColor(colors[0], colors[1], colors[2]));
        }
        if (level == 0) {
            cell.setHorizontalAlignment(data.getAlign());
        } else {
            cell.setIndent(20 * level);
        }
        table.addCell(cell);
    }
}
项目:PowerApi    文件:PDFTest.java   
public PdfPCell createCell(String value, Font font, int align, int colspan, boolean boderFlag) {
    PdfPCell cell = new PdfPCell();
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(align);
    cell.setColspan(colspan);
    cell.setPhrase(new Phrase(value, font));
    cell.setPadding(3.0f);
    if (!boderFlag) {
        cell.setBorder(0);
        cell.setPaddingTop(15.0f);
        cell.setPaddingBottom(8.0f);
    }
    return cell;
}
项目:pdf-renderer    文件:CellFactory.java   
public PdfPCell createCell( Block block ){
    float[] margins = block.getMargins();
    PdfPCell cell =  new PdfPCell();
    cell.setBorderWidth(0);
    cell.setVerticalAlignment( VerticalAlign.getByName(block.getVerticalAlign()).getAlignment() );
    cell.setLeft(0);
    cell.setTop(0);
    cell.setRight(0);
    cell.setBottom(0);
    cell.setUseAscender( block.isUseAscender() );
    cell.setIndent(0);
    cell.setPaddingLeft( SizeFactory.millimetersToPostscriptPoints( margins[0]) );
    cell.setPaddingBottom( SizeFactory.millimetersToPostscriptPoints(margins[3]) );
    cell.setPaddingRight( SizeFactory.millimetersToPostscriptPoints(margins[1]) );
    cell.setPaddingTop( SizeFactory.millimetersToPostscriptPoints(margins[2]) );
    cell.setFixedHeight(SizeFactory.millimetersToPostscriptPoints( block.getPosition()[3] ));
    cell.setBorder(0);
    cell.setCellEvent( new CellBlockEvent().createEvent(block));
    cell.setRotation( block.getRotation() );
    return cell;
}
项目:pdf-renderer    文件:Paragraph.java   
public void onRender(PdfPCell cell ) throws PdfRenderException{
    com.itextpdf.text.Paragraph pr = new com.itextpdf.text.Paragraph();
    pr.setLeading( leading );
    pr.setExtraParagraphSpace(0);
    pr.setAlignment( HorizontalAlign.getByName(horizontalAlign).getAlignment() );
    pr.setIndentationLeft( indent.getLeft() );
    pr.setFirstLineIndent( indent.getFirst() );
    pr.setIndentationRight( indent.getRight() );
    pr.setSpacingBefore(0);
    pr.setSpacingAfter(0);
    if( phrases != null ){
        for( AbstractPhrase phrase : phrases ){
            phrase.onRender( pr );
        }
    }
    cell.addElement( pr );
}
项目:hotel    文件:ResidenceService.java   
private void createAccomodationTableHeaders(PdfPTable accomodationsTable) {
    PdfPCell numberHeader = new PdfPCell(new Paragraph("Lp."));
    PdfPCell roomNumberHeader = new PdfPCell(new Paragraph("Nr pokoju"));
    PdfPCell dateFromHeader = new PdfPCell(new Paragraph("Od"));
    PdfPCell dateToHeader = new PdfPCell(new Paragraph("Do"));
    PdfPCell placesHeader = new PdfPCell(new Paragraph("Miejsca"));
    PdfPCell roomTypeHeader = new PdfPCell(new Paragraph("Typ"));
    PdfPCell roomPriceHeader = new PdfPCell(new Paragraph("Cena"));
    accomodationsTable.addCell(numberHeader);
    accomodationsTable.addCell(roomNumberHeader);
    accomodationsTable.addCell(dateFromHeader);
    accomodationsTable.addCell(dateToHeader);
    accomodationsTable.addCell(placesHeader);
    accomodationsTable.addCell(roomTypeHeader);
    accomodationsTable.addCell(roomPriceHeader);
}
项目:hotel    文件:ResidenceService.java   
private void createofferInstancesTableContent(List<OfferInstance> offerInstances, PdfPTable offerInstancesTable) {
    DecimalFormat decimalFormat = new DecimalFormat(PRICE_DECIMAL_FORMAT);

    int i = 1;
    for (OfferInstance offerInstance : offerInstances) {
        Offer offer = offerInstance.getOffer();

        PdfPCell numberCell = new PdfPCell(new Paragraph(String.valueOf(i++)));

        String offerName = offer.getName();
        PdfPCell roomNumberCell = new PdfPCell(new Paragraph(offerName));

        String offerPrice = decimalFormat.format(offer.getBaseValue()) + " PLN";
        PdfPCell roomPriceCell = new PdfPCell(new Paragraph(offerPrice));

        offerInstancesTable.addCell(numberCell);
        offerInstancesTable.addCell(roomNumberCell);
        offerInstancesTable.addCell(roomPriceCell);
    }

}
项目:hotel    文件:EmployeeService.java   
private void createTableContent(List<CleaningSchedule> cleaningSchedules, PdfPTable cleaningScheduleTable) {
    int i = 1;
    for (CleaningSchedule cleaningSchedule : cleaningSchedules) {
        PdfPCell numberCell = new PdfPCell(new Paragraph(String.valueOf(i++)));
        String roomNumber = cleaningSchedule.getAccomodation().getAllocationEntity().getNumber();
        PdfPCell roomNumberCell = new PdfPCell(new Paragraph(roomNumber));
        String preferredTime = cleaningSchedule.getDesiredTime() == null ? "-" : cleaningSchedule.getDesiredTime().toString("HH:mm");
        PdfPCell preferredTimeCell = new PdfPCell(new Paragraph(preferredTime));
        String note = cleaningSchedule.getNote() == null ? "-" : cleaningSchedule.getNote();
        PdfPCell noteCell = new PdfPCell(new Paragraph(note));
        cleaningScheduleTable.addCell(numberCell);
        cleaningScheduleTable.addCell(roomNumberCell);
        cleaningScheduleTable.addCell(preferredTimeCell);
        cleaningScheduleTable.addCell(noteCell);
    }
}
项目:NICON    文件:ExporOnlyViagemPdf.java   
private PdfPTable cellRodape(String value, boolean l,boolean r,int align)
{
    Font fontCorpoTableO= FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED ,7.5f);
    PdfPTable pTable = new PdfPTable(1);
    pTable.setWidthPercentage(100f);
    PdfPCell cellValue = new PdfPCell(new Phrase(value,fontCorpoTableO));
    if(l){cellValue.setBorderWidthLeft(0);}
    if(r){cellValue.setBorderWidthRight(0);}
   switch (align) 
   {
       case Element.ALIGN_RIGHT:cellValue.setHorizontalAlignment(Element.ALIGN_RIGHT);break;
       case Element.ALIGN_LEFT:cellValue.setHorizontalAlignment(Element.ALIGN_LEFT);break;
       case Element.ALIGN_CENTER:cellValue.setHorizontalAlignment(Element.ALIGN_CENTER);break;
       default:break;
   }
    pTable.addCell(cellValue);
    return pTable;
}
项目:bamboobsc    文件:PersonalReportPdfCommand.java   
private void putSignature(PdfPTable table, Context context) throws Exception {
    String uploadOid = (String)context.get("uploadSignatureOid");
    if ( StringUtils.isBlank(uploadOid) ) {
        return;
    }
    byte[] imageBytes = UploadSupportUtils.getDataBytes( uploadOid );
    if ( null == imageBytes ) {
        return;
    }
    Image signatureImgObj = Image.getInstance( imageBytes );
    signatureImgObj.setWidthPercentage(40f);
    PdfPCell cell = new PdfPCell();
    cell.setBorder( Rectangle.NO_BORDER );
    cell.addElement(signatureImgObj);
    table.addCell(cell);        
}
项目:bamboobsc    文件:KpiReportPdfCommand.java   
private void putSignature(PdfPTable table, Context context) throws Exception {
    String uploadOid = (String)context.get("uploadSignatureOid");
    if ( StringUtils.isBlank(uploadOid) ) {
        return;
    }
    byte[] imageBytes = UploadSupportUtils.getDataBytes( uploadOid );
    if ( null == imageBytes ) {
        return;
    }
    Image signatureImgObj = Image.getInstance( imageBytes );
    signatureImgObj.setWidthPercentage(40f);
    PdfPCell cell = new PdfPCell();
    cell.setBorder( Rectangle.NO_BORDER );
    cell.addElement(signatureImgObj);
    table.addCell(cell);        
}
项目:bamboobsc    文件:OrganizationReportPdfCommand.java   
private void putSignature(PdfPTable table, Context context) throws Exception {
    String uploadOid = (String)context.get("uploadSignatureOid");
    if ( StringUtils.isBlank(uploadOid) ) {
        return;
    }
    byte[] imageBytes = UploadSupportUtils.getDataBytes( uploadOid );
    if ( null == imageBytes ) {
        return;
    }
    Image signatureImgObj = Image.getInstance( imageBytes );
    signatureImgObj.setWidthPercentage(40f);
    PdfPCell cell = new PdfPCell();
    cell.setBorder( Rectangle.NO_BORDER );
    cell.addElement(signatureImgObj);
    table.addCell(cell);        
}
项目:FOXopen    文件:FormListWidgetBuilder.java   
/**
 * Serialises a form row
 * @param pSerialisationContext
 * @param pSerialiser
 * @param pRowNode The form node
 */
private void addFormRow(SerialisationContext pSerialisationContext, PDFSerialiser pSerialiser, EvaluatedNodeInfo pRowNode) {
  ElementAttributes lElementAttributes = pSerialiser.getInheritedElementAttributes();
  pSerialiser.getCSSResolver().resolveStyles(lElementAttributes, LIST_ROW_TAG, getRowClasses(pRowNode), getRowStyles(pRowNode));
  pSerialiser.pushElementAttributes(lElementAttributes);

  PdfPCell lCell = pSerialiser.getElementFactory().getCell();
  Paragraph lCellParagraph = pSerialiser.getElementFactory().getParagraph();

  pSerialiser.startContainer(ElementContainerFactory.getContainer(lCell, lCellParagraph));
  pSerialiser.getWidgetBuilder(pRowNode.getWidgetBuilderType()).buildWidget(pSerialisationContext, pSerialiser, pRowNode);
  pSerialiser.endContainer();
  pSerialiser.add(lCell);

  pSerialiser.popElementAttributes();
}
项目:FOXopen    文件:InputField.java   
/**
 * Serialise the input field div and content
 * @param pSerialisationContext
 * @param pSerialiser
 * @param pEvalNode
 */
public void serialise(SerialisationContext pSerialisationContext, PDFSerialiser pSerialiser, EN pEvalNode) {
  ElementAttributes lElementAttributes = pSerialiser.getInheritedElementAttributes();
  pSerialiser.getCSSResolver().resolveStyles(lElementAttributes, INPUT_FIELD_TAG, getInputFieldClasses(), Collections.emptyList());
  pSerialiser.pushElementAttributes(lElementAttributes);

  PdfPTable lTable = pSerialiser.getElementFactory().getTable(1);
  PdfPCell lCell = pSerialiser.getElementFactory().getCell();
  Paragraph lCellParagraph = pSerialiser.getElementFactory().getParagraph();

  pSerialiser.startContainer(ElementContainerFactory.getContainer(lCell, lCellParagraph));
  mInputFieldContent.addContent(pSerialisationContext, pSerialiser, pEvalNode);
  if (lCellParagraph.isEmpty()) {
    // If there is no cell content in all cells in a table row, the row will be 0 height - add a zero width space to
    // ensure that the input field div isn't collapsed like this (the height will be determined from the cell
    // paragraph font)
    lCellParagraph.add(ZERO_WIDTH_SPACE_CHARACTER);
  }
  pSerialiser.endContainer();

  lTable.addCell(lCell);
  pSerialiser.add(lTable);

  pSerialiser.popElementAttributes();
}
项目:FOXopen    文件:ListWidgetBuilder.java   
/**
 * Serialises a column header
 * @param pSerialiser
 * @param pHeaderNode The column header node
 */
private void addColumnHeader(PDFSerialiser pSerialiser, EvaluatedNodeInfo pHeaderNode) {
  ElementAttributes lElementAttributes = pSerialiser.getInheritedElementAttributes();
  pSerialiser.getCSSResolver().resolveStyles(lElementAttributes, LIST_CELL_TAG, getHeaderClasses(pHeaderNode), getHeaderStyles(pHeaderNode));
  pSerialiser.pushElementAttributes(lElementAttributes);

  PdfPCell lHeaderCell = pSerialiser.getElementFactory().getCell();

  // Add the header prompt to the cell if one exists
  Optional.ofNullable(pHeaderNode.getSummaryPrompt()).ifPresent(pEvaluatedPrompt -> {
    Paragraph lCellParagraph = pSerialiser.getElementFactory().getParagraph();
    pSerialiser.startContainer(ElementContainerFactory.getContainer(lHeaderCell, lCellParagraph));
    pSerialiser.addParagraphText(pSerialiser.getSafeStringAttribute(pEvaluatedPrompt));
    pSerialiser.endContainer();
  });

  pSerialiser.add(lHeaderCell);
  pSerialiser.popElementAttributes();
}
项目:FOXopen    文件:ListWidgetBuilder.java   
/**
 * Serialises a list body cell
 * @param pSerialisationContext
 * @param pSerialiser
 * @param pItemNode The item node of the cell if the row and column of the cell has content
 * @param pIsNestedList Whether or not the list if nested, a different class is applied to nested list cells
 */
private void addBodyCell(SerialisationContext pSerialisationContext, PDFSerialiser pSerialiser, Optional<EvaluatedNodeInfo> pItemNode, boolean pIsNestedList) {
  ElementAttributes lElementAttributes = pSerialiser.getInheritedElementAttributes();
  pSerialiser.getCSSResolver().resolveStyles(lElementAttributes, LIST_CELL_TAG, getCellClasses(pItemNode, pIsNestedList), getCellStyles(pItemNode));
  pSerialiser.pushElementAttributes(lElementAttributes);

  PdfPCell lCell = pSerialiser.getElementFactory().getCell();
  Paragraph lCellParagraph = pSerialiser.getElementFactory().getParagraph();

  if (pItemNode.isPresent() && pItemNode.get().getVisibility() != NodeVisibility.DENIED) {
    // Column was found for this row and it isn't denied visibility, add content
    pSerialiser.startContainer(ElementContainerFactory.getContainer(lCell, lCellParagraph));
    pSerialiser.getWidgetBuilder(pItemNode.get().getWidgetBuilderType()).buildWidget(pSerialisationContext, pSerialiser, pItemNode.get());
    pSerialiser.endContainer();
  }

  pSerialiser.add(lCell);
  pSerialiser.popElementAttributes();
}
项目:FOXopen    文件:MultiOptionSelectWidget.java   
private PdfPCell createColumnItem(PDFSerialiser pSerialiser, EvaluatedNodeInfo pEvalNode,
                                  LayoutFieldValueMappingItemColumn pColumnItem, int pItemsPerRow, boolean pHideField) {
  ElementAttributes lElementAttributes = pSerialiser.getInheritedElementAttributes();
  pSerialiser.getCSSResolver().resolveStyles(lElementAttributes, MULTI_OPTION_CELL_TAG,
                                             getColumnItemClasses(pEvalNode), getColumnItemStyles(pEvalNode));
  pSerialiser.pushElementAttributes(lElementAttributes);

  PdfPCell lFieldCell = pSerialiser.getElementFactory().getCell();
  Paragraph lCellParagraph = pSerialiser.getElementFactory().getParagraph();
  lFieldCell.setColspan(FOXGridUtils.calculateAdjustedColumnSpan(pColumnItem.getColSpan(), pItemsPerRow));

  pSerialiser.startContainer(ElementContainerFactory.getContainer(lFieldCell, lCellParagraph));
  addColumnItemContent(pSerialiser, pColumnItem, pHideField);
  pSerialiser.endContainer();

  pSerialiser.popElementAttributes();

  return lFieldCell;
}
项目:FOXopen    文件:FormWidget.java   
/**
 * Serialises a table cell of the column item content with cell styles applied
 * @param pSerialisationContext
 * @param pSerialiser
 * @param pColumnItem The column item to create a cell for
 * @param pFormColumns The number of columns in the form, used to determine field column spans
 */
private void addColumnItem(SerialisationContext pSerialisationContext, PDFSerialiser pSerialiser, LayoutWidgetItemColumn pColumnItem, int pFormColumns) {
  ElementAttributes lElementAttributes = pSerialiser.getInheritedElementAttributes();
  pSerialiser.getCSSResolver().resolveStyles(lElementAttributes, FORM_CELL_TAG, getColumnItemCellClasses(pColumnItem), getColumnItemCellStyles(pColumnItem));
  pSerialiser.pushElementAttributes(lElementAttributes);

  PdfPCell lFormCell = pSerialiser.getElementFactory().getCell();
  Paragraph lCellParagraph = pSerialiser.getElementFactory().getParagraph();
  lFormCell.setColspan(FOXGridUtils.calculateAdjustedColumnSpan(pColumnItem.getColSpan(), pFormColumns));

  pSerialiser.startContainer(ElementContainerFactory.getContainer(lFormCell, lCellParagraph));
  addColumnItemContent(pSerialisationContext, pSerialiser, pColumnItem);
  pSerialiser.endContainer();

  pSerialiser.add(lFormCell);
  pSerialiser.popElementAttributes();
}
项目:FOXopen    文件:HeaderFooterComponent.java   
@Override
public void buildComponent(SerialisationContext pSerialisationContext, PDFSerialiser pSerialiser, EPN pEvalNode) {
  ElementAttributes lElementAttributes = pSerialiser.getInheritedElementAttributes();
  pSerialiser.getCSSResolver().resolveStyles(lElementAttributes, mTag,
                                             Collections.singletonList(pEvalNode.getClasses()),
                                             Collections.singletonList(pEvalNode.getStyles()));
  pSerialiser.pushElementAttributes(lElementAttributes);

  // Add header/footer content to a table
  PdfPTable lTable = pSerialiser.getElementFactory().getTable(1);
  PdfPCell lCell = pSerialiser.getElementFactory().getCell();
  Paragraph lCellParagraph = pSerialiser.getElementFactory().getParagraph();

  pSerialiser.startContainer(ElementContainerFactory.getContainer(lCell, lCellParagraph));
  processChildren(pSerialisationContext, pSerialiser, pEvalNode);
  pSerialiser.endContainer();

  lTable.addCell(lCell);

  // Consume the header/footer content (i.e. set the header or footer content via the serialiser)
  mHeaderFooterContentConsumer.accept(pSerialiser, new HeaderFooterContent(lTable));
  pSerialiser.popElementAttributes();
}
项目:FOXopen    文件:HeadingComponentBuilder.java   
@Override
public void buildComponent(SerialisationContext pSerialisationContext, PDFSerialiser pSerialiser, EvaluatedHeadingPresentationNode pEvalNode) {
  ElementAttributes lElementAttributes = pSerialiser.getInheritedElementAttributes();
  pSerialiser.getCSSResolver().resolveStyles(lElementAttributes, HEADING_TAG_PREFIX + pEvalNode.getLevel(),
                                             Collections.singletonList(pEvalNode.getClasses()),
                                             Collections.singletonList(pEvalNode.getStyles()));
  pSerialiser.pushElementAttributes(lElementAttributes);

  // Heading text is contained within a table so that it may be styled as a block-level element (i.e. the same as a
  // div with borders, background colours etc.)
  PdfPTable lTable = pSerialiser.getElementFactory().getTable(1);
  PdfPCell lCell = pSerialiser.getElementFactory().getCell();
  Paragraph lCellParagraph = pSerialiser.getElementFactory().getParagraph();

  pSerialiser.startContainer(ElementContainerFactory.getContainer(lCell, lCellParagraph));
  processChildren(pSerialisationContext, pSerialiser, pEvalNode);
  pSerialiser.endContainer();

  lTable.addCell(lCell);
  // A table spacer is required so any content before the heading is not overlapped
  pSerialiser.addTableSpacer();
  pSerialiser.add(lTable);

  pSerialiser.popElementAttributes();
}
项目:FOXopen    文件:GridCellComponentBuilder.java   
@Override
public void buildComponent(SerialisationContext pSerialisationContext, PDFSerialiser pSerialiser, EvaluatedGridCellPresentationNode pEvalNode) {
  ElementAttributes lElementAttributes = pSerialiser.getInheritedElementAttributes();
  pSerialiser.getCSSResolver().resolveStyles(lElementAttributes, GRID_CELL_TAG,
                                             Arrays.asList(GRID_CELL_CLASS, pEvalNode.getClasses()),
                                             Collections.singletonList(pEvalNode.getStyles()));
  pSerialiser.pushElementAttributes(lElementAttributes);

  PdfPCell lCell = pSerialiser.getElementFactory().getCell();
  Paragraph lCellParagraph = pSerialiser.getElementFactory().getParagraph();
  lCell.setColspan(pEvalNode.getColumnSpan());

  pSerialiser.startContainer(ElementContainerFactory.getContainer(lCell, lCellParagraph));
  processChildren(pSerialisationContext, pSerialiser, pEvalNode);
  pSerialiser.endContainer();
  pSerialiser.add(lCell);

  pSerialiser.popElementAttributes();
}
项目:testarea-itext5    文件:PercentileCellBackground.java   
@Override
    public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
        PdfContentByte canvas = canvases[PdfPTable.BACKGROUNDCANVAS];

        float xTransition = position.getLeft() + (position.getRight() - position.getLeft()) * (percent/100.0f);
        float yTransition = (position.getTop() + position.getBottom()) / 2f;
        float radius = (position.getRight() - position.getLeft()) * 0.025f;
        PdfShading axial = PdfShading.simpleAxial(canvas.getPdfWriter(),
                xTransition - radius, yTransition, xTransition + radius, yTransition, leftColor, rightColor);
        PdfShadingPattern shading = new PdfShadingPattern(axial);

        canvas.saveState();
        canvas.setShadingFill(shading);
        canvas.rectangle(position.getLeft(), position.getBottom(), position.getWidth(), position.getHeight());
//        canvas.clip();
        canvas.fill();
        canvas.restoreState();
    }
项目:testarea-itext5    文件:AddField.java   
public void cellLayout(PdfPCell cell, Rectangle position,
                               PdfContentByte[] canvases) {
            PdfWriter writer = canvases[0].getPdfWriter();
            float x = position.getLeft();
            float y = position.getBottom();
            Rectangle rect = new Rectangle(x-5, y-5, x+5, y+5);
            RadioCheckField checkbox = new RadioCheckField(
                    writer, rect, name, "Yes");
            checkbox.setCheckType(RadioCheckField.TYPE_CROSS);
            checkbox.setChecked(check);
// change: set border color
            checkbox.setBorderColor(BaseColor.BLACK);

            try {
                pdfStamper.addAnnotation(checkbox.getCheckField(), page);
            } catch (Exception e) {
                throw new ExceptionConverter(e);
            }
        }
项目:testarea-itext5    文件:UseRowspan.java   
/**
 * <a href="http://stackoverflow.com/questions/44005834/changing-rowspans">
 * Changing rowspans
 * </a>
 * <p>
 * Helper method of the OP.
 * </p>
 * @see #testUseRowspanLikeUser7968180()
 * @see #testUseRowspanLikeUser7968180Fixed()
 * @see #createPdf(String)
 * @see #createPdfFixed(String)
 */
private static void addCellToTableCzech(PdfPTable table, int horizontalAlignment,
        int verticalAlignment, String value, int colspan, int rowspan,
        String fontType, float fontSize) {
    BaseFont base = null;
    try {
        base = BaseFont.createFont(fontType, BaseFont.CP1250, BaseFont.EMBEDDED);
    } catch (Exception e) {
        e.printStackTrace();
    }
    Font font = new Font(base, fontSize);
    PdfPCell cell = new PdfPCell(new Phrase(value, font));
    cell.setColspan(colspan);
    cell.setRowspan(rowspan);
    cell.setHorizontalAlignment(horizontalAlignment);
    cell.setVerticalAlignment(verticalAlignment);
    cell.setBorder(PdfPCell.NO_BORDER);
    table.addCell(cell);
}
项目:testarea-itext5    文件:DynamicFooter.java   
public PdfPTable generateFooter() {
    try {
        BaseFont baseFont = BaseFont.createFont(/*"resources/ARIAL.TTF"*/ "c:/Windows/Fonts/arial.ttf", BaseFont.IDENTITY_H, true);
        footerTable = new PdfPTable(1);
        footerTable.setTotalWidth(440);
        footerTable.setLockedWidth(true);

        Font pageNumberFont = new Font(baseFont, 9, Font.BOLD);
        Paragraph pageNumberP = new Paragraph(titleIndex+"-"+ pageNumber, pageNumberFont);
        PdfPCell pageNumberCell = new PdfPCell(pageNumberP);
        pageNumberCell.setBorder(0);
        pageNumberCell.setPaddingTop(20);
        footerTable.addCell(pageNumberCell);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return footerTable;
}
项目:MountainQuest-PL    文件:TableOfContentsPageGenerator.java   
private void generateSectionTitle(PdfPTable table, Data data) throws IOException, DocumentException {
    if (!this.currentSection.equals(data.mountains)) {
        currentSection = data.mountains;
        currentBackgroundColor = backgroundColorGenerator.generate(data);

        PdfPCell cellSeparator = new PdfPCell(PhraseUtil.phrase(" "));
        cellSeparator.setBorder(0);
        cellSeparator.setPadding(10);
        cellSeparator.setColspan(4);
        table.addCell(cellSeparator);

        PdfPCell cell = new PdfPCell(PhraseUtil.phrase(currentSection, 14, Font.BOLD));
        cell.setBorder(0);
        cell.setPadding(10);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setColspan(4);
        cell.setBackgroundColor(currentBackgroundColor);
        table.addCell(cell);
    }
}
项目:MountainQuest-PL    文件:EmptyPageGenerator.java   
private PdfPTable tableWithPageNumber() throws DocumentException, IOException {

        PdfPTable innerTable = new PdfPTable(1);
        innerTable.setWidths(new int[]{1});
        innerTable.setWidthPercentage(100);
        innerTable.setPaddingTop(0);
        innerTable.addCell(new PageNumberCellGenerator(pageNumber, BackgroundColorGenerator.DEFAULT_BACKGROUND_COLOR)
                .generateTile());

        PdfPCell cell = new PdfPCell();
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        cell.setPadding(0);
        cell.addElement(innerTable);

        PdfPTable table = new PdfPTable(1);
        table.setWidthPercentage(100f);
        table.setWidths(new int[]{1});
        table.setExtendLastRow(true);
        table.addCell(cell);
        return table;
    }
项目:MountainQuest-PL    文件:DataPageGenerator.java   
private PdfPCell generateFooter() throws IOException, DocumentException, URISyntaxException {

        PdfPCell cell = new PdfPCell();
        cell.setColspan(12);
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        cell.setPadding(0);

        PdfPTable innerTable = new PdfPTable(2);
        innerTable.getDefaultCell().setBorder(0);
        innerTable.setWidths(new int[]{1, 1});
        innerTable.setWidthPercentage(100);
        innerTable.addCell(generateStamp());
        innerTable.addCell(new PageNumberCellGenerator(pageNumber, backgroundColor).generateTile());

        cell.addElement(innerTable);
        return cell;
    }
项目:tellervo    文件:PDFLabelMaker.java   
public void addCell(PdfPCell cell) {

    cell.setBorder(borderwidth);

    cell.setNoWrap(false);
    cell.setFixedHeight(margins.getLabelHeight());

    //cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    //cell.setVerticalAlignment(Element.ALIGN_TOP);

    if(curX != 0)
    {
        PdfPCell gapcell = new PdfPCell();
        gapcell.setBorder(borderwidth);
        table.addCell(gapcell);
    }

    curX++;
    table.addCell(cell);

    if(curX == nAcross)
        //table.completeRow();
        curX = 0;
}
项目:weplantaforest    文件:PdfReceiptView.java   
private PdfPTable createDateTable(PdfContentByte cb, Receipt receipt) throws DocumentException {
    PdfPTable tableForDate = new PdfPTable(1);
    float[] rowForDate = { 110f };
    tableForDate.setTotalWidth(rowForDate);
    tableForDate.getDefaultCell()
                .setBorder(Rectangle.NO_BORDER);

    tableForDate.addCell(new Phrase(new Chunk("Datum der Zuwendung:", textFont)));
    tableForDate.addCell(new Phrase(new Chunk(" ", textFont)));
    final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+2"), Locale.GERMAN);
    for (final Cart cart : receipt.getCarts()) {
        cal.setTimeInMillis(cart.getTimeStamp());
        final String date = cal.get(Calendar.DAY_OF_MONTH) + "." + (cal.get(Calendar.MONTH) + 1) + "." + cal.get(Calendar.YEAR);
        PdfPCell cell = new PdfPCell(new Phrase(new Chunk(date, textFontUserData)));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cell.setBorder(PdfPCell.NO_BORDER);
        tableForDate.addCell(cell);
    }
    return tableForDate;
}
项目:weplantaforest    文件:PdfReceiptView.java   
private PdfPTable createLawTable(PdfContentByte cb) throws DocumentException {
    PdfPTable table = new PdfPTable(1);
    float[] rows = { 445f };
    table.setTotalWidth(rows);
    table.getDefaultCell()
         .setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell()
         .setLeading(8f, 0);

    table.addCell(new Phrase(new Chunk("Es handelt sich nicht um den Verzicht auf Erstattung von Aufwendungen.", textFontLawText)));
    table.addCell(new Phrase(new Chunk("Die Gesellschaft ist wegen Förderung (begünstigter Zweck: Umweltschutz (§52 (2) S. 1 Nr.(n) 8 AO)) durch", textFontLawText)));
    table.addCell(new Phrase(new Chunk("Bescheinigung des Finanzamt Halle (Saale)-Nord, StNr. 110/108/91169, vom 19.11.2008 ab 01.01.2009", textFontLawText)));
    table.addCell(new Phrase(new Chunk("als gemeinnützig anerkannt. Letzter Freistellungsbescheid datiert auf den 20.06.2013.", textFontLawText)));
    table.addCell(new Phrase(new Chunk("Es wird bestätigt, dass die Zuwendung nur zur Förderung des Umweltschutzes verwendet wird.", textFontLawText)));

    PdfPCell emptyCell = new PdfPCell();
    emptyCell.setBorder(Rectangle.BOTTOM);
    emptyCell.setFixedHeight(15f);
    table.addCell(emptyCell);

    return table;
}
项目:rolp    文件:PdfFormatHelper.java   
public static PdfPTable buildHeaderNameLine(String schuelername, Font headerFont) throws DocumentException {
    PdfPCell labelCell = new PdfPCell(new Phrase("Name", headerFont));
    labelCell.setBorder(Rectangle.BOTTOM);
    labelCell.setBorderWidth(1f);

    PdfPCell nameCell = new PdfPCell(new Phrase(schuelername, headerFont));
    nameCell.setBorder(Rectangle.BOTTOM);
    nameCell.setBorderWidth(1f);
    nameCell.setColspan(5);

    PdfPTable table = prebuildHeaderTable();
    table.addCell(labelCell);
    table.addCell(nameCell);

    return table;
}
项目:rolp    文件:PdfFormatHelper.java   
public static PdfPTable buildFooterVersetzungsvermerkLine(String versetzungsvermerk, Font footerFont) throws DocumentException {
    PdfPCell labelCell = new PdfPCell(new Phrase("Versetzungsvermerk", footerFont));
    labelCell.setBorder(Rectangle.BOTTOM);
    labelCell.setBorderWidth(1f);

    PdfPCell nameCell = new PdfPCell(new Phrase(versetzungsvermerk, footerFont));
    nameCell.setBorder(Rectangle.BOTTOM);
    nameCell.setBorderWidth(1f);

    PdfPTable table = new PdfPTable(2);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.setWidthPercentage(100f);
    table.addCell(labelCell);
    table.addCell(nameCell);
    table.setWidths(new float[] {0.3f, 0.7f});
    return table;
}
项目:rolp    文件:PdfFormatHelper.java   
public static PdfPTable buildFooterDatumLine(String datumString, Font footerFont) throws DocumentException {
    PdfPCell labelCell = new PdfPCell(new Phrase("Datum", footerFont));
    labelCell.setBorder(Rectangle.BOTTOM);
    labelCell.setBorderWidth(1f);

    PdfPCell nameCell = new PdfPCell(new Phrase(datumString, footerFont));
    nameCell.setBorder(Rectangle.BOTTOM);
    nameCell.setBorderWidth(1f);

    PdfPTable table = new PdfPTable(2);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.setWidthPercentage(100f);
    table.addCell(labelCell);
    table.addCell(nameCell);
    table.setWidths(new float[] {0.3f, 0.7f});
    return table;
}
项目:rolp    文件:PdfFormatHelper.java   
public static PdfPTable buildFooterDienstsiegelLine(Font footerFont) throws DocumentException {
    PdfPCell leftCell = new PdfPCell(new Phrase("", footerFont));
    leftCell.setBorder(Rectangle.NO_BORDER);
    leftCell.setBorderWidth(1f);

    PdfPCell centerCell = new PdfPCell(new Phrase("Dienstsiegel der Schule", footerFont));
    centerCell.setBorder(Rectangle.NO_BORDER);
    centerCell.setBorderWidth(1f);
    centerCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell rightCell = new PdfPCell(new Phrase("", footerFont));
    rightCell.setBorder(Rectangle.NO_BORDER);
    rightCell.setBorderWidth(1f);

    PdfPTable table = new PdfPTable(3);
    table.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.setWidthPercentage(100f);
    table.addCell(leftCell);
    table.addCell(centerCell);
    table.addCell(rightCell);
    table.setWidths(new float[] {0.3f, 0.3f, 0.3f});
    return table;
}