如何用pdf中的空填充空空间?使用PDFBox

发布于 2025-01-22 07:14:28 字数 766 浏览 4 评论 0原文

我正在使用Java PDFBox来读取PDF,

这是一个非常长的PDF,其中有40多页,我需要在每个页面上提取100个以上的元素,使用坐标手动进行操作将使我永远。

有没有办法将PDF页面文本排成行,每个空白空间都充满了一个空值?

例如,当我解析此表时:

使用代码:

            PDFTextStripper stripper = new PDFTextStripper();
            stripper.setSortByPosition(true);

            stripper.setStartPage(30);
            stripper.setEndPage(30);
            LOG.info("page 30 \n{}", stripper.getText(document));

我明白了:

016         1 300 
030        17 994        41 629        15 712 
042           676           676 

问题是我无法确定是否只有一个或两个值!

I am using Java PDFBOX to read a pdf

It is a very long pdf with more than 40 pages, and I need to extract more than 100 elements on each page, doing it manually using coordinates would take me forever.

Is there a way to get the pdf page text in rows with each empty space filled with some null value?

When I parse this table for example:
enter image description here

using the code:

            PDFTextStripper stripper = new PDFTextStripper();
            stripper.setSortByPosition(true);

            stripper.setStartPage(30);
            stripper.setEndPage(30);
            LOG.info("page 30 \n{}", stripper.getText(document));

I get this:

016         1 300 
030        17 994        41 629        15 712 
042           676           676 

The problem is that I can't tell if there are just one or two values which are which !!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文