【问题标题】:How to get PDF coordinates of specific selected area?如何获取特定选定区域的 PDF 坐标?
【发布时间】:2021-06-20 11:52:28
【问题描述】:

我的任务是比较我使用以下库的两个 pdf:

https://github.com/red6/pdfcompare

问题是,我必须忽略 pdf 的某些部分,我需要为此提供坐标。如何获得文档中提到的坐标?我研究过,但使用的所有工具都只显示 x 和 y 坐标,我这里需要 4 个维度。

exclusions: [
    {
        page: 2
        x1: 300 // entries without a unit are in pixels. Pdfs are rendered by default at 300DPI
        y1: 1000
        x2: 550
        y2: 1300
    },
    {
        // page is optional. When not given, the exclusion applies to all pages.
        x1: 130.5mm // entries can also be given in units of cm, mm or pt (DTP-Point defined as 1/72 Inches)
        y1: 3.3cm
        x2: 190mm
        y2: 3.7cm
    },
    {
        page: 7
        // coordinates are optional. When not given, the whole page is excluded.
    }
]

我想忽略 PDF 中的以下内容

谢谢。

【问题讨论】:

  • "我需要 4 个维度" 你需要 2 个点的坐标:一个矩形的左上角和右下角。
  • 谢谢@Olivier,我是新手,你能指导我怎么做吗?
  • 您可以尝试使用 DrawPrintTextLocations.java 示例。

标签: java pdf pdfbox


【解决方案1】:

感谢@Olivier 指导我。我使用 GIMP 加载 PDF,并选择了我想忽略的区域的左上角区域,并复制了该位置。我对右下角做了同样的事情。然后我将右上角粘贴到 x1 和 y1 中,将右下角粘贴到 x2 和 y2 中。现在,它按预期工作。谢谢大家。

随附的屏幕截图显示了我所做的。

upper-left lower-right

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-26
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 2017-02-14
    相关资源
    最近更新 更多