itext 如何让图片放在最上面
发布网友
发布时间:2022-04-20 14:45
我来回答
共1个回答
热心网友
时间:2023-06-23 22:40
Image img = Image.getInstance("watermark.jpg");
PdfReader reader = new PdfReader(filename);
PdfStamper stamp = new PdfStamper(reader,
new FileOutputStream(newFilename));
PdfContentByte under;
int numPages = reader.getNumberOfPages();
int count = 0;
while (count < numPages)
{
count++;
under = stamp.getOverContent(count);
under.addImage(img);
}
stamp.close();
参考资料:http://blog.rubypdf.com