嗨,我有一个用例可以在文本旋转90和180度时在页面中找到文本的(x1,y1)(x2,y2)值。
当文本处于0度和180度时,我可以找到这些值。
因此,这个想法是从PDFBox使用PDStreamEngine类并从同一类中覆盖方法,并使用它们来查找x1,y1,x2,y2值,
对于上述代码,我在文本为0时正确获得值和180度。
以下
IE文本为0度
(x1 = 31,y1 = 726,x2 = 122,y2 = 744)
当文本为180度时
(x1 = 122,y1 = 744,x2 = 31,y2 = 726)
我得到了上述值。
但是,当我将文本旋转到90度时,旋转文本 pdf ,我将这些值作为(x1 = 22,y1 = 660,x2 = 22 y2 = 740)
在这里,我们可以看到x1和x2值相同。
在其时如何找到文本的x1和x2值旋转90度和270度吗?
我通过使用以下代码片段我也想到使用文本置换“ https://paste-code/bdhr”
我也想过使用文本置换“ printword“方法如此,这将是解决方案,找到x1,y1,x2,y2值。
x1 = Double.valueOf(text.getYDirAdj());
y1 = Double.valueOf(text.getXDirAdj());
x2 = x1 - text.getHeight();
y2 = y1 + text.getWidth();
示例的任何代码片段都将有帮助。
谢谢
Tejas
Hi I have an Use case to find the (x1, y1) (x2, Y2) values of the text in a page when the text is rotated 90 and 180 degree.
I am able to find these values when the text is at 0 degrees and 180 degrees.
So the idea is to use the PDStreamengine class from the PDFBOX and overriding the method from the same class and using them to find the x1,y1,x2,y2 values ,
For the above code i am getting the values properly when the text is 0 and 180 degree.
for the following pdf
i.e when the text is 0 degree
(x1 =31 , y1 =726 , x2 =122 , y2 = 744 )
when the text is 180 degree
(x1 = 122, y1 = 744, x2 = 31, y2 = 726)
i am getting the above values.
but when i rotate the text to 90 degree, Rotated text PDF,I am getting the values as (x1 =22 , y1 =660 , x2 =22 y2 = 740)
Here we can see Both the x1 and X2 Values are same.
how can we Find the X1 and X2 values of a text when it is rotated 90 degree and 270 Degree ?
I got above mentioned values by using the following code snippet
I have also thought of using the TextPosition "printWord" method so, will that be a solution find the x1,y1,x2,y2 values.
x1 = Double.valueOf(text.getYDirAdj());
y1 = Double.valueOf(text.getXDirAdj());
x2 = x1 - text.getHeight();
y2 = y1 + text.getWidth();
And any code snippet with the example will be helpfull.
Thanks
Tejas
发布评论