本文整理汇总了Java中org.apache.pdfbox.util.TextPosition.getTextPos方法的典型用法代码示例。如果您正苦于以下问题:Java TextPosition.getTextPos方法的具体用法?Java TextPosition.getTextPos怎么用?Java TextPosition.getTextPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pdfbox.util.TextPosition
的用法示例。
在下文中一共展示了TextPosition.getTextPos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: strikesThrough
import org.apache.pdfbox.util.TextPosition; //导入方法依赖的package包/类
boolean strikesThrough(TextPosition textPosition)
{
Matrix matrix = textPosition.getTextPos();
// TODO: This is a very simplistic implementation only working for horizontal text without page rotation
// and horizontal rectangular strikeThroughs with p0 at the left bottom and p2 at the right top
// Check if rectangle horizontally matches (at least) the text
if (p0.getX() > matrix.getXPosition() + textPosition.getWidth() * .1f || p2.getX() < matrix.getXPosition() + textPosition.getWidth() * .9f)
return false;
// Check whether rectangle vertically is at the right height to underline
double vertDiff = p0.getY() - matrix.getYPosition();
if (vertDiff < 0 || vertDiff > textPosition.getFont().getFontDescriptor().getAscent() * textPosition.getFontSizeInPt() / 1000.0)
return false;
// Check whether rectangle is small enough to be a line
return Math.abs(p2.getY() - p0.getY()) < 2;
}
示例2: underlines
import org.apache.pdfbox.util.TextPosition; //导入方法依赖的package包/类
boolean underlines(TextPosition textPosition)
{
Matrix matrix = textPosition.getTextPos();
// TODO: This is a very simplistic implementation only working for horizontal text without page rotation
// and horizontal rectangular underlines with p0 at the left bottom and p2 at the right top
// Check if rectangle horizontally matches (at least) the text
if (p0.getX() > matrix.getXPosition() + textPosition.getWidth() * .1f || p2.getX() < matrix.getXPosition() + textPosition.getWidth() * .9f)
return false;
// Check whether rectangle vertically is at the right height to underline
double vertDiff = p0.getY() - matrix.getYPosition();
if (vertDiff > 0 || vertDiff < textPosition.getFont().getFontDescriptor().getDescent() * textPosition.getFontSizeInPt() / 500.0)
return false;
// Check whether rectangle is small enough to be a line
return Math.abs(p2.getY() - p0.getY()) < 2;
}
示例3: isItalic
import org.apache.pdfbox.util.TextPosition; //导入方法依赖的package包/类
public boolean isItalic(TextPosition text) {
if (isItalic(text.getFont().getFontDescriptor())) {
return true;
}
Matrix textPos = text.getTextPos();
if (textPos != null && textPos.getXScale() < textPos.getYScale()) {
return true;
}
if (textPos != null && textPos.getXScale() > textPos.getYScale()) {
return true;
}
return false;
}