Java编辑pdf
来源:互联网 发布:博达软件 编辑:程序博客网 时间:2024/06/11 09:31
/*
* oriPath原始文件路径 genPath写入pdf生成文件路径 x x轴位置 y y轴位置
*/
public void wriPDF(int x, int y,int z, String oriPath, String genPath, String content) throws Exception {
PdfReader reader = new PdfReader(oriPath);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(genPath));
PdfContentByte overContent = stamper.getOverContent(1);
// 添加文字
BaseFont font = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
overContent.beginText();
// 设置字体大小
// content写入文件的内容
String[] contents = content.split("\r\n");
for (String str : contents) {
int n=x;
String[] st=str.split(" ");
if(st.length==3){
overContent.setFontAndSize(font, 10);
}else{
overContent.setFontAndSize(font, 12);
}
for(String s : st){
overContent.showTextAligned(0, s, n, y, 0.0F);
n+=z;
}
y-= 15;
}
overContent.endText();
stamper.close();
reader.close();
}
* oriPath原始文件路径 genPath写入pdf生成文件路径 x x轴位置 y y轴位置
*/
public void wriPDF(int x, int y,int z, String oriPath, String genPath, String content) throws Exception {
PdfReader reader = new PdfReader(oriPath);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(genPath));
PdfContentByte overContent = stamper.getOverContent(1);
// 添加文字
BaseFont font = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
overContent.beginText();
// 设置字体大小
// content写入文件的内容
String[] contents = content.split("\r\n");
for (String str : contents) {
int n=x;
String[] st=str.split(" ");
if(st.length==3){
overContent.setFontAndSize(font, 10);
}else{
overContent.setFontAndSize(font, 12);
}
for(String s : st){
overContent.showTextAligned(0, s, n, y, 0.0F);
n+=z;
}
y-= 15;
}
overContent.endText();
stamper.close();
reader.close();
}
阅读全文
0 0
- Java编辑pdf
- java利用itext编辑pdf
- java利用itext编辑pdf
- java中利用itext编辑pdf
- java中利用itext编辑pdf
- java中利用itext编辑pdf
- 有关java编辑PDF的一些小问题
- ubutnu pdf 编辑工具
- PDF 编辑工具
- PDF页面编辑
- iText编辑Pdf模板
- pdf格式文件怎么编辑
- iText编辑Pdf模板
- 怎么编辑pdf文件
- 编辑pdf的软件
- pdf文件编辑
- 怎样编辑pdf文件
- pdf文件怎么编辑
- maven中端口占用报错
- js构造函数,原型对象,继承 (2)
- C#指定图片添加文字
- springboot-加载自定义的properties文件
- 主从复制、读写分离水平拆分及库表散列
- Java编辑pdf
- oracle数据库用户管理操作(DCL)
- CodeForces
- 常见的简单笔试题却又要小心的题
- Unity2D游戏入门教程(一)宝石迷阵(1)创建项目
- hdu 1018
- 打印当前时间。
- 【C#】身份证识别(三):身份证信息识别
- yolo_v2训练自己的数据出现Obj: 0.000000, No Obj: 0.000000