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

项目: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 );
}
项目:Deskera-HRMS    文件:ExportSalarySlipService.java   
@Override
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Rectangle page = document.getPageSize();
        PdfPTable footer = new PdfPTable(1);
        footer.setWidthPercentage(100);
        footer.setSpacingBefore(20);
        PdfPCell footerPageNocell = new PdfPCell(new Paragraph(fontFamilySelector.process(messageSource.getMessage("hrms.payroll.computer.generated.payslip.not.require.signature", null, this.locale), FontContext.REGULAR_NORMAL_TIMES_NEW_ROMAN)));
        footerPageNocell.setBorder(0);
        footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        footer.addCell(footerPageNocell);
        footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin()+2 , writer.getDirectContent());

    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:Learning-Spring-5.0    文件:PdfView.java   
@Override
protected void buildPdfDocument(Map<String, Object> model, Document document, PdfWriter writer,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    List<Book> books = (List<Book>) model.get("book");

    PdfPTable table = new PdfPTable(3);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.getDefaultCell().setBackgroundColor(Color.lightGray);

    table.addCell("Book Name");
    table.addCell("Author Name");
    table.addCell("Price");

    for (Book book : books) {
        table.addCell(book.getBookName());
        table.addCell(book.getAuthor());
        table.addCell("" + book.getPrice());
    }
    document.add(table);

}
项目: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    文件:EndPageTest.java   
/**
 * @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter,
 *      com.lowagie.text.Document)
 */
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Rectangle page = document.getPageSize();
        PdfPTable head = new PdfPTable(3);
        for (int k = 1; k <= 6; ++k)
            head.addCell("head " + k);
        head.setTotalWidth(page.getWidth() - document.leftMargin()
                - document.rightMargin());
        head.writeSelectedRows(
                0,
                -1,
                document.leftMargin(),
                page.getHeight() - document.topMargin()
                        + head.getTotalHeight(), writer.getDirectContent());
        PdfPTable foot = new PdfPTable(3);
        for (int k = 1; k <= 6; ++k)
            foot.addCell("foot " + k);
        foot.setTotalWidth(page.getWidth() - document.leftMargin()
                - document.rightMargin());
        foot.writeSelectedRows(0, -1, document.leftMargin(),
                document.bottomMargin(), writer.getDirectContent());
    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目: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    文件:SplitTableTest.java   
/**
 * Break a large table up into several smaller tables for memory management
 * purposes.
 * 
 */
@Test
public void main() throws Exception {
    // step1
    Document document = new Document(PageSize.A4, 10, 10, 10, 10);
    // step2
    PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("SplitTable.pdf"));
    // step3
    document.open();
    // step4

    PdfContentByte cb = writer.getDirectContent();
    PdfPTable table = new PdfPTable(10);
    for (int k = 1; k <= 100; ++k) {
        table.addCell("The number " + k);
    }
    table.setTotalWidth(800);
    table.writeSelectedRows(0, 5, 0, -1, 50, 650, cb);
    document.newPage();
    table.writeSelectedRows(5, -1, 0, -1, 50, 650, cb);
    document.close();

    // step5
    document.close();
}
项目: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;
}
项目:docx4j-export-FO    文件:Conversion.java   
/**
 * @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document)
 */
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Rectangle page = document.getPageSize();

        if (headerFooterPolicy.getHeader(writer.getPageNumber())!=null) {
         Hdr hdr = headerFooterPolicy.getHeader(writer.getPageNumber()).getJaxbElement();
         PdfPTable head = new PdfPTable(1); // num cols             
         // TODO - no cell borders
         traverseBlockLevelContent( hdr.getEGBlockLevelElts(), head);
         head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
         head.writeSelectedRows(0, -1, document.leftMargin(), page.getHeight() - document.topMargin() + head.getTotalHeight(),
             writer.getDirectContent());
        }

        if (headerFooterPolicy.getFooter(writer.getPageNumber())!=null) {
         Ftr ftr = headerFooterPolicy.getFooter(writer.getPageNumber()).getJaxbElement();               
         PdfPTable foot = new PdfPTable(1);
         traverseBlockLevelContent( ftr.getEGBlockLevelElts(), foot);
         foot.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
         foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(),
             writer.getDirectContent());
        }
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:dhis2-core    文件:DefaultPdfDataEntryFormService.java   
private void insertTable_DataSet( PdfPTable mainTable, PdfWriter writer, DataSet dataSet )
    throws IOException, DocumentException
{
    Rectangle rectangle = new Rectangle( TEXTBOXWIDTH, PdfDataEntryFormUtil.CONTENT_HEIGHT_DEFAULT );

    if ( dataSet.getSections().size() > 0 )
    {
        for ( Section section : dataSet.getSections() )
        {
            insertTable_DataSetSections( mainTable, writer, rectangle, section.getDataElements(), section.getDisplayName() );
        }
    }
    else
    {
        insertTable_DataSetSections( mainTable, writer, rectangle, dataSet.getDataElements(), "" );
    }
}
项目:dhis2-core    文件:DefaultPdfDataEntryFormService.java   
private void insertTable_ProgramStage( PdfPTable mainTable, PdfWriter writer, ProgramStage programStage )
    throws IOException, DocumentException
{
    Rectangle rectangle = new Rectangle( TEXTBOXWIDTH, PdfDataEntryFormUtil.CONTENT_HEIGHT_DEFAULT );

    // Add Program Stage Sections
    if ( programStage.getProgramStageSections().size() > 0 )
    {
        // Sectioned Ones
        for ( ProgramStageSection section : programStage.getProgramStageSections() )
        {
            insertTable_ProgramStageSections( mainTable, rectangle, writer, section.getDataElements() );
        }
    }
    else
    {
        // Default one
        insertTable_ProgramStageSections( mainTable, rectangle, writer, programStage.getAllDataElements() );
    }
}
项目: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 );
}
项目:Biblivre-3    文件:SearchesByDateReport.java   
@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    SearchesByDateReportDto dto = (SearchesByDateReportDto)reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_SEARCHES_BY_DATE_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);
    document.add(new Phrase("\n"));
    StringBuilder p2Builder = new StringBuilder();
    p2Builder.append(this.getText("REPORTS_FROM") + " ");
    p2Builder.append(dto.getInitialDate());
    p2Builder.append(" " + this.getText("REPORTS_TO") + " ");
    p2Builder.append(dto.getFinalDate());
    Paragraph p2 = new Paragraph(this.getHeaderChunk(p2Builder.toString()));
    p2.setAlignment(Paragraph.ALIGN_LEFT);
    document.add(p2);
    document.add(new Phrase("\n"));
    if (dto != null) {
        PdfPTable table = createTable(dto);
        document.add(table);
        document.add(new Phrase("\n"));
    }
}
项目:Biblivre-3    文件:RequestsByDateReport.java   
@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    RequestsByDateReportDto dto = (RequestsByDateReportDto)reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_REQUESTS_BY_DATE_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);
    document.add(new Phrase("\n"));
    StringBuilder header = new StringBuilder();
    header.append(this.getText("REPORTS_FROM"));
    header.append(" ").append(dto.getInitialDate()).append(" ");
    header.append(this.getText("REPORTS_TO"));
    header.append(" ").append(dto.getFinalDate());
    Paragraph p2 = new Paragraph(this.getHeaderChunk(header.toString()));
    p2.setAlignment(Paragraph.ALIGN_LEFT);
    document.add(p2);
    document.add(new Phrase("\n"));
    if (dto.getData() != null) {
        PdfPTable table = createTable(dto.getData());
        document.add(table);
        document.add(new Phrase("\n"));
    }
}
项目:Biblivre-3    文件:LateReturnLendingsReport.java   
@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    DelayedLendingsDto dto = (DelayedLendingsDto)reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_DELAYED_LENDING_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);
    document.add(new Phrase("\n"));

    if (dto.getData().size() != 0) {
        Paragraph p2 = new Paragraph(this.getHeaderChunk(this.getText("REPORTS_DELAYED_LENDING_TOTAL") + ":  " + dto.getData().size()));
        p2.setAlignment(Paragraph.ALIGN_LEFT);
        document.add(p2);
        document.add(new Phrase("\n"));

        PdfPTable table = createTable(dto.getData());
        document.add(table);
        document.add(new Phrase("\n"));
    }
}
项目:javamelody    文件:PdfRequestAndGraphDetailReport.java   
private void writeGraph() throws IOException, DocumentException {
    final JRobin jrobin = collector.getJRobin(graphName);
    if (jrobin != null) {
        final byte[] img = jrobin.graph(range, 960, 400);
        final Image image = Image.getInstance(img);
        image.scalePercent(50);

        final PdfPTable table = new PdfPTable(1);
        table.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.setWidthPercentage(100);
        table.getDefaultCell().setBorder(0);
        table.addCell("\n");
        table.addCell(image);
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(new Phrase(getString("graph_units"), cellFont));
        addToDocument(table);
    } else {
        // just in case request is null and collector.getJRobin(graphName) is null, we must write something in the document
        addToDocument(new Phrase("\n", cellFont));
    }
}
项目:AgileAlligators    文件:DefaultPdfDataEntryFormService.java   
private void insertTable_DataSet( PdfPTable mainTable, PdfWriter writer, DataSet dataSet )
    throws IOException, DocumentException
{
    Rectangle rectangle = new Rectangle( TEXTBOXWIDTH, PdfDataEntryFormUtil.CONTENT_HEIGHT_DEFAULT );

    if ( dataSet.getSections().size() > 0 )
    {
        for ( Section section : dataSet.getSections() )
        {
            insertTable_DataSetSections( mainTable, writer, rectangle, section.getDataElements(), section.getDisplayName() );
        }
    }
    else
    {
        insertTable_DataSetSections( mainTable, writer, rectangle, dataSet.getDataElements(), "" );
    }
}
项目:AgileAlligators    文件:DefaultPdfDataEntryFormService.java   
private void insertTable_ProgramStage( PdfPTable mainTable, PdfWriter writer, ProgramStage programStage )
    throws IOException, DocumentException
{
    Rectangle rectangle = new Rectangle( TEXTBOXWIDTH, PdfDataEntryFormUtil.CONTENT_HEIGHT_DEFAULT );

    // Add Program Stage Sections
    if ( programStage.getProgramStageSections().size() > 0 )
    {
        // Sectioned Ones
        for ( ProgramStageSection section : programStage.getProgramStageSections() )
        {
            insertTable_ProgramStageSections( mainTable, rectangle, writer, section.getProgramStageDataElements() );
        }
    }
    else
    {
        // Default one
        insertTable_ProgramStageSections( mainTable, rectangle, writer, programStage.getProgramStageDataElements() );
    }
}
项目:AgileAlligators    文件: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 );
}
项目:AgileAlligators    文件: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 );
}
项目:AgileAlligators    文件: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 );
}
项目:members_cuacfm    文件:PayMemberServiceImpl.java   
@Override
public ResponseEntity<byte[]> createPdfFeeMember(Long feeMemberId, String option) {

    FeeMember feeMember = feeMemberRepository.findById(feeMemberId);
    List<PayMember> payMembers = payMemberRepository.getPayMemberListByFeeMemberId(feeMemberId);

    String fileNameFeeMember = messageSource.getMessage("fileNameFeeMember", null, Locale.getDefault()) + "_"
            + DateUtils.format(new Date(), DateUtils.FORMAT_FILE) + ".pdf";

    FileUtils.createFolderIfNoExist(pathFeeMember);
    String path = pathFeeMember + fileNameFeeMember;

    String title;
    if (option.equals(Constants.PAY)) {
        title = feeMember.getName() + " - " + messageSource.getMessage("feeMember.printPayList", null, Locale.getDefault());
    } else if (option.equals(Constants.NOPAY)) {
        title = feeMember.getName() + " - " + messageSource.getMessage("feeMember.printNoPayList", null, Locale.getDefault());
    } else {
        title = feeMember.getName() + " - " + messageSource.getMessage("feeMember.printAllList", null, Locale.getDefault());
    }
    CreatePdf pdf = new CreatePdf();
    PdfPTable table = pdf.createTablePayMembers(messageSource, option, payMembers);
    pdf.createBody(path, title, table);
    return CreatePdf.viewPdf(path, fileNameFeeMember);
}
项目:members_cuacfm    文件:PayProgramServiceImpl.java   
@Override
public ResponseEntity<byte[]> createPdfFeeProgram(Long feeProgramId, String option) {

    FeeProgram feeProgram = feeProgramRepository.findById(feeProgramId);
    List<PayProgram> payPrograms = payProgramRepository.getPayProgramListByFeeProgramId(feeProgramId);

    String fileNameFeeProgram = messageSource.getMessage("fileNameFeeProgram", null, Locale.getDefault()) + "_"
            + DateUtils.format(new Date(), DateUtils.FORMAT_FILE) + ".pdf";

    FileUtils.createFolderIfNoExist(pathFeeProgram);
    String path = pathFeeProgram + fileNameFeeProgram;

    String title;
    if (option.equals(Constants.PAY)) {
        title = feeProgram.getName() + " - " + messageSource.getMessage("feeProgram.printPayList", null, Locale.getDefault());
    } else if (option.equals(Constants.NOPAY)) {
        title = feeProgram.getName() + " - " + messageSource.getMessage("feeProgram.printNoPayList", null, Locale.getDefault());
    } else {
        title = feeProgram.getName() + " - " + messageSource.getMessage("feeProgram.printAllList", null, Locale.getDefault());
    }
    CreatePdf pdf = new CreatePdf();
    PdfPTable table = pdf.createTablePayPrograms(messageSource, option, payPrograms);
    pdf.createBody(path, title, table);
    return CreatePdf.viewPdf(path, fileNameFeeProgram);
}
项目:api-resolver    文件:SimplePdfDocInstaller.java   
private void addSummary(Section section, ApiDoc apiDoc) throws Exception {

    Paragraph summary = new Paragraph(itemFont.process("★简要信息"));
    summary.setSpacingBefore(6f);
    summary.setSpacingAfter(8f);

    List<String[]> rowDatas = new ArrayList<String[]>();
    rowDatas.add(new String[]{apiDoc.getMapping()});
    rowDatas.add(new String[]{apiDoc.getAuthor()});
    rowDatas.add(new String[]{apiDoc.getVersion()});
    PdfPTable table = DefaultPdfTable.get().create(TBDirection.Vertical, rowDatas.size(), 
                        new String[]{"映射地址", "作者", "版本"}, new int[]{1, 10});
    DefaultPdfTable.get().setDataAlignments(new int[]{Element.ALIGN_LEFT});
    DefaultPdfTable.get().setRowDatas(rowDatas);
    Paragraph wrapperTable = new Paragraph();
    wrapperTable.setIndentationLeft(12f);
    wrapperTable.add(table);
    section.add(summary);
    section.add(wrapperTable);
}
项目:api-resolver    文件:SimplePdfDocInstaller.java   
private void addParameters(Section section, ApiDoc apiDoc) throws Exception {

     Paragraph inputParams = new Paragraph(itemFont.process("★输入参数"));
     inputParams.setSpacingBefore(6f);
     inputParams.setSpacingAfter(8f);

     List<String[]> rowDatas = new ArrayList<String[]>();
     for (ParamDoc paramDoc : apiDoc.getParams()) {
      String required = paramDoc.getRequired() ? "必须" : "可选";
      rowDatas.add(new String[]{paramDoc.getName(), paramDoc.getType(), 
              required, paramDoc.getExampleValue(), paramDoc.getDefaultValue(), paramDoc.getDesc()});
     }

     PdfPTable paramTable = DefaultPdfTable.get().create(TBDirection.Horizontal, rowDatas.size()+1,
                        new String[]{"名称", "类型", "是否必须", "示例值", "默认值", "描述"}, 
                        new int[]{15, 10, 10, 15, 10, 40});
     DefaultPdfTable.get().setDataAlignments(new int[]{Element.ALIGN_CENTER, Element.ALIGN_CENTER,
                        Element.ALIGN_CENTER, Element.ALIGN_CENTER, Element.ALIGN_CENTER, Element.ALIGN_LEFT});
     DefaultPdfTable.get().setRowDatas(rowDatas);
     Paragraph wrapperTable = new Paragraph();
     wrapperTable.setIndentationLeft(12f);
     wrapperTable.add(paramTable);
     section.add(inputParams);
     section.add(wrapperTable);
}
项目:api-resolver    文件:SimplePdfDocInstaller.java   
private void addResultExample(Section section, ApiDoc apiDoc) throws Exception {

          Paragraph result = new Paragraph(itemFont.process("★返回示例"));
//        result.setLeading(6f);
          result.setSpacingBefore(6f);
          result.setSpacingAfter(8f);

          PdfPTable table = new PdfPTable(1);
          table.setWidthPercentage(95f);
          table.setHorizontalAlignment(Element.ALIGN_LEFT);
          PdfPCell pdfPCell = table.getDefaultCell();
          pdfPCell.setHorizontalAlignment(Element.ALIGN_LEFT);
          pdfPCell.setBackgroundColor(Color.LIGHT_GRAY);
          if (apiDoc.getResultDoc() != null && apiDoc.getResultExample() != null) {
              pdfPCell.setPhrase(DefaultPdfTable.tableBSelector.process(apiDoc.getResultExample()));
          }
          table.addCell(pdfPCell);
          Paragraph wrapperTable = new Paragraph();
          wrapperTable.setSpacingAfter(8f);
          wrapperTable.setIndentationLeft(12f);
          wrapperTable.add(table);
          section.add(result);
          section.add(wrapperTable);
    }
项目:PDFTestForAndroid    文件:EndPage.java   
/**
 * @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter,
 *      com.lowagie.text.Document)
 */
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Rectangle page = document.getPageSize();
        PdfPTable head = new PdfPTable(3);
        for (int k = 1; k <= 6; ++k)
            head.addCell("head " + k);
        head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        head.writeSelectedRows(0, -1, document.leftMargin(), page.getHeight() - document.topMargin()
                + head.getTotalHeight(), writer.getDirectContent());
        PdfPTable foot = new PdfPTable(3);
        for (int k = 1; k <= 6; ++k)
            foot.addCell("foot " + k);
        foot.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(), writer.getDirectContent());
    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:Deskera-HRMS    文件:ExportPayslipController.java   
@Override
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Rectangle page = document.getPageSize();
        PdfPTable footer = new PdfPTable(1);
        footer.setWidthPercentage(100);
        footer.setSpacingBefore(20);
        PdfPCell footerPageNocell = new PdfPCell(new Paragraph(fontFamilySelector.process(messageSource.getMessage("hrms.payroll.computer.generated.payslip.not.require.signature", null, RequestContextUtils.getLocale(request)), FontContext.SMALL_NORMAL_TIMES_NEW_ROMAN)));
        footerPageNocell.setBorder(0);
        footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        footer.addCell(footerPageNocell);
        footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin()+2 , writer.getDirectContent());

    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:Deskera-HRMS    文件:exportAppraisalReportPDFDAOImpl.java   
@Override
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Rectangle page = document.getPageSize();
        PdfPTable footer = new PdfPTable(1);
        footer.setWidthPercentage(100);
        footer.setSpacingBefore(20);
        String FootPager = String.valueOf(document.getPageNumber());//current page no
        PdfPCell footerPageNocell = new PdfPCell(new Phrase(fontFamilySelector.process(FootPager, FontContext.SMALL_BOLD_HELVETICA)));
        footerPageNocell.setBorder(0);
        footerPageNocell.setPaddingBottom(5);
        footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        footer.addCell(footerPageNocell);
        footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin() - 5, writer.getDirectContent());

    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:Deskera-HRMS    文件:PrintAppraisalReportDAOImp.java   
@Override
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Rectangle page = document.getPageSize();
        PdfPTable footer = new PdfPTable(1);
        footer.setWidthPercentage(100);
        footer.setSpacingBefore(20);
        String FootPager = String.valueOf(document.getPageNumber());//current page no
        PdfPCell footerPageNocell = new PdfPCell(new Phrase(fontFamilySelector.process(FootPager, FontContext.SMALL_BOLD_HELVETICA)));
        footerPageNocell.setBorder(0);
        footerPageNocell.setPaddingBottom(5);
        footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        footer.addCell(footerPageNocell);
        footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin() - 5, writer.getDirectContent());

    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:Deskera-HRMS    文件:AppraisalDetails.java   
@Override
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Rectangle page = document.getPageSize();
        PdfPTable footer = new PdfPTable(1);
        footer.setWidthPercentage(100);
        footer.setSpacingBefore(20);
        String FootPager = String.valueOf(document.getPageNumber());//current page no
        PdfPCell footerPageNocell = new PdfPCell(new Phrase(FootPager, fontSmallBold));
        footerPageNocell.setBorder(0);
        footerPageNocell.setPaddingBottom(5);
        footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        footer.addCell(footerPageNocell);
        footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin() - 5, writer.getDirectContent());

    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:Deskera-HRMS    文件:ExportLeavePdfServlet.java   
@Override
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Rectangle page = document.getPageSize();
        PdfPTable footer = new PdfPTable(1);
        footer.setWidthPercentage(100);
        footer.setSpacingBefore(20);
        PdfPCell footerPageNocell = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.computer.generated.payslip.not.require.signature", null, RequestContextUtils.getLocale(request)), fontMediumRegular));
        footerPageNocell.setBorder(0);
        footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        footer.addCell(footerPageNocell);
        footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin()+2 , writer.getDirectContent());

    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:Deskera-HRMS    文件:ExportServlet.java   
private static void addComponyLogo(Document d, HttpServletRequest req) throws ConfigurationException, DocumentException {
    PdfPTable table = new PdfPTable(1);
    imgPath = StorageHandler.GetProfileImgStorePath() + "logo.gif";
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.setWidthPercentage(50);
    PdfPCell cell = null;
    try {
        if(StringUtil.isStandAlone()){
            imgPath = URLUtil.getPageURL(req, "").concat(defaultCompanyImgPath);
        }
        Image img = Image.getInstance(imgPath);
        cell = new PdfPCell(img);
    } catch (Exception e) {
        cell = new PdfPCell(new Paragraph(companyName, fontBig));
    }
    cell.setBorder(0);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    d.add(table);
}
项目:oscar-old    文件: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;
}