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


Java TextPosition.getFontSizeInPt方法代码示例

本文整理汇总了Java中org.apache.pdfbox.text.TextPosition.getFontSizeInPt方法的典型用法代码示例。如果您正苦于以下问题:Java TextPosition.getFontSizeInPt方法的具体用法?Java TextPosition.getFontSizeInPt怎么用?Java TextPosition.getFontSizeInPt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.pdfbox.text.TextPosition的用法示例。


在下文中一共展示了TextPosition.getFontSizeInPt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: TextMetrics

import org.apache.pdfbox.text.TextPosition; //导入方法依赖的package包/类
public TextMetrics(TextPosition tp)
{
    x = tp.getX();
    baseline = tp.getY();
    font = tp.getFont();
    width = tp.getWidth();
    height = tp.getHeight();
    pointSize = tp.getFontSizeInPt();
    fontSize = tp.getYScale();
    ascent = getAscent();
    descent = getDescent();
}
 
开发者ID:radkovo,项目名称:Pdf2Dom,代码行数:13,代码来源:TextMetrics.java

示例3: toPDFToken

import org.apache.pdfbox.text.TextPosition; //导入方法依赖的package包/类
public PDFToken toPDFToken() {
  val builder = PDFToken.builder();
  String tokenText = textPositions.stream().map(TextPosition::getUnicode).collect(Collectors.joining(""));
  // HACK(aria42) assumes left-to-right text
  TextPosition firstTP = textPositions.get(0);
  PDFont pdFont = firstTP.getFont();
  val desc = pdFont.getFontDescriptor();
  String fontFamily = desc == null ? PDFFontMetrics.UNKNWON_FONT_FAMILY : desc.getFontName();
  float ptSize = firstTP.getFontSizeInPt();
  //HACK(ddowney): it appears that sometimes (maybe when half-pt font sizes are used), pdfbox 2.0 will multiply
  //  all of the true font sizes by 10.  If we detect this is likely, we divide font size by ten:
  if(ptSize > 45.0f)
    ptSize /= 10.0f;
  //HACK(ddowney): ensure unique sizes get unique names/objects:
  fontFamily += "_" + ptSize + "_" + firstTP.getWidthOfSpace();
  val fontMetrics = PDFFontMetrics.of(fontFamily, ptSize, firstTP.getWidthOfSpace());
  builder.fontMetrics(fontMetrics);

  float minX = Float.POSITIVE_INFINITY;
  float maxX = Float.NEGATIVE_INFINITY;
  float minY = Float.POSITIVE_INFINITY;
  float maxY = Float.NEGATIVE_INFINITY;
  for (TextPosition tp : textPositions) {
    float x0 = tp.getX();
    if (x0 < minX) {
      minX = x0;
    }
    float x1 = x0 + tp.getWidth();
    if (x1 > maxX) {
      maxX = x1;
    }
    float y0 = tp.getY() - tp.getHeight(); //getY returns the bottom-left
    if (y0 < minY) {
      minY = y0;
    }
    float y1 = tp.getY();
    if (y1 > maxY) {
      maxY = y1;
    }
  }
  FloatList bounds = FloatArrayList.newListWith(minX, minY, maxX, maxY);
  builder.bounds(bounds);
  tokenText = discardSuperscripts(tokenText, bounds);
  // separate ligands
  tokenText = Normalizer.normalize(tokenText, Normalizer.Form.NFKC);
  builder.token(tokenText);
  return builder.build();
}
 
开发者ID:allenai,项目名称:science-parse,代码行数:49,代码来源:PDFExtractor.java

示例4: 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


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