public void test2() throws IOException {
String pdfPath = "/Users/zhouyang/Desktop/pdf.pdf";
String pdfPath1 = "/Users/zhouyang/Desktop/pdf1.pdf";
String logoPath = "/Users/zhouyang/Desktop/sysush_logo.jpeg";
File file = new File(pdfPath);
PDDocument doc = PDDocument.load(file);
PDPage page = doc.getPage(0);
PDImageXObject pdImage = PDImageXObject.createFromFile(logoPath,doc);
PDPageContentStream contents = new PDPageContentStream(doc, page, PDPageContentStream.AppendMode.APPEND,false,false);
contents.drawImage(pdImage, 200, 700, 200, 50);
contents.close();
doc.save(pdfPath1);
doc.close();
}
标签:zhouyang,PDPageContentStream,String,doc,Desktop,添加,pdfbox,contents,图片
From: https://www.cnblogs.com/zhouyang209117/p/17736157.html