spring boot 画单
Properties properties = System.getProperties();
String labelPath = properties.getProperty("user.dir")+"\\src\\main\\resources\\pdf\\"+jumiaCreateLabelRequest.getTrackNumber()+".pdf";
File file = new File(labelPath);
PdfDocument pdf = null;
try {
pdf = new PdfDocument(new PdfWriter(file));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Document document = new Document(pdf,new PageSize(283.0F, 283.0F));
document.setMargins(5f, 5f, 5f, 5f);
Table table = new Table(2);
table.setWidth(273.0f);
table.setTextAlignment(TextAlignment.CENTER).setHorizontalAlignment(HorizontalAlignment.CENTER);
Border border = new SolidBorder(0.0f);
Border border1 = new SolidBorder(0.0f);
Cell cell1 = new Cell(1,2);
cell1.setBorder(border);
cell1.setHeight(30f);
cell1.setPaddingTop(5.0f);
cell1.add(new Paragraph("Provider : CLEVY"));
table.addCell(cell1);
Cell cell2 = new Cell(1,2);
cell2.setBorder(border);
cell2.setHeight(30f);
cell2.setPaddingTop(5.0f);
cell2.add(new Paragraph("Package Type : ECONOMY POSTAL"));
table.addCell(cell2);
Cell cell3 = new Cell(1,2);
cell3.setBorder(border);
cell3.setHeight(30f);
cell3.setPaddingTop(5.0f);
cell3.add(new Paragraph("Destination : "+jumiaCreateLabelRequest.getCountry()));
table.addCell(cell3);
Cell cell21 = new Cell(1,1);
cell21.setBorder(border);
cell21.setHeight(60f);
cell21.setPaddingTop(10.0f);
cell21.add(new Paragraph("Parcel Number"));
table.addCell(cell21);
Barcode128 barcode128 = new Barcode128(pdf);
barcode128.setCode(jumiaCreateLabelRequest.getTrackNumber());
barcode128.setCodeType(Barcode128.CODE128);
// barcode128.setBarHeight(50.0f);
Image code128Image = new Image(barcode128.createFormXObject(pdf)).setAutoScale(true);
Cell cell22 = new Cell(1,1);
cell22.setBorder(border);
cell22.setHeight(60f);
cell22.setPaddingTop(10.0f);
cell22.setPaddingLeft(15f);
cell22.setPaddingRight(15f);
cell22.add(code128Image);
table.addCell(cell22);
Cell cell23 = new Cell(1,1);
cell23.setBorder(border);
cell23.setHeight(60f);
cell23.setPaddingTop(10.0f);
cell23.add(new Paragraph("Order Number"));
table.addCell(cell23);
Barcode128 barcode1281 = new Barcode128(pdf);
barcode1281.setCode(jumiaCreateLabelRequest.getPlatformId());
barcode1281.setCodeType(Barcode128.CODE128);
Image code128Image1 = new Image(barcode1281.createFormXObject(pdf)).setAutoScale(true);
Cell cell24 = new Cell(1,1);
cell24.setBorder(border);
cell24.setHeight(60f);
cell24.setPaddingTop(10.0f);
cell24.setPaddingLeft(15f);
cell24.setPaddingRight(15f);
cell24.add(code128Image1);
table.addCell(cell24);
document.add(table);
document.close();
return file.getPath();