|
@@ -166,7 +166,7 @@ public class PDFUtil {
|
|
|
Document document = new Document(PageSize.A4);// 建立一个Document对象
|
|
|
|
|
|
// 2.建立一个书写器(Writer)与document对象关联
|
|
|
- String uploadPath = "E:/szsm/uploadPath";
|
|
|
+ String uploadPath = "D:/szsm/uploadPath";
|
|
|
File file = new File(uploadPath+File.separator+"PDFDemo.pdf");
|
|
|
file.createNewFile();
|
|
|
|
|
@@ -214,6 +214,219 @@ public class PDFUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public static void generateEPDF(Document document,String name) throws Exception {
|
|
|
+
|
|
|
+ // 段落
|
|
|
+ Paragraph paragraph = new Paragraph("立 邦 随 身 邦 订 单 ", titlefont);
|
|
|
+ paragraph.setAlignment(1); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph.setIndentationLeft(12); //设置左缩进
|
|
|
+ paragraph.setIndentationRight(12); //设置右缩进
|
|
|
+ paragraph.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph.setLeading(20f); //行间距
|
|
|
+ paragraph.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph.setSpacingAfter(10f); //设置段落下空白
|
|
|
+ document.add(paragraph);
|
|
|
+ // 直线
|
|
|
+ Paragraph p1 = new Paragraph();
|
|
|
+ p1.add(new Chunk(new LineSeparator()));
|
|
|
+ document.add(p1);
|
|
|
+ Paragraph paragraph1 = new Paragraph("客户名称: " +name+"", textfont);
|
|
|
+ paragraph1.setLeading(20f); //行间距
|
|
|
+ paragraph1.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph1.setSpacingAfter(10f); //设置段落下空白
|
|
|
+ document.add(paragraph1);
|
|
|
+ // 点线
|
|
|
+ Paragraph p2 = new Paragraph();
|
|
|
+ p2.add(new Chunk(new DottedLineSeparator()));
|
|
|
+ //document.add(p2);
|
|
|
+
|
|
|
+ //添加空行
|
|
|
+ Paragraph p3 = new Paragraph();
|
|
|
+ p3.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ p3.setSpacingAfter(5f); //设置段落下空白
|
|
|
+ // 超链接
|
|
|
+ Anchor anchor = new Anchor("baidu");
|
|
|
+ anchor.setReference("www.baidu.com");
|
|
|
+ //document.add(anchor);
|
|
|
+ // 定位
|
|
|
+ Anchor gotoP = new Anchor("goto");
|
|
|
+ gotoP.setReference("#top");
|
|
|
+ //document.add(gotoP);
|
|
|
+ // 添加图片
|
|
|
+ Image image = Image.getInstance("https://img-blog.csdn.net/20180801174617455?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl8zNzg0ODcxMA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70");
|
|
|
+ image.setAlignment(Image.ALIGN_CENTER);
|
|
|
+ image.scalePercent(40); //依照比例缩放
|
|
|
+ //document.add(image);
|
|
|
+ // 表格
|
|
|
+ PdfPTable table = createTable(new float[] { 80, 80, 80, 80, 80, 80 ,80,80});
|
|
|
+ table.addCell(createCell("采购单信息", headfont, Element.ALIGN_LEFT, 8, false));
|
|
|
+ table.addCell(createCell("采购单号", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("项目名称", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("采购分类", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("申请人", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("申请部门", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("采购员", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("预估总价", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("申请日期", keyfont, Element.ALIGN_CENTER));
|
|
|
+
|
|
|
+
|
|
|
+ table.addCell(createCell("20200813131", textfont));
|
|
|
+ table.addCell(createCell("丁小改测试数据01", textfont));
|
|
|
+ table.addCell(createCell("打印机", textfont));
|
|
|
+ table.addCell(createCell("业务用户1", textfont));
|
|
|
+ table.addCell(createCell("南京工厂", textfont));
|
|
|
+ table.addCell(createCell("cg000005", textfont));
|
|
|
+ table.addCell(createCell("100000", textfont));
|
|
|
+ table.addCell(createCell("2020-08-13", textfont));
|
|
|
+// document.add(table);
|
|
|
+
|
|
|
+ table = createTable(new float[] { 80, 80, 80, 80, 80, 80 ,80});
|
|
|
+ table.addCell(createCell("明细名称", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("采购数量", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("单位", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("预估单价", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("金额小计", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("规格", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("采购时间", keyfont, Element.ALIGN_CENTER));
|
|
|
+
|
|
|
+ table.addCell(createCell("笔记本", textfont));
|
|
|
+ table.addCell(createCell("5", textfont));
|
|
|
+ table.addCell(createCell("台", textfont));
|
|
|
+ table.addCell(createCell("2490", textfont));
|
|
|
+ table.addCell(createCell("12450", textfont));
|
|
|
+ table.addCell(createCell("适配", textfont));
|
|
|
+ table.addCell(createCell("2020-08-13",textfont));
|
|
|
+
|
|
|
+// document.add(table);
|
|
|
+ document.add(p1);
|
|
|
+
|
|
|
+ paragraph = new Paragraph("中标供应商信息", titlefont);
|
|
|
+ paragraph.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph.setIndentationLeft(12); //设置左缩进
|
|
|
+ paragraph.setIndentationRight(12); //设置右缩进
|
|
|
+ paragraph.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph.setLeading(20f); //行间距
|
|
|
+ paragraph.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph.setSpacingAfter(10f); //设置段落下空白
|
|
|
+// document.add(paragraph);
|
|
|
+
|
|
|
+ table = createTable(new float[] { 80, 80, 80, 80});
|
|
|
+ table.addCell(createCell("供应商名称", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("联系人", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("联系方式", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("邮箱", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("测试供应商", textfont));
|
|
|
+ table.addCell(createCell("张三", textfont));
|
|
|
+ table.addCell(createCell("8337971871", textfont));
|
|
|
+ table.addCell(createCell("langss@dgtis.com", textfont));
|
|
|
+// document.add(table);
|
|
|
+
|
|
|
+ table = createTable(new float[] { 80, 80, 80, 80});
|
|
|
+ table.addCell(createCell("报价编号", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("总价", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("报价时间", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("状态", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("P20200812104", textfont));
|
|
|
+ table.addCell(createCell("70000.0", textfont));
|
|
|
+ table.addCell(createCell("2020-08-12", textfont));
|
|
|
+ table.addCell(createCell("已报价", textfont));
|
|
|
+ table.addCell(createCell("P20200812104", textfont));
|
|
|
+ table.addCell(createCell("70000.0", textfont));
|
|
|
+ table.addCell(createCell("2020-08-12", textfont));
|
|
|
+ table.addCell(createCell("已作废", textfont));
|
|
|
+// document.add(table);
|
|
|
+// document.add(p3);
|
|
|
+ table = createTable(new float[] { 80, 80, 80, 80});
|
|
|
+ table.addCell(createCell("供应商名称", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("联系人", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("联系方式", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("邮箱", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("测试供应商", textfont));
|
|
|
+ table.addCell(createCell("张三", textfont));
|
|
|
+ table.addCell(createCell("8337971871", textfont));
|
|
|
+ table.addCell(createCell("langss@dgtis.com", textfont));
|
|
|
+// document.add(table);
|
|
|
+
|
|
|
+ table = createTable(new float[] { 80, 80, 80, 80});
|
|
|
+ table.addCell(createCell("报价编号", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("总价", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("报价时间", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("状态", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("P20200812104", textfont));
|
|
|
+ table.addCell(createCell("70000.0", textfont));
|
|
|
+ table.addCell(createCell("2020-08-12", textfont));
|
|
|
+ table.addCell(createCell("已报价", textfont));
|
|
|
+ table.addCell(createCell("P20200812104", textfont));
|
|
|
+ table.addCell(createCell("70000.0", textfont));
|
|
|
+ table.addCell(createCell("2020-08-12", textfont));
|
|
|
+ table.addCell(createCell("已作废", textfont));
|
|
|
+// document.add(table);
|
|
|
+
|
|
|
+ document.add(p1);//添加实线
|
|
|
+
|
|
|
+ paragraph = new Paragraph("未中标供应商信息", titlefont);
|
|
|
+ paragraph.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
+ paragraph.setIndentationLeft(12); //设置左缩进
|
|
|
+ paragraph.setIndentationRight(12); //设置右缩进
|
|
|
+ paragraph.setFirstLineIndent(24); //设置首行缩进
|
|
|
+ paragraph.setLeading(20f); //行间距
|
|
|
+ paragraph.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph.setSpacingAfter(10f); //设置段落下空白
|
|
|
+ document.add(paragraph);
|
|
|
+ table = createTable(new float[] { 80, 80, 80, 80});
|
|
|
+ table.addCell(createCell("供应商名称", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("联系人", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("联系方式", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("邮箱", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("测试供应商", textfont));
|
|
|
+ table.addCell(createCell("张三", textfont));
|
|
|
+ table.addCell(createCell("8337971871", textfont));
|
|
|
+ table.addCell(createCell("langss@dgtis.com", textfont));
|
|
|
+// document.add(table);
|
|
|
+
|
|
|
+ table = createTable(new float[] { 80, 80, 80, 80});
|
|
|
+ table.addCell(createCell("报价编号", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("总价", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("报价时间", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("状态", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("P20200812104", textfont));
|
|
|
+ table.addCell(createCell("70000.0", textfont));
|
|
|
+ table.addCell(createCell("2020-08-12", textfont));
|
|
|
+ table.addCell(createCell("已报价", textfont));
|
|
|
+ table.addCell(createCell("P20200812104", textfont));
|
|
|
+ table.addCell(createCell("70000.0", textfont));
|
|
|
+ table.addCell(createCell("2020-08-12", textfont));
|
|
|
+ table.addCell(createCell("已作废", textfont));
|
|
|
+// document.add(table);
|
|
|
+
|
|
|
+ table = createTable(new float[] { 80, 80, 80, 80});
|
|
|
+ table.addCell(createCell("供应商名称", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("联系人", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("联系方式", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("邮箱", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("测试供应商", textfont));
|
|
|
+ table.addCell(createCell("张三", textfont));
|
|
|
+ table.addCell(createCell("8337971871", textfont));
|
|
|
+ table.addCell(createCell("langss@dgtis.com", textfont));
|
|
|
+// document.add(table);
|
|
|
+ document.add(p3);
|
|
|
+ table = createTable(new float[] { 80, 80, 80, 80});
|
|
|
+ table.addCell(createCell("报价编号", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("总价", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("报价时间", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("状态", keyfont, Element.ALIGN_CENTER));
|
|
|
+ table.addCell(createCell("P20200812104", textfont));
|
|
|
+ table.addCell(createCell("70000.0", textfont));
|
|
|
+ table.addCell(createCell("2020-08-12", textfont));
|
|
|
+ table.addCell(createCell("已报价", textfont));
|
|
|
+ table.addCell(createCell("P20200812104", textfont));
|
|
|
+ table.addCell(createCell("70000.0", textfont));
|
|
|
+ table.addCell(createCell("2020-08-12", textfont));
|
|
|
+ table.addCell(createCell("已作废", textfont));
|
|
|
+// document.add(table);
|
|
|
+ }
|
|
|
+
|
|
|
// 生成PDF文件
|
|
|
public static void generatePDF(Document document) throws Exception {
|
|
|
|