当前位置: 首页>>代码示例>>Java>>正文


Java TextPosition.getTextPos方法代码示例

本文整理汇总了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;
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:17,代码来源:PDFStyledTextStripper.java

示例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;
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:17,代码来源:PDFStyledTextStripper.java

示例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;
}
 
开发者ID:wx5223,项目名称:fileconvert,代码行数:14,代码来源:StatisticParser.java


注:本文中的org.apache.pdfbox.util.TextPosition.getTextPos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。