引用 iTextpdf
使用 maven 引用或下载 jar 包使用,jar 包在文末
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-asian</artifactId>
<version>5.2.0</version>
</dependency>
功能实现
Rectangle pageSize = new Rectangle(PageSize.A4.getWidth(),1000);
Document document = new Document(pageSize,50,50,50,50);
PdfWriter.getInstance(document, new FileOutputStream(outPath+"hallo.pdf"));
document.open();
BaseFont bfChinese = BaseFont.createFont("msyhbd.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
BaseColor titleFontColor = new BaseColor(255, 255, 255);
Font fontChinese = new Font(bfChinese, 8, Font.NORMAL,titleFontColor);
PdfPTable table = new PdfPTable(15);
BaseColor titleBackgroundColor = new BaseColor(32, 200, 197);
BaseColor titleBorderColor = new BaseColor(167, 225, 224);
PdfPCell cell = new PdfPCell(new Paragraph("单位",fontChinese));
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBorderColorRight(titleBorderColor);
cell.setBackgroundColor(titleBackgroundColor);
cell.setBorderWidth(1);
cell.setFixedHeight(19);
cell.setColspan(2);
table.addCell(cell);
document.add(table);
document.close();
资料下载
itextpdf 下载
itext-asian 下载
微软雅黑粗体下载
iText 中文文档下载
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于