本文整理汇总了Java中org.apache.pdfbox.text.TextPosition.getUnicode方法的典型用法代码示例。如果您正苦于以下问题:Java TextPosition.getUnicode方法的具体用法?Java TextPosition.getUnicode怎么用?Java TextPosition.getUnicode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pdfbox.text.TextPosition
的用法示例。
在下文中一共展示了TextPosition.getUnicode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeString
import org.apache.pdfbox.text.TextPosition; //导入方法依赖的package包/类
@Override
protected void writeString(String string, List<TextPosition> textPositions) throws IOException {
for (TextPosition text : textPositions) {
String row =
round(text.getXDirAdj()) + "|" +
round(text.getYDirAdj()) + "|" +
round(text.getFontSize()) + "|" +
round(text.getXScale()) + "|" +
round(text.getHeightDir()) + "|" +
round(text.getWidthOfSpace()) + "|" +
round(text.getWidthDirAdj()) + "|" +
text.getUnicode();
writer.write(System.lineSeparator() + row.trim());
}
}
示例2: newFor
import org.apache.pdfbox.text.TextPosition; //导入方法依赖的package包/类
public static Text newFor(TextPosition tp, PDGraphicsState gs,String text) {
Text t = new Text();
t.x = tp.getXDirAdj();
t.baseline = tp.getYDirAdj();
t.font = tp.getFont();
t.strokeColor = gs.getStrokingColor();
t.nonStrokeColor = gs.getNonStrokingColor();
t.run = tp.getUnicode();
t.width = tp.getWidth();
t.height = tp.getHeight();
t.pointSize = tp.getFontSizeInPt();
t.fontSize = tp.getYScale();
t.tempRun = t.run;
// Bump the width by the word spacing for each space in tp.
/* for (int i=0; i<tp.getCharacter().length(); i++) {
Character c = tp.getCharacter().charAt(i);
if (c.equals(" ")) {
t.width -= tp.getWidthOfSpace();
t.width += tp.getWordSpacing();
}
}
*/
return t;
}
示例3: writeString
import org.apache.pdfbox.text.TextPosition; //导入方法依赖的package包/类
@Override
protected void writeString(String string, List<TextPosition> textPositions) throws IOException
{
for (TextPosition textPosition: textPositions)
{
if (textPosition == null) {
continue;
}
String c = textPosition.getUnicode();
// if c not printable, return
if (!isPrintable(c)) {
continue;
}
Float h = textPosition.getHeightDir();
if (c.equals(NBSP)) { // replace non-breaking space for space
c = " ";
}
float wos = textPosition.getWidthOfSpace();
TextElement te = new TextElement(Utils.round(textPosition.getYDirAdj() - h, 2),
Utils.round(textPosition.getXDirAdj(), 2), Utils.round(textPosition.getWidthDirAdj(), 2),
Utils.round(textPosition.getHeightDir(), 2), textPosition.getFont(), textPosition.getFontSize(), c,
// workaround a possible bug in PDFBox:
// https://issues.apache.org/jira/browse/PDFBOX-1755
wos, textPosition.getDir());
this.minCharWidth = (float) Math.min(this.minCharWidth, te.getWidth());
this.minCharHeight = (float) Math.min(this.minCharHeight, te.getHeight());
this.spatialIndex.add(te);
this.textElements.add(te);
}
}
示例4: checkForValue
import org.apache.pdfbox.text.TextPosition; //导入方法依赖的package包/类
void checkForValue(List<TextPosition> textPositions)
{
for (TextPosition textPosition : textPositions)
{
if (inField(textPosition))
{
float textX = textPosition.getTextMatrix().getTranslateX();
if (textX > lastX + textPosition.getWidthOfSpace() / 2 && value.length() > 0)
value += " ";
value += textPosition.getUnicode();
lastX = textX + textPosition.getWidth();
}
}
}
示例5: charAt
import org.apache.pdfbox.text.TextPosition; //导入方法依赖的package包/类
@Override
public char charAt(int index)
{
TextPosition textPosition = textPositionAt(index);
String text = textPosition.getUnicode();
return text.charAt(0);
}
示例6: writeString
import org.apache.pdfbox.text.TextPosition; //导入方法依赖的package包/类
@Override
protected void writeString(String text, List<TextPosition> textPositions) throws IOException {
super.writeString(text, textPositions);
if (textPositions == null)
return;
StringBuilder term = new StringBuilder();
final List<Rectangle> rects = new ArrayList<>();
for (TextPosition tp : textPositions) {
String str = tp.getUnicode();
if (str.length() > 1) {
handleTerm(term, rects);
term = new StringBuilder();
rects.clear();
addRect(tp, rects);
handleTerm(str, rects);
continue;
}
char c = str.charAt(0);
if (!Character.isLetterOrDigit(c)) {
handleTerm(term, rects);
term = new StringBuilder();
rects.clear();
continue;
}
term.append(c);
addRect(tp, rects);
}
handleTerm(term, rects);
}
示例7: writePage
import org.apache.pdfbox.text.TextPosition; //导入方法依赖的package包/类
protected void writePage() throws IOException {
TextPosition previousCharacter = null;
String currentLine = new String();
for (Iterator i$ = this.charactersByArticle.iterator(); i$.hasNext(); this.endArticle()) {
List textList = (List) i$.next();
for (Object o : textList) {
TextPosition character = (TextPosition) o;
int fontSize = (int) (character.getFontSizeInPt() / character.getFontSize());
int previousFontSize = fontSize;
if (previousCharacter != null) {
previousFontSize = (int) (previousCharacter.getFontSizeInPt() / previousCharacter.getFontSize());
}
if (fontSize != previousFontSize) {
currentLine = currentLine.trim().toLowerCase();
if (previousFontSize >= 7) {
// substance
switch (currentLine) {
case "abciximab (c 7e3b fab)":
currentLine = "abciximab (c7e3b fab)";
break;
}
substance = new SubstanceInteraction();
substance.setSubstance(currentLine);
substances.add(substance);
} else {
// interaction
if (currentLine.contains("interactions en propre")) {
substance.getFamilles().add(substance.getSubstance());
}
int index = currentLine.indexOf(":");
if (index > 0) {
currentLine = currentLine.substring(index + 1);
String[] split = currentLine.split(" \\- ");
for (String tmp : split) {
tmp = tmp.trim();
if (tmp.length() > 1) {
substance.getFamilles().add(tmp);
}
}
}
}
currentLine = new String();
}
currentLine += character.getUnicode();
previousCharacter = character;
}
}
}
示例8: writePage
import org.apache.pdfbox.text.TextPosition; //导入方法依赖的package包/类
protected void writePage() throws IOException {
TextPosition previousCharacter = null;
String currentLine = new String();
for (Iterator i$ = this.charactersByArticle.iterator(); i$.hasNext(); this.endArticle()) {
List textList = (List) i$.next();
for (Object o : textList) {
TextPosition character = (TextPosition) o;
if (previousCharacter != null && character.getFontSize() != previousCharacter.getFontSize()) {
currentLine = currentLine.trim().toLowerCase();
if (previousCharacter.getFontSize() > 7) {
// substance
SubstanceInteraction substance = new SubstanceInteraction();
substances.add(substance);
substance.setSubstance(currentLine);
} else {
// interaction
if (currentLine.contains("interactions en propre")) {
lastSubstance().getInteractions().add(lastSubstance().getSubstance());
}
int index = currentLine.indexOf(":");
if (index > 0) {
currentLine = currentLine.substring(index + 1);
String[] split = currentLine.split(" \\- ");
for (String tmp : split) {
lastSubstance().getInteractions().add(tmp.trim());
}
}
}
currentLine = new String();
}
currentLine += character.getUnicode();
previousCharacter = character;
}
}
}