公司最近需要进行图片内容动态添加数据需求
boolean flag = PDFReader.createStringMark(“C:\Users\zhangwp\Desktop\1.jpg”, “CALG”,“C:\Users\zhangwp\Desktop\12.jpg”);
System.out.println(flag);
具体内容位置等根据需求调试
/**
* 给图片添加文字内容
* @param filePath 原图路径
* @param markContent 文字内容
* @param outPath 添加文字内容的图片存放路径地址
* @param flag 可以根据flag值,给图片设置具体值
*/
public static void createStringMark(String filePath,String markContent,String outPath,Integer flag) {
ImageIcon imgIcon = new ImageIcon(filePath);
Image theImg = imgIcon.getImage();
int width = theImg.getWidth(null) == -1 ? 200 : theImg.getWidth(null);
int height = theImg.getHeight(null) == -1 ? 200 : theImg.getHeight(null);
// System.out.println(width);
// System.out.println(height);
// System.out.println(theImg);
BufferedImage bimage = new BufferedImage</

本文介绍了如何使用Java进行图片内容的动态添加,特别是在公司项目中处理图片数据需求的场景。通过PDFReader类的createStringMark方法,可以将指定的文字添加到图片上,例如将文字'CALG'添加到1.jpg并输出结果到12.jpg。具体的位置调整和应用可以根据实际需求进行调试。
最低0.47元/天 解锁文章

1438

被折叠的 条评论
为什么被折叠?



