简体   繁体   English

如何使用java获取pdf中任何给定单词的(x,y width height)

[英]How to get (x,y width height )of any given word in pdf using java

I need to get x,y ,width and height of a given word in pdf. 我需要获取pdf中给定单词的x,y,宽度和高度。 so that later while parsing the same type of file i can fetch value from the co-ordinate itself. 这样,稍后在解析相同类型的文件时,我就可以从坐标本身获取值。 How should i get position of a word from PDF using java. 我应该如何使用Java从PDF中获取单词的位置。

Rectangle rect = new Rectangle(451, 125,100,1); // i need to get this co-ordate for any particular word
stripper.addRegion("class1", rect);
stripper.extractRegions(pdDocument.getPage(0));
System.out.println("stripper "+stripper.getTextForRegion("class1").trim());

我认为您可以利用Apache的PDFBox API并遵循这个类似问题的建议, 该问题专门针对该API编写您所需的代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从给定的宽度和高度的有序1d列表-0,1,2,3,4,5,6…中获取2d坐标(x,y)? - How to get the 2d coordinates(x,y) from an ordered 1d list - 0,1,2,3,4,5,6… with given width & height? 如何在使用 PDF BOX 时获取 pdf 的高度和宽度 - How to get height and width of a pdf while using PDF BOX 如何使用 java 获取图像的高度和宽度? - How to get image height and width using java? 如何使用java在给定新高度和宽度的情况下更改图像大小? - How to change the size of image with given new height and width using java? Java从Slick2D中的图像获取X,Y,宽度,高度线 - Java get X, Y, Width, Height cords from an Image in Slick2D 为什么在Java中矩形的中心(x + width / 2,y + height / 2)? - Why is the center of a rectangle (x+width/2, y+height/2) in Java? 如何使用 Java 获得具有定义宽度的多行富文本字段(任何字体,任何字体大小)的所需高度? - How to get the needed height of a multi line rich-text field (any font, any font size) having defined width using Java? 如何使用itext和java阅读pdf并获取表格单元格高度 - how read pdf using itext and java and get table cell height 如何禁用java.awt.Graphics.fillRect(int x,int y,int width,int height)的效果? - How to disable java.awt.Graphics.fillRect(int x, int y, int width, int height)'s effect? 如何在Java中获取当前监视器的宽度和高度 - How to get the width and height of current monitor in java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM