本文整理汇总了Java中com.itextpdf.text.pdf.PdfPCell.setPadding方法的典型用法代码示例。如果您正苦于以下问题:Java PdfPCell.setPadding方法的具体用法?Java PdfPCell.setPadding怎么用?Java PdfPCell.setPadding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.itextpdf.text.pdf.PdfPCell
的用法示例。
在下文中一共展示了PdfPCell.setPadding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generatePage
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
@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;
}
示例2: buildPdfPCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
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;
}
示例3: createCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
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;
}
示例4: generateSectionTitle
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
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);
}
}
示例5: tableWithPageNumber
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
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;
}
示例6: generateFooter
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
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;
}
示例7: generateAuthorCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private PdfPCell generateAuthorCell() throws IOException, DocumentException {
PdfPCell cell = new PdfPCell(PhraseUtil.phrase(
"............................................\nImię i nazwisko", 15, Font.NORMAL));
cell.setBorder(0);
cell.setPadding(10);
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
cell.setBackgroundColor(BackgroundColorGenerator.DEFAULT_BACKGROUND_COLOR);
return cell;
}
示例8: generateStamp
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private PdfPCell generateStamp() throws IOException, DocumentException, URISyntaxException {
PdfPTable stampTable = new PdfPTable(2);
stampTable.setWidths(new float[] {1,12});
PdfPCell cellIcon = new PdfPCell(ImageUtils.readImageFromResources("icons/check.png"));
cellIcon.setFixedHeight(10);
cellIcon.setPadding(2);
cellIcon.setBorder(0);
cellIcon.setBackgroundColor(backgroundColor);
PdfPCell cellText = new PdfPCell(phrase("Data i pieczątka"));
cellText.setHorizontalAlignment(Element.ALIGN_LEFT);
cellText.setVerticalAlignment(Element.ALIGN_CENTER);
cellText.setBorder(0);
cellText.setBackgroundColor(backgroundColor);
cellText.setPadding(0);
cellText.setPaddingTop(5);
cellText.setPaddingLeft(5);
stampTable.addCell(cellIcon);
stampTable.addCell(cellText);
PdfPCell stampCell = new PdfPCell(stampTable);
stampCell.setPadding(0);
stampCell.setBorder(0);
return stampCell;
}
示例9: generateTile
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
public PdfPCell generateTile() throws IOException, DocumentException {
PdfPCell cell = new PdfPCell(PhraseUtil.phrase("- " + pageNumber + " -"));
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
cell.setVerticalAlignment(Element.ALIGN_CENTER);
cell.setBorder(0);
cell.setPadding(5);
cell.setPaddingRight(10);
cell.setPaddingBottom(9);
cell.setBackgroundColor(backgroundColor);
return cell;
}
示例10: getCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
public PdfPCell getCell(String text, int alignment) {
PdfPCell cell = new PdfPCell(new Phrase(text));
cell.setPadding(0);
cell.setHorizontalAlignment(alignment);
//cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
示例11: getCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
/**
* Returns a formatted cell for the given value.
* @param value cell value
* @return Cell
*/
private PdfPCell getCell(String value)
{
PdfPCell cell = new PdfPCell(new Phrase(new Chunk(StringUtils.trimToEmpty(value), smallFont)));
cell.setVerticalAlignment(Element.ALIGN_TOP);
cell.setLeading(8, 0);
cell.setPadding(2);
return cell;
}
示例12: setStyleRodape
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private void setStyleRodape(PdfPCell cellRodape) {
cellRodape.setBorderWidthBottom(0.5f);
cellRodape.setPadding(2f);
cellRodape.setPaddingLeft(0.8f);
cellRodape.setPaddingRight(0.8f);
}
示例13: cellEspecial
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private static PdfPTable cellEspecial(PdfPCell cellEspcial) {
PdfPTable pTable = new PdfPTable(1);
pTable.addCell(cellEspcial);
cellEspcial.setPadding(3f);
return pTable;
}
示例14: buildPdfPCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private PdfPCell buildPdfPCell(Cell cellInfo,int cellHeight) throws Exception{
CellStyle style=cellInfo.getCellStyle();
CellStyle customStyle=cellInfo.getCustomCellStyle();
CellStyle rowStyle=cellInfo.getRow().getCustomCellStyle();
CellStyle colStyle=cellInfo.getColumn().getCustomCellStyle();
PdfPCell cell=newPdfCell(cellInfo,cellHeight);
cell.setPadding(0);
cell.setBorder(PdfPCell.NO_BORDER);
cell.setCellEvent(new CellBorderEvent(style,customStyle));
int rowSpan=cellInfo.getPageRowSpan();
if(rowSpan>0){
cell.setRowspan(rowSpan);
}
int colSpan=cellInfo.getColSpan();
if(colSpan>0){
cell.setColspan(colSpan);
}
Alignment align=style.getAlign();
if(customStyle!=null && customStyle.getAlign()!=null){
align=customStyle.getAlign();
}
if(rowStyle!=null && rowStyle.getAlign()!=null){
align=rowStyle.getAlign();
}
if(colStyle!=null && colStyle.getAlign()!=null){
align=colStyle.getAlign();
}
if(align!=null){
if(align.equals(Alignment.left)){
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
}else if(align.equals(Alignment.center)){
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
}else if(align.equals(Alignment.right)){
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
}
}
Alignment valign=style.getValign();
if(customStyle!=null && customStyle.getValign()!=null){
valign=customStyle.getValign();
}
if(rowStyle!=null && rowStyle.getValign()!=null){
valign=rowStyle.getValign();
}
if(colStyle!=null && colStyle.getValign()!=null){
valign=colStyle.getValign();
}
if(valign!=null){
if(valign.equals(Alignment.top)){
cell.setVerticalAlignment(Element.ALIGN_TOP);
}else if(valign.equals(Alignment.middle)){
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
}else if(valign.equals(Alignment.bottom)){
cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
}
}
String bgcolor=style.getBgcolor();
if(customStyle!=null && StringUtils.isNotBlank(customStyle.getBgcolor())){
bgcolor=customStyle.getBgcolor();
}
if(rowStyle!=null && StringUtils.isNotBlank(rowStyle.getBgcolor())){
bgcolor=rowStyle.getBgcolor();
}
if(colStyle!=null && StringUtils.isNotBlank(colStyle.getBgcolor())){
bgcolor=colStyle.getBgcolor();
}
if(StringUtils.isNotEmpty(bgcolor)){
String[] colors=bgcolor.split(",");
cell.setBackgroundColor(new BaseColor(Integer.valueOf(colors[0]),Integer.valueOf(colors[1]),Integer.valueOf(colors[2])));
}
return cell;
}
示例15: buildPdfDocument
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void buildPdfDocument(Map<String, Object> model, Document doc,
PdfWriter writer, HttpServletRequest request, HttpServletResponse response)
throws Exception {
// get data model which is passed by the Spring container
List<HrmsLogin> users = (List<HrmsLogin>) model.get("allUsers");
doc.add(new Paragraph("Master List of Users"));
PdfPTable table = new PdfPTable(4);
table.setWidthPercentage(100.0f);
table.setWidths(new float[] {3.0f, 2.0f, 2.0f, 2.0f});
table.setSpacingBefore(10);
// define font for table header row
Font font = FontFactory.getFont(FontFactory.HELVETICA);
font.setColor(BaseColor.WHITE);
// define table header cell
PdfPCell cell = new PdfPCell();
cell.setBackgroundColor(BaseColor.BLUE);
cell.setPadding(5);
// write table header
cell.setPhrase(new Phrase("Employee ID", font));
table.addCell(cell);
cell.setPhrase(new Phrase("Username", font));
table.addCell(cell);
cell.setPhrase(new Phrase("Password", font));
table.addCell(cell);
cell.setPhrase(new Phrase("Role", font));
table.addCell(cell);
// write table row data
for (HrmsLogin user : users) {
table.addCell(user.getHrmsEmployeeDetails().getEmpId()+"");
table.addCell(user.getUsername());
table.addCell(user.getPassword());
table.addCell(user.getRole());
}
doc.add(table);
}