将jPedal pdf转换为PDFDocumentGraphics2D的方法

时间:2023-02-09 16:50:38

I use the PdfDecoder class from jPedal to attempting to convert/paint a pdf file to a PDFDocumentGraphics2D object. The PDFDocumentGraphics2D is an extension of javas AWT Graphics class, and part of Apache FOP (http://xmlgraphics.apache.org/fop/).

我使用jPedal中的PdfDecoder类来尝试将pdf文件转换/绘制为PDFDocumentGraphics2D对象。 PDFDocumentGraphics2D是javas AWT Graphics类的扩展,也是Apache FOP(http://xmlgraphics.apache.org/fop/)的一部分。

Is there another way to .paint(...) the pdf onto PDFDocumentGraphics2D except using the commercial-only function renderPageOntoGraphics2D from jPedals PdfDecoder class? I have a feeling it might be done by going through the whole tree of the pdf, and .paint() everything. This seems tedious though, since it's my experience that it is quite hard to get all text, images and forms out of a pdf file by using the PdfDecoder class.

除了使用来自jPedals PdfDecoder类的商业化函数renderPageOntoGraphics2D之外,是否有另一种方法将.paint(...)pdf放到PDFDocumentGraphics2D上?我觉得可以通过遍历pdf的整个树和.paint()所有内容来完成。这似乎很乏味,因为根据我的经验,使用PdfDecoder类很难从pdf文件中获取所有文本,图像和表单。

I am also open for alternative/better ways to read in a pdf file, and painting it onto a PDFDocumentGraphics2D object!

我也是开放的替代/更好的方式来阅读PDF文件,并将其绘制到PDFDocumentGraphics2D对象!

1 个解决方案

#1


0  

You could hack into the main parsing engine in PdfStreamDecoder or implement your own version of the DynamicVectorRenderer JPedal writes to but it is going to be quite a hack.

您可以入侵PdfStreamDecoder中的主要解析引擎或实现您自己的DynamicVectorRenderer JPedal写入版本,但这将是一个非常黑客。

#1


0  

You could hack into the main parsing engine in PdfStreamDecoder or implement your own version of the DynamicVectorRenderer JPedal writes to but it is going to be quite a hack.

您可以入侵PdfStreamDecoder中的主要解析引擎或实现您自己的DynamicVectorRenderer JPedal写入版本,但这将是一个非常黑客。