📄 pdftestutil.java
字号:
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("-S-",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("-M-",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("-L-",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("-XL-",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("-XXL-",fontCN));
sizeTable.addCell(sizeCell);
//2nd row
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("01",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("34",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("43",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("54",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("5",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeTable.addCell(sizeCell);
//three row
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("33",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("43",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("43",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("54",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("54",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeTable.addCell(sizeCell);
//fourth row
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("52",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("43",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("4",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("4",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("45",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeTable.addCell(sizeCell);
//five row
sizeTable.getDefaultCell().setBorder(1);
sizeCell = new PdfPCell();
sizeCell.setColspan(6);
sizeCell.setBorder(Rectangle.BOTTOM);
sizeTable.addCell(sizeCell);
//six row
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("120",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("90",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("112",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeCell.addElement(new Paragraph("104",fontCN));
sizeTable.addCell(sizeCell);
sizeCell = new PdfPCell();
sizeCell.setBorder(Rectangle.NO_BORDER);
sizeTable.addCell(sizeCell);
table.addCell(sizeTable);//2nd column
PdfPTable numTable = new PdfPTable(1);
numTable.setWidthPercentage(100);
numTable.getDefaultCell().setBorder(0);
numTable.getDefaultCell().setHorizontalAlignment(0);
PdfPCell numCell = new PdfPCell();
numCell.setBorder(Rectangle.NO_BORDER);
numCell.addElement(new Paragraph(" "));
numTable.addCell(numCell);
numCell = new PdfPCell();
numCell.setBorder(Rectangle.NO_BORDER);
paragraph = new Paragraph("136");
paragraph.setAlignment("right");
numCell.addElement(paragraph);
numTable.addCell(numCell);
numCell = new PdfPCell();
numCell.setBorder(Rectangle.NO_BORDER);
paragraph = new Paragraph("194");
paragraph.setAlignment("right");
numCell.addElement(paragraph);
numTable.addCell(numCell);
numCell = new PdfPCell();
numCell.setBorder(Rectangle.NO_BORDER);
paragraph = new Paragraph("96");
paragraph.setAlignment("right");
numCell.addElement(paragraph);
numTable.addCell(numCell);
numTable.getDefaultCell().setBorder(1);
numCell = new PdfPCell();
numCell.setColspan(1);
numCell.setBorder(Rectangle.BOTTOM);
numTable.addCell(numCell);
numTable.getDefaultCell().setHorizontalAlignment(2);
numCell = new PdfPCell();
numCell.setBorder(Rectangle.NO_BORDER);
paragraph = new Paragraph("426");
paragraph.setAlignment("right");
numCell.addElement(paragraph);
numTable.addCell(numCell);
table.addCell(numTable);//three column
PdfPTable orderTable = new PdfPTable(1);
orderTable.setWidthPercentage(100);
orderTable.getDefaultCell().setBorder(0);
orderTable.getDefaultCell().setHorizontalAlignment(2);
PdfPCell orderCell = new PdfPCell();
orderCell.addElement(new Paragraph(" "));
orderCell.setBorder(Rectangle.NO_BORDER);
orderTable.addCell(orderCell);
orderCell = new PdfPCell();
orderCell.setBorder(Rectangle.NO_BORDER);
paragraph = new Paragraph("7.282.80");
paragraph.setAlignment("right");
orderCell.addElement(paragraph);
orderTable.addCell(orderCell);
orderCell = new PdfPCell();
orderCell.setBorder(Rectangle.NO_BORDER);
paragraph = new Paragraph("10.388.70");
paragraph.setAlignment("right");
orderCell.addElement(paragraph);
orderTable.addCell(orderCell);
orderCell = new PdfPCell();
orderCell.setBorder(Rectangle.NO_BORDER);
paragraph = new Paragraph("5.140.80");
paragraph.setAlignment("right");
orderCell.addElement(paragraph);
orderTable.addCell(orderCell);
orderTable.getDefaultCell().setBorder(1);
orderCell = new PdfPCell();
orderCell.setColspan(1);
orderCell.setBorder(Rectangle.BOTTOM);
orderTable.addCell(orderCell);
orderCell = new PdfPCell();
orderCell.setBorder(Rectangle.NO_BORDER);
paragraph = new Paragraph("22.812.30");
paragraph.setAlignment("right");
orderCell.addElement(paragraph);
orderTable.addCell(orderCell);
table.addCell(orderTable);//fourth column
return table;
}
private PdfPTable createHeader(Font fontCN ) throws Exception{
PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(100);
table.setSpacingBefore(3f); //设置标题和第一个表格间的距离.不然会粘在一起
table.getDefaultCell().setBorder(0);
//frist row
PdfPTable headerTable = new PdfPTable(4);
int headerwidths[] = {20, 30, 30,20}; // percentage
headerTable.setWidths(headerwidths);
headerTable.setWidthPercentage(100);
headerTable.setSpacingBefore(3f); //设置标题和第一个表格间的距离.不然会粘在一起
headerTable.getDefaultCell().setBorder(0);
headerTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
PdfPCell cell = new PdfPCell();
paragraph =new Paragraph("订单地区: 厦门",fontCN);
paragraph.setAlignment("left");
cell.addElement(paragraph);
cell.setBorder(Rectangle.NO_BORDER);
headerTable.addCell(cell);
headerTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
cell = new PdfPCell();
paragraph =new Paragraph("出货店号: 169",fontCN);
paragraph.setAlignment("left");
cell.addElement(paragraph);
cell.setBorder(Rectangle.NO_BORDER);
headerTable.addCell(cell);
headerTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
cell = new PdfPCell();
paragraph =new Paragraph("订货店号:207,209,211,219,261,275,276,277,281,408",fontCN);
paragraph.setAlignment("right");
cell.addElement(paragraph);
cell.setColspan(2);
cell.setBorder(Rectangle.NO_BORDER);
headerTable.addCell(cell);
table.addCell(headerTable);
//2nd row
table.getDefaultCell().setBorder(1);
PdfPCell newCell = new PdfPCell();
newCell.setBorder(Rectangle.BOTTOM);
newCell.setColspan(4);
table.addCell(newCell);
//three row
PdfPTable newTable = new PdfPTable(4);
float widths[] = {20, 50, 10,20}; // percentage
//newTable.setWidths();
newTable.setTotalWidth(widths);
newTable.setWidthPercentage(100);
newTable.setSpacingBefore(3f); //设置标题和第一个表格间的距离.不然会粘在一起
newTable.getDefaultCell().setBorder(0);
newTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
newCell = new PdfPCell();
newCell.setBorder(Rectangle.NO_BORDER);
paragraph =new Paragraph("款号",fontCN);
paragraph.setAlignment("left");
newCell.addElement(paragraph);
newTable.addCell(newCell);
newCell = new PdfPCell();
newCell.setBorder(Rectangle.NO_BORDER);
paragraph =new Paragraph("颜色",fontCN);
paragraph.setAlignment("left");
newCell.addElement(paragraph);
newTable.addCell(newCell);
newTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
newCell = new PdfPCell();
newCell.setBorder(Rectangle.NO_BORDER);
paragraph =new Paragraph("数量总数",fontCN);
paragraph.setAlignment("right");
newCell.addElement(paragraph);
newTable.addCell(newCell);
newCell = new PdfPCell();
newCell.setBorder(Rectangle.NO_BORDER);
paragraph =new Paragraph("订单总金额",fontCN);
paragraph.setAlignment("right");
newCell.addElement(paragraph);
newTable.addCell(newCell);
table.addCell(newTable);
//forth row
table.getDefaultCell().setBorder(1);
newCell = new PdfPCell();
newCell.setBorder(Rectangle.BOTTOM);
newCell.setColspan(4);
table.addCell(newCell);
return table;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -