|
@@ -1,6 +1,7 @@
|
|
|
package com.dgtly.wxportal.utils.pdf;
|
|
|
|
|
|
-import com.dgtly.wxportal.config.ESignConfig;
|
|
|
+import com.dgtly.system.domain.MetaHanaSalesOrder;
|
|
|
+import com.dgtly.system.service.IMetaHanaSalesOrderService;
|
|
|
import com.itextpdf.text.*;
|
|
|
import com.itextpdf.text.pdf.*;
|
|
|
import com.itextpdf.text.pdf.draw.DottedLineSeparator;
|
|
@@ -9,6 +10,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
+import java.math.BigInteger;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @description: PDF相关处理
|
|
|
* @author: qxm
|
|
@@ -162,7 +166,6 @@ public class PDFUtil {
|
|
|
*/
|
|
|
|
|
|
|
|
|
-
|
|
|
// main测试
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
@@ -182,14 +185,15 @@ public class PDFUtil {
|
|
|
|
|
|
// 3.打开文档
|
|
|
document.open();
|
|
|
- document.addTitle("E 签 宝 租 铺 合 同 ");// 标题
|
|
|
+ document.addTitle("随 身 邦 收 货 单");// 标题
|
|
|
document.addAuthor("");// 作者
|
|
|
document.addSubject("");// 主题
|
|
|
document.addKeywords("");// 关键字
|
|
|
document.addCreator("");// 创建者
|
|
|
|
|
|
+
|
|
|
// 4.向文档中添加内容
|
|
|
- PDFUtil.generateEPDF(document,"XXX公司");
|
|
|
+ PDFUtil.generateEPDF(document,"XXX公司",null,null);
|
|
|
|
|
|
// 5.关闭文档
|
|
|
document.close();
|
|
@@ -201,6 +205,7 @@ public class PDFUtil {
|
|
|
// 定义全局的字体静态变量
|
|
|
private static Font titlefont;
|
|
|
private static Font headfont;
|
|
|
+ private static Font namefont;
|
|
|
private static Font keyfont;
|
|
|
private static Font textfont;
|
|
|
// 最大宽度
|
|
@@ -213,6 +218,7 @@ public class PDFUtil {
|
|
|
titlefont = new Font(bfChinese, 16, Font.BOLD);
|
|
|
headfont = new Font(bfChinese, 14, Font.BOLD);
|
|
|
keyfont = new Font(bfChinese, 10, Font.BOLD);
|
|
|
+ namefont = new Font(bfChinese, 12, Font.BOLD);
|
|
|
textfont = new Font(bfChinese, 10, Font.NORMAL);
|
|
|
|
|
|
} catch (Exception e) {
|
|
@@ -221,10 +227,11 @@ public class PDFUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static void generateEPDF(Document document,String name) throws Exception {
|
|
|
|
|
|
+
|
|
|
+ public static void generateEPDF(Document document,String name,String docNumber,List<MetaHanaSalesOrder> metaHanaSalesOrders) throws Exception {
|
|
|
// 段落
|
|
|
- Paragraph paragraph = new Paragraph("立 邦 随 身 邦 订 单 ", titlefont);
|
|
|
+ Paragraph paragraph = new Paragraph("立 邦 随 身 邦 收 货 单", titlefont);
|
|
|
paragraph.setAlignment(1); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
paragraph.setIndentationLeft(12); //设置左缩进
|
|
|
paragraph.setIndentationRight(12); //设置右缩进
|
|
@@ -234,7 +241,7 @@ public class PDFUtil {
|
|
|
paragraph.setSpacingAfter(10f); //设置段落下空白
|
|
|
document.add(paragraph);
|
|
|
|
|
|
- Paragraph paragraph2 = new Paragraph("发呢五分范文芳你得请我的飒",textfont);
|
|
|
+ /*Paragraph paragraph2 = new Paragraph("发呢五分范文芳你得请我的飒",textfont);
|
|
|
paragraph2.setAlignment(1); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
paragraph2.setIndentationLeft(12); //设置左缩进
|
|
|
paragraph2.setIndentationRight(12); //设置右缩进
|
|
@@ -242,16 +249,22 @@ public class PDFUtil {
|
|
|
paragraph2.setLeading(10f); //行间距
|
|
|
paragraph2.setSpacingBefore(5f); //设置段落上空白
|
|
|
paragraph2.setSpacingAfter(5f); //设置段落下空白
|
|
|
- document.add(paragraph2);
|
|
|
+ document.add(paragraph2);*/
|
|
|
// 直线
|
|
|
Paragraph p1 = new Paragraph();
|
|
|
p1.add(new Chunk(new LineSeparator()));
|
|
|
document.add(p1);
|
|
|
- Paragraph paragraph1 = new Paragraph("客户名称: " +name+"", textfont);
|
|
|
+ Paragraph paragraph1 = new Paragraph("客户名称: " +name+" " +
|
|
|
+ " 订单号: " +docNumber+"", namefont);
|
|
|
paragraph1.setLeading(20f); //行间距
|
|
|
paragraph1.setSpacingBefore(5f); //设置段落上空白
|
|
|
paragraph1.setSpacingAfter(5f); //设置段落下空白
|
|
|
document.add(paragraph1);
|
|
|
+ /*Paragraph paragraphNumber = new Paragraph("订单号: " +docNumber+"", textfont);
|
|
|
+ paragraphNumber.setLeading(20f); //行间距
|
|
|
+ paragraphNumber.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraphNumber.setSpacingAfter(5f); //设置段落下空白
|
|
|
+ document.add(paragraphNumber);*/
|
|
|
// 点线
|
|
|
Paragraph p2 = new Paragraph();
|
|
|
p2.add(new Chunk(new DottedLineSeparator()));
|
|
@@ -275,39 +288,30 @@ public class PDFUtil {
|
|
|
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);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- paragraph = new Paragraph("中标供应商信息", titlefont);
|
|
|
+ PdfPTable table = createTable(new float[] { 100, 80, 80});
|
|
|
+ table.addCell(createCell("物品明细", headfont, Element.ALIGN_CENTER, 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));
|
|
|
+ for (MetaHanaSalesOrder metaHanaSalesOrder1:metaHanaSalesOrders) {
|
|
|
+ table.addCell(createCell(metaHanaSalesOrder1.getMaterialName(), textfont));
|
|
|
+ table.addCell(createCell(metaHanaSalesOrder1.getSizeDim(), textfont));
|
|
|
+ table.addCell(createCell(metaHanaSalesOrder1.getDeliverQty().toString(), textfont));
|
|
|
+ }
|
|
|
+ document.add(table);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ paragraph = new Paragraph("收货单位及经办人(盖章):", namefont);
|
|
|
paragraph.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
- paragraph.setIndentationLeft(12); //设置左缩进
|
|
|
- paragraph.setIndentationRight(12); //设置右缩进
|
|
|
- paragraph.setFirstLineIndent(24); //设置首行缩进
|
|
|
paragraph.setLeading(20f); //行间距
|
|
|
- paragraph.setSpacingBefore(5f); //设置段落上空白
|
|
|
+ paragraph.setSpacingBefore(10f); //设置段落上空白
|
|
|
paragraph.setSpacingAfter(10f); //设置段落下空白
|
|
|
- document.add(paragraph);
|
|
|
+ document.add(paragraph);
|
|
|
|
|
|
|
|
|
}
|