使用PDFBox查找空白空间(矩形)以进行签名字段
当您要使用PDFBox创建可见的签名时,需要创建一个Rectangle2D对象。
Rectangle2d humanRect = new Rectangle2d.float(100,200,150,50);
我想知道是否可以在文档中找到所有白色空间(矩形)(或从第一个/最后一页)一定尺寸(宽度x高)。 我想为我的签名形式选择其中一个职位。
我想在以下示例中使用它:
rectangle2d humanRect = new Rectangle2d.float(fundx,findy,width,height);
>
When you want to create a visible signature using PDFBox you need to create a Rectangle2D object.
Rectangle2D humanRect = new Rectangle2D.Float(100, 200, 150, 50);
I would like to know if it is possible to find all the white spaces(rectangles) in the document(or from the first/last page) of a certain size (width x height).
I would like to choose one of these positions for my signature form.
I would like to use it as in the following example:
Rectangle2D humanRect = new Rectangle2D.Float(foundX, foundY, width, height);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在对问题的评论中已经确认,您本质上正在寻找
freeSpacefinder
和 nofollow noreferrer“>从 to pdfbox。这是此答案的重点:
,
如果要从PDFBox的页面的内容流指令中确定某些内容,通常会根据
pdfstreamengine
或其一个子类创建类。对于不关注文本提取的任何事物,通常是pdfgraphicsStreamEngine
是选择的基类。基于此,我们可以从本质上复制上述itext类的功能:
( freespacefinder )
使用此
freeSpaceFinder
您可以在给定的最小尺寸中,这样的方法:(确定freEspaces 方法
查找
)我们得到:
与Itext变体的类似屏幕截图进行比较,我们看到这里有更多可能的矩形。
这是由于使用字体级别的升华和下降时的ITEXT解决方案时,我们在这里使用各个雕文框框。
As already confirmed in a comment to the question, you essentially are looking for a port of the functionality of the
FreeSpaceFinder
andFreeSpaceFinderExt
classes for iText from this answer to PDFBox. This is the focus of this answer:If you want to determine something from the content stream instructions of a page with PDFBox, you usually will create a class based on
PDFStreamEngine
or one of its subclasses. For anything that's not focusing on text extraction most often thePDFGraphicsStreamEngine
is the base class of choice.Based on that we can essentially copy the functionality of the mentioned iText based classes:
(FreeSpaceFinder)
Using this
FreeSpaceFinder
you can find empty areas with given minimum dimensions in a method like this:(DetermineFreeSpaces method
find
)Applied to the same PDF page as was the iText centric solution with minimum width 200 and height 50, we get:
Comparing to the analogous screen shot for the iText variant, we see that we get more possible rectangles here.
This is due to the iText solution using the font-level ascender and descender while we here use the individual glyph bounding boxes.