引入itext7
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext7-core</artifactId>
<version>7.1.3</version>
<type>pom</type>
</dependency>
第一种:导出地址在当前目录
public class CreatePdf {
public static void main(String[] args) throws Exception{
List<ExportBean> beanList = new ArrayList<>();
ExportBean bean = new ExportBean();
bean.setNo(1);
bean.setDate("20200426");
bean.setSource("I系");
beanList.add(bean);
try {
PdfDocument pdfDoc = new PdfDocument(
new PdfWriter(System.getProperty("user.dir") + "\\DatabaseDesign.pdf"));
Document doc = new Document(pdfDoc);
PdfFont sysFont = PdfFontFactory.createFont("STSongStd-Light", "UniGB-UCS2-H", false);
Table table = new Table(8).setWidth(UnitValue.createPercentValue(100));
table.addCell(new Cell().