itextpdf 画出医保结算清单PDF
时间: 2023-11-17 21:00:53 浏览: 38
使用itextpdf可以很方便地画出医保结算清单PDF。具体步骤如下:
1.创建一个PDF文档对象。
2.添加页面。
3.添加表格。
4.向表格中添加数据。
5.将PDF文档对象写入输出流中,生成PDF文件。
代码示例:
```java
// 创建PDF文档对象
Document document = new Document();
// 创建输出流
OutputStream outputStream = new FileOutputStream(new File("医保结算清单.pdf"));
// 创建PDF写入器
PdfWriter.getInstance(document, outputStream);
// 打开文档
document.open();
// 添加页面
document.newPage();
// 创建表格
PdfPTable table = new PdfPTable(3);
// 设置表格宽度比例
table.setWidthPercentage(100);
// 添加表头
table.addCell(new PdfPCell(new Phrase("项目名称")));
table.addCell(new PdfPCell(new Phrase("单价")));
table.addCell(new PdfPCell(new Phrase("数量")));
// 添加数据
table.addCell(new PdfPCell(new Phrase("药品A")));
table.addCell(new PdfPCell(new Phrase("10")));
table.addCell(new PdfPCell(new Phrase("2")));
table.addCell(new PdfPCell(new Phrase("药品B")));
table.addCell(new PdfPCell(new Phrase("20")));
table.addCell(new PdfPCell(new Phrase("1")));
// 将表格添加到文档中
document.add(table);
// 关闭文档
document.close();
// 关闭输出流
outputStream.close();
```
相关推荐
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)