如何使用iText在文本下插入图像作为PDF背景?
发布时间:2021-03-18 17:13:39 所属栏目:MsSql教程 来源:网络整理
导读:我需要一些示例代码将图像作为pdf背景插入,是否有这种示例代码? 我已经写好了文本,然后我需要在文本下插入一个图像. 解决方法 我想你正在寻找用PDF标记页面的水.请查看下面的代码.您也可以使用Watermarker类. PdfReader reader = new PdfReader("text.pdf");
|
我需要一些示例代码将图像作为pdf背景插入,是否有这种示例代码?
解决方法我想你正在寻找用PDF标记页面的水.请查看下面的代码.您也可以使用Watermarker类.PdfReader reader = new PdfReader("text.pdf");
int n = reader.getNumberOfPages();
// Create a stamper that will copy the document to a new file
PdfStamper stamp = new PdfStamper(reader,new FileOutputStream("text1.pdf"));
int i = 1;
PdfContentByte under;
PdfContentByte over;
Image img = Image.getInstance("watermark.jpg");
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,BaseFont.WINANSI,BaseFont.EMBEDDED);
img.setAbsolutePosition(200,400);
while (i < n)
{
// Watermark under the existing page
under = stamp.getUnderContent(i);
under.addImage(img);
// Text over the existing page
over = stamp.getOverContent(i);
over.beginText();
over.setFontAndSize(bf,18);
over.showText("page " + i);
over.endText();
i++;
}
stamp.close();
问候,阿卜杜勒·奥拉卡拉 (编辑:天瑞地安资讯网_黄海网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 你能在SQL中定义“文字”表吗?
- sql-server – 外部应用vs左连接性能
- sql的存储过程定义有哪些方法,你知道几种?
- 带有last_insert_id()的Mysql多行插入 – 选择语句
- 数据库设计 – 在具有缩写表名的表中为每个字段名添加前缀是
- alter table alter SQL的SQL Server性能更改数据类型
- iis-7 – .NET 3.5,IIS 7,SQL Server 2008托管
- sql 中rand函数怎样用?sql怎样获取区间随机数?
- sql-server – SQL Server 2008:找出表中的主键/外键?
- 如何从SQL Server中的分组值返回动态列(存储过程)
站长推荐
热点阅读


