本文整理汇总了Java中org.apache.pdfbox.util.TextPosition.getX方法的典型用法代码示例。如果您正苦于以下问题:Java TextPosition.getX方法的具体用法?Java TextPosition.getX怎么用?Java TextPosition.getX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pdfbox.util.TextPosition
的用法示例。
在下文中一共展示了TextPosition.getX方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CharSegment
import org.apache.pdfbox.util.TextPosition; //导入方法依赖的package包/类
/**
* This will create a TextFragment object from a TextPosition object.
* As of PDFBox 0.7.2, this is the method currently in use, which
* converts co-ordinates back to the original system.
*
* @param tPos - the TextPosition object; pageDim - page dimensions in order to
* convert co-ordinates
* @return The new TextFragment object
*/
public CharSegment(TextPosition tPos, GenericSegment pageDim)
{
super(tPos.getX(),
tPos.getX() + tPos.getWidth(),
pageDim.getY2() - tPos.getY(),
pageDim.getY2() - tPos.getY() + (tPos.getFontSize() * tPos.getYScale()),
tPos.getCharacter(),
tPos.getFont().getBaseFont(),
tPos.getFontSize() * tPos.getYScale());
// uncomment to print the contents of all text fragments to the screen
// System.out.println("Created text fragment: x1: " + tPos.getX() + " x2: " + (tPos.getX() + tPos.getWidth()) + " y1: " + tPos.getY() + " y2: " + (tPos.getY() + (tPos.getFontSize() * tPos.getYScale())) + " Text: " + text + " Font size: " + tPos.getFontSize() + " X Scale: " + tPos.getYScale() + " Y Scale: " + tPos.getYScale());
// todo: trim the name of the font
String fontName = tPos.getFont().getBaseFont();
/*
this.xScale = tPos.getXScale();
this.yScale = tPos.getYScale();
this.widthOfSpace = tPos.getWidthOfSpace();
this.wordSpacing = tPos.getWordSpacing();
*/
}
示例2: TextFragment
import org.apache.pdfbox.util.TextPosition; //导入方法依赖的package包/类
public TextFragment(TextPosition tPos)
{
super(tPos.getX(),
tPos.getX() + (tPos.getWidth()),
tPos.getY(),
tPos.getY() + (tPos.getFontSize() * tPos.getYScale()),
tPos.getCharacter(),
findFontName(tPos.getFont()),
tPos.getFontSize() * tPos.getYScale());
// todo: trim the name of the font
String fontName = tPos.getFont().getBaseFont();
}
示例3: writeLineStart
import org.apache.pdfbox.util.TextPosition; //导入方法依赖的package包/类
@Override
protected void writeLineStart(List<TextPosition> line) {
if (isLineEmpty(line)) {
return;
}
lines++;
float lineY = getFirstTrimmed(line).getY();
if (prevLineY >= 0f) {
incrementOrAdd(lineSpacing, lineY - prevLineY);
}
prevLineY = lineY;
float start = getFirstTrimmed(line).getX();
// leftMargin += start;
incrementOrAdd(leftMargin, start);
TextPosition lastTrimmed = getLastTrimmed(line);
float end = lastTrimmed.getX() + lastTrimmed.getWidth();
// rightMargin += end;
incrementOrAdd(rightMargin, end);
Float fontSize;
for (TextPosition t : line) {
PDFont font = t.getFont();
if (font != null) {
PDFontDescriptor fontDescriptor = font.getFontDescriptor();
if(fontDescriptor != null)
incrementOrAdd(fontWeight, fontDescriptor.getFontWeight());
}
fontSize = t.getFontSizeInPt();
if (fontSize > 0) {
incrementOrAdd(linesFontSize, fontSize);
}
}
}
示例4: parseAlign
import org.apache.pdfbox.util.TextPosition; //导入方法依赖的package包/类
protected void parseAlign(List<TextPosition> line) {
if (line.size() < 1) {
return;
}
float start = -1;
TextPosition firstText = getFirstTrimmed(line);
start = firstText.getX();
if (start == -1 || firstText.getCharacter().trim().isEmpty()) {
return;
}
float end = -1;
TextPosition lastText = getLastTrimmed(line);
end = lastText.getX() + lastText.getWidth();
if (end == -1 || lastText.getCharacter().trim().isEmpty()) {
return;
}
if (start > maxLeftMargin /*&& end < minRightMargin*/) {
// too much lineSpacing
float lineMean = (end + start) / 2;
if (lineMean > minBoxMean && lineMean < maxBoxMean) {
// centered
//align = "center";
} else if (end > minRightMargin) {
// right
//align = "right";
} else {
// System.err.println("Strange line: " + line);
}
}
if (align == null) {
if (start > getAverangeLeftMargin()) {
// intent
startP = false;
}
if (end < minRightMargin) {
// small line
endP = true;
}
}
}