本文整理汇总了Java中com.lowagie.text.pdf.PdfPTable.addCell方法的典型用法代码示例。如果您正苦于以下问题:Java PdfPTable.addCell方法的具体用法?Java PdfPTable.addCell怎么用?Java PdfPTable.addCell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.pdf.PdfPTable
的用法示例。
在下文中一共展示了PdfPTable.addCell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
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);
}
示例2: insertTable_TextRow
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
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 );
}
示例3: onEndPage
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
@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);
}
}
示例4: buildPdfDocument
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
@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);
}
示例5: createNeedHeader
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
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;
}
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:18,代码来源:SummaryOfActionsAndCommentsReportGenerator.java
示例6: writeCampos
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
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);
}
示例7: writeGraph
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
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));
}
}
示例8: insertTable_HiddenValue
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
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 );
}
示例9: addCell_WithTextField
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
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 );
}
示例10: addCell_WithDropDownListField
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
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 );
}
示例11: addResultExample
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
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);
}
示例12: onEndPage
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
@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);
}
}
示例13: addComponyLogo
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
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);
}
示例14: buildTable
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
public PdfPTable buildTable() {
if (rows.isEmpty())
return new PdfPTable(1);
int ncol = 0;
ArrayList c0 = (ArrayList)rows.get(0);
for (int k = 0; k < c0.size(); ++k) {
ncol += ((PdfPCell)c0.get(k)).getColspan();
}
PdfPTable table = new PdfPTable(ncol);
String width = (String)props.get("width");
if (width == null)
table.setWidthPercentage(100);
else {
if (width.endsWith("%"))
table.setWidthPercentage(Float.parseFloat(width.substring(0, width.length() - 1)));
else {
table.setTotalWidth(Float.parseFloat(width));
table.setLockedWidth(true);
}
}
for (int row = 0; row < rows.size(); ++row) {
ArrayList col = (ArrayList)rows.get(row);
for (int k = 0; k < col.size(); ++k) {
table.addCell((PdfPCell)col.get(k));
}
}
return table;
}
示例15: addCell_WithRadioButton
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
@SuppressWarnings( "unused" )
private void addCell_WithRadioButton( PdfPTable table, PdfWriter writer, PdfPCell cell, String strfldName )
{
PdfFormField radiogroupField = PdfFormField.createRadioButton( writer, true );
radiogroupField.setFieldName( strfldName );
cell.setCellEvent( new PdfFieldCell( radiogroupField, new String[]{ "Yes", "No", "null" }, new String[]{
"true", "false", "" }, "", 30.0f, PdfDataEntryFormUtil.UNITSIZE_DEFAULT, PdfFieldCell.TYPE_RADIOBUTTON, writer ) );
table.addCell( cell );
writer.addAnnotation( radiogroupField );
}