java-将BufferedImage添加到PDFBox 2.0文档
作者:互联网
第一次海报,和我一起…
我有两个问题.首先,我想知道如何使用BufferedImage将图像添加到PDFBox 2.0文档.在这里提出的问题:Add BufferedImage to PDFBox document
此后,PDFBox整体排除了PDJpeg类和xobject部分.
其次,如果有人已经问过这个问题并且已经回答了,但是答案已过时;更新/联系这两个问题的最佳方法是什么? (我没有任何要点,所以我无法发表评论).
解决方法:
PDFBox has since excluded the PDJpeg class and the xobject section as a whole.
在版本2的开发过程中,确实存在很多重构(以及重构,重构等),而且这种重构通常不仅仅局限于软件包的更改.通常,现在某些功能在哪里并不明显.
但是,可以将基本功能(如将BufferedImage添加到文档中)视为不会丢失.
现在有JPEGFactory,它提供了从BufferedImage创建图像XObject的方法,尤其是:
/**
* Creates a new JPEG Image XObject from a Buffered Image.
* @param document the document where the image will be created
* @param image the buffered image to embed
* @return a new Image XObject
* @throws IOException if the JPEG data cannot be written
*/
public static PDImageXObject createFromImage(PDDocument document, BufferedImage image)
/**
* Creates a new JPEG Image XObject from a Buffered Image and a given quality.
* The image will be created at 72 DPI.
* @param document the document where the image will be created
* @param image the buffered image to embed
* @param quality the desired JPEG compression quality
* @return a new Image XObject
* @throws IOException if the JPEG data cannot be written
*/
public static PDImageXObject createFromImage(PDDocument document, BufferedImage image, float quality)
/**
* Creates a new JPEG Image XObject from a Buffered Image, a given quality and DPI.
* @param document the document where the image will be created
* @param image the buffered image to embed
* @param quality the desired JPEG compression quality
* @param dpi the desired DPI (resolution) of the JPEG
* @return a new Image XObject
* @throws IOException if the JPEG data cannot be written
*/
public static PDImageXObject createFromImage(PDDocument document, BufferedImage image, float quality, int dpi)
标签:jfreechart,bufferedimage,pdfbox,java 来源: https://codeday.me/bug/20191027/1942442.html