|
@@ -1,9 +1,11 @@
|
|
package com.dgtly.wxportal.utils.pdf;
|
|
package com.dgtly.wxportal.utils.pdf;
|
|
|
|
|
|
|
|
+import com.dgtly.wxportal.config.ESignConfig;
|
|
import com.itextpdf.text.*;
|
|
import com.itextpdf.text.*;
|
|
import com.itextpdf.text.pdf.*;
|
|
import com.itextpdf.text.pdf.*;
|
|
import com.itextpdf.text.pdf.draw.DottedLineSeparator;
|
|
import com.itextpdf.text.pdf.draw.DottedLineSeparator;
|
|
import com.itextpdf.text.pdf.draw.LineSeparator;
|
|
import com.itextpdf.text.pdf.draw.LineSeparator;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.FileOutputStream;
|
|
@@ -159,9 +161,13 @@ public class PDFUtil {
|
|
* image.scalePercent(40);//依照比例缩放
|
|
* image.scalePercent(40);//依照比例缩放
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
// main测试
|
|
// main测试
|
|
public static void main(String[] args) throws Exception {
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
+
|
|
try {
|
|
try {
|
|
|
|
+
|
|
// 1.新建document对象
|
|
// 1.新建document对象
|
|
Document document = new Document(PageSize.A4);// 建立一个Document对象
|
|
Document document = new Document(PageSize.A4);// 建立一个Document对象
|
|
|
|
|
|
@@ -227,6 +233,16 @@ public class PDFUtil {
|
|
paragraph.setSpacingBefore(5f); //设置段落上空白
|
|
paragraph.setSpacingBefore(5f); //设置段落上空白
|
|
paragraph.setSpacingAfter(10f); //设置段落下空白
|
|
paragraph.setSpacingAfter(10f); //设置段落下空白
|
|
document.add(paragraph);
|
|
document.add(paragraph);
|
|
|
|
+
|
|
|
|
+ Paragraph paragraph2 = new Paragraph("发呢五分范文芳你得请我的飒",textfont);
|
|
|
|
+ paragraph2.setAlignment(1); //设置文字居中 0靠左 1,居中 2,靠右
|
|
|
|
+ paragraph2.setIndentationLeft(12); //设置左缩进
|
|
|
|
+ paragraph2.setIndentationRight(12); //设置右缩进
|
|
|
|
+ paragraph2.setFirstLineIndent(24); //设置首行缩进
|
|
|
|
+ paragraph2.setLeading(10f); //行间距
|
|
|
|
+ paragraph2.setSpacingBefore(5f); //设置段落上空白
|
|
|
|
+ paragraph2.setSpacingAfter(5f); //设置段落下空白
|
|
|
|
+ document.add(paragraph2);
|
|
// 直线
|
|
// 直线
|
|
Paragraph p1 = new Paragraph();
|
|
Paragraph p1 = new Paragraph();
|
|
p1.add(new Chunk(new LineSeparator()));
|
|
p1.add(new Chunk(new LineSeparator()));
|
|
@@ -234,7 +250,7 @@ public class PDFUtil {
|
|
Paragraph paragraph1 = new Paragraph("客户名称: " +name+"", textfont);
|
|
Paragraph paragraph1 = new Paragraph("客户名称: " +name+"", textfont);
|
|
paragraph1.setLeading(20f); //行间距
|
|
paragraph1.setLeading(20f); //行间距
|
|
paragraph1.setSpacingBefore(5f); //设置段落上空白
|
|
paragraph1.setSpacingBefore(5f); //设置段落上空白
|
|
- paragraph1.setSpacingAfter(10f); //设置段落下空白
|
|
|
|
|
|
+ paragraph1.setSpacingAfter(5f); //设置段落下空白
|
|
document.add(paragraph1);
|
|
document.add(paragraph1);
|
|
// 点线
|
|
// 点线
|
|
Paragraph p2 = new Paragraph();
|
|
Paragraph p2 = new Paragraph();
|
|
@@ -281,25 +297,7 @@ public class PDFUtil {
|
|
table.addCell(createCell("2020-08-13", textfont));
|
|
table.addCell(createCell("2020-08-13", textfont));
|
|
document.add(table);
|
|
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 = new Paragraph("中标供应商信息", titlefont);
|
|
paragraph.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
paragraph.setAlignment(0); //设置文字居中 0靠左 1,居中 2,靠右
|
|
@@ -309,7 +307,7 @@ public class PDFUtil {
|
|
paragraph.setLeading(20f); //行间距
|
|
paragraph.setLeading(20f); //行间距
|
|
paragraph.setSpacingBefore(5f); //设置段落上空白
|
|
paragraph.setSpacingBefore(5f); //设置段落上空白
|
|
paragraph.setSpacingAfter(10f); //设置段落下空白
|
|
paragraph.setSpacingAfter(10f); //设置段落下空白
|
|
-// document.add(paragraph);
|
|
|
|
|
|
+ document.add(paragraph);
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|