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


Java TextPosition.getUnicode方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:robinhowlett,项目名称:chart-parser,代码行数:17,代码来源:ChartStripper.java

示例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;
	}
 
开发者ID:TekstoSense,项目名称:pdf-segmenter,代码行数:26,代码来源:Text.java

示例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);
    }
}
 
开发者ID:redmyers,项目名称:484_P7_1-Java,代码行数:39,代码来源:TextStripper.java

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

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

示例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);
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:30,代码来源:PDFBoxHighlighter.java

示例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;
        }
    }
}
 
开发者ID:Ellixo,项目名称:MedicamentDB,代码行数:60,代码来源:InteractionService.java

示例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;
        }
    }
}
 
开发者ID:Ellixo,项目名称:MedicamentDB,代码行数:46,代码来源:PDFTest.java


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