返回

spring boot 画单

发布时间:2022-10-20 12:09:57 318

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();

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像
精选文章
thumb 中国研究员首次曝光美国国安局顶级后门—“方程式组织”
thumb 俄乌线上战争,网络攻击弥漫着数字硝烟
thumb 从网络安全角度了解俄罗斯入侵乌克兰的相关事件时间线
下一篇
java保存api返回的pdf流文件 2022-10-20 11:51:19