我想使用PDInlineImage
将图像添加到现有的PDF文档中,但是不显示结果图像,我的代码如下:
PDPageContentStream contentStream = new PDPageContentStream(document, document.getPage(0), PDPageContentStream.AppendMode.APPEND, true, true);
byte[] bytes = FileUtils.readFileToByteArray(new File("C:\\Users\\Administrator\\Desktop\\1.png"));
COSDictionary cosDictionary = new COSDictionary();
PDInlineImage inlineImage = new PDInlineImage(cosDictionary,bytes,document.getPage(0).getResources());
inlineImage.setStencil(true);
inlineImage.setWidth(100);
inlineImage.setHeight(100);
inlineImage.setInterpolate(true);
contentStream.drawImage(inlineImage, 300,90);
contentStream.close();