• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Operator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.pdfbox.contentstream.operator.Operator的典型用法代码示例。如果您正苦于以下问题:Java Operator类的具体用法?Java Operator怎么用?Java Operator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Operator类属于org.apache.pdfbox.contentstream.operator包,在下文中一共展示了Operator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: removeText

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
private PDDocument removeText(PDPage page) throws IOException {

        PDFStreamParser parser = new PDFStreamParser(page);
        parser.parse();
        List<Object> tokens = parser.getTokens();
        List<Object> newTokens = new ArrayList<>();
        for (Object token : tokens) {
            if (token instanceof Operator) {
                Operator op = (Operator) token;
                if (op.getName().equals("TJ") || op.getName().equals("Tj")) {
                    //remove the one argument to this operator
                    newTokens.remove(newTokens.size() - 1);
                    continue;
                }
            }
            newTokens.add(token);
        }

        PDDocument document = new PDDocument();
        document.addPage(page);

        PDStream newContents = new PDStream(document);
        OutputStream out = newContents.createOutputStream(COSName.FLATE_DECODE);
        ContentStreamWriter writer = new ContentStreamWriter(out);
        writer.writeTokens(newTokens);
        out.close();
        page.setContents(newContents);

        return document;

    }
 
开发者ID:redmyers,项目名称:484_P7_1-Java,代码行数:32,代码来源:NurminenDetectionAlgorithm.java


示例2: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
  throws IOException {
  // set parameters from graphics state parameter dictionary
  COSName dictName = (COSName) arguments.get(0);
  PDExtendedGraphicsState gs = context.getResources().getExtGState(dictName);
  gs.copyIntoGraphicsState(context.getGraphicsState());
}
 
开发者ID:ckorzen,项目名称:icecite,代码行数:9,代码来源:SetGraphicsStateParameters.java


示例3: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
  throws IOException {
  if (arguments.size() < 6) {
    throw new MissingOperandException(operator, arguments);
  }

  // concatenate matrix to current transformation matrix
  COSNumber a = (COSNumber) arguments.get(0);
  COSNumber b = (COSNumber) arguments.get(1);
  COSNumber c = (COSNumber) arguments.get(2);
  COSNumber d = (COSNumber) arguments.get(3);
  COSNumber e = (COSNumber) arguments.get(4);
  COSNumber f = (COSNumber) arguments.get(5);

  Matrix matrix = new Matrix(a.floatValue(), b.floatValue(), c.floatValue(),
          d.floatValue(), e.floatValue(), f.floatValue());

  context.getCurrentTransformationMatrix().concatenate(matrix);
}
 
开发者ID:ckorzen,项目名称:icecite,代码行数:21,代码来源:ModifyCurrentTransformationMatrix.java


示例4: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
  throws IOException {
  COSNumber x = (COSNumber) operands.get(0);
  COSNumber y = (COSNumber) operands.get(1);
  COSNumber w = (COSNumber) operands.get(2);
  COSNumber h = (COSNumber) operands.get(3);

  Point lowerLeft = new SimplePoint(x.floatValue(), y.floatValue());
  Point upperRight = new SimplePoint(w.floatValue() + lowerLeft.getX(), 
      h.floatValue() + lowerLeft.getY());
  
  context.transform(lowerLeft);
  context.transform(upperRight);
  
  // To ensure that the path is created in the right direction,
  // we have to create it by combining single lines instead of
  // creating a simple rectangle
  GeneralPath path = context.getLinePath();
  path.moveTo(lowerLeft.getX(), lowerLeft.getY());
  path.lineTo(upperRight.getX(), lowerLeft.getY());
  path.lineTo(upperRight.getX(), upperRight.getY());
  path.lineTo(lowerLeft.getX(), upperRight.getY());
  path.lineTo(lowerLeft.getX(), lowerLeft.getY());
}
 
开发者ID:ckorzen,项目名称:icecite,代码行数:26,代码来源:AppendRectangleToPath.java


示例5: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
  throws IOException {
  COSNumber x2 = (COSNumber) operands.get(0);
  COSNumber y2 = (COSNumber) operands.get(1);
  COSNumber x3 = (COSNumber) operands.get(2);
  COSNumber y3 = (COSNumber) operands.get(3);

  Point2D currentPoint = context.getLinePath().getCurrentPoint();
  Point point2 = new SimplePoint(x2.floatValue(), y2.floatValue());
  Point point3 = new SimplePoint(x3.floatValue(), y3.floatValue());
  
  context.transform(point2);
  context.transform(point3);

  if (currentPoint == null) {
    context.getLinePath().moveTo(point3.getX(), point3.getY());
  } else {
    context.getLinePath().curveTo(
        (float) currentPoint.getX(), (float) currentPoint.getY(),
        point2.getX(), point2.getY(), point3.getX(), point3.getY());
  }
}
 
开发者ID:ckorzen,项目名称:icecite,代码行数:24,代码来源:CurveToReplicateInitialPoint.java


示例6: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands) 
    throws IOException {
  COSNumber x1 = (COSNumber) operands.get(0);
  COSNumber y1 = (COSNumber) operands.get(1);
  COSNumber x3 = (COSNumber) operands.get(2);
  COSNumber y3 = (COSNumber) operands.get(3);

  Point point1 = new SimplePoint(x1.floatValue(), y1.floatValue());
  Point point3 = new SimplePoint(x3.floatValue(), y3.floatValue());
  
  context.transform(point1);
  context.transform(point3);

  context.getLinePath().curveTo(point1.getX(), point1.getY(), 
      point3.getX(), point3.getY(), point3.getX(), point3.getY());
}
 
开发者ID:ckorzen,项目名称:icecite,代码行数:18,代码来源:CurveToReplicateFinalPoint.java


示例7: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
  throws IOException {
  COSNumber x1 = (COSNumber) operands.get(0);
  COSNumber y1 = (COSNumber) operands.get(1);
  COSNumber x2 = (COSNumber) operands.get(2);
  COSNumber y2 = (COSNumber) operands.get(3);
  COSNumber x3 = (COSNumber) operands.get(4);
  COSNumber y3 = (COSNumber) operands.get(5);

  Point point1 = new SimplePoint(x1.floatValue(), y1.floatValue());
  Point point2 = new SimplePoint(x2.floatValue(), y2.floatValue());
  Point point3 = new SimplePoint(x3.floatValue(), y3.floatValue());
  
  context.transform(point1);
  context.transform(point2);
  context.transform(point3);
  
  if (context.getLinePath().getCurrentPoint() == null) {
    context.getLinePath().moveTo(point3.getX(), point3.getY());
  } else {
    context.getLinePath().curveTo(point1.getX(), point1.getY(), 
        point2.getX(), point2.getY(), point3.getX(), point3.getY());
  }
}
 
开发者ID:ckorzen,项目名称:icecite,代码行数:26,代码来源:CurveTo.java


示例8: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
  throws MissingOperandException {
  if (arguments.size() < 6) {
    throw new MissingOperandException(operator, arguments);
  }
  
  COSNumber a = (COSNumber) arguments.get(0);
  COSNumber b = (COSNumber) arguments.get(1);
  COSNumber c = (COSNumber) arguments.get(2);
  COSNumber d = (COSNumber) arguments.get(3);
  COSNumber e = (COSNumber) arguments.get(4);
  COSNumber f = (COSNumber) arguments.get(5);

  // Set both matrices to 
  // [ a b 0
  //   c d 0
  //   e f 1 ]
  
  Matrix matrix = new Matrix(a.floatValue(), b.floatValue(), 
      c.floatValue(), d.floatValue(), e.floatValue(), f.floatValue());

  context.setTextMatrix(matrix);
  context.setTextLineMatrix(matrix.clone());
}
 
开发者ID:ckorzen,项目名称:icecite,代码行数:26,代码来源:SetTextMatrix.java


示例9: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
  throws MissingOperandException {
  if (arguments.size() < 2) {
    throw new MissingOperandException(operator, arguments);
  }
  Matrix tlm = context.getTextLineMatrix();
  if (tlm == null) {
    return;
  }

  COSNumber tx = (COSNumber) arguments.get(0);
  COSNumber ty = (COSNumber) arguments.get(1);
  
  Matrix matrix = new Matrix(1, 0, 0, 1, tx.floatValue(), ty.floatValue());
  tlm.concatenate(matrix);
      
  context.setTextMatrix(tlm.clone());
}
 
开发者ID:ckorzen,项目名称:icecite,代码行数:20,代码来源:MoveText.java


示例10: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
  throws IOException {
  PDColorSpace cs = context.getResources().getColorSpace(COSName.DEVICERGB);
  context.getGraphicsState().setNonStrokingColorSpace(cs);
  super.process(operator, arguments);
}
 
开发者ID:ckorzen,项目名称:icecite,代码行数:8,代码来源:SetNonStrokingDeviceRGBColor.java


示例11: PdfImageCounter

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
public PdfImageCounter() {
    addOperator(new OperatorProcessor() {
        @Override
        public void process(Operator operator, List<COSBase> arguments) throws IOException {
            if (arguments.size() < 1) {
                throw new org.apache.pdfbox.contentstream.operator.MissingOperandException(operator, arguments);
            }
            if (isImage(arguments.get(0))) {
                documentImageCount++;
            }
        }

        protected Boolean isImage(COSBase base) {
            return (base instanceof COSName) &&
                    context.getResources().isImageXObject((COSName)base);
        }

        @Override
        public String getName() {
            return "Do";
        }
    });
}
 
开发者ID:hrbrmstr,项目名称:pdfbox,代码行数:24,代码来源:PdfImageCounter.java


示例12: processOperator

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
protected void processOperator(Operator operator, List<COSBase> operands) throws IOException
{
    String currentFormName = formName; 
    if (operator != null && "Do".equals(operator.getName()) && operands != null && operands.size() > 0)
    {
        COSBase base0 = operands.get(0);
        if (base0 instanceof COSName)
        {
            formName = ((COSName)base0).getName();
            if (currentFormName == null)
                lastFormName = formName;
        }
    }
    try
    {
        super.processOperator(operator, operands);
    }
    finally
    {
        formName = currentFormName;
    }
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox2,代码行数:24,代码来源:HelloSignAnalyzer.java


示例13: processOperator

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
protected void processOperator(Operator operator, List<COSBase> operands) throws IOException
{
    if (replacement != null)
    {
        boolean copy = true;
        if (TjTJ.contains(operator.getName()))
        {
            Matrix transformation = getTextMatrix().multiply(getGraphicsState().getCurrentTransformationMatrix());
            float xPos = transformation.getTranslateX();
            float yPos = transformation.getTranslateY();
            for (HelloSignField field : fields)
            {
                if (field.inField(xPos, yPos))
                {
                    copy = false;
                }
            }
        }

        if (copy)
        {
            replacement.writeTokens(operands);
            replacement.writeToken(operator);
        }
    }
    super.processOperator(operator, operands);
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox2,代码行数:29,代码来源:HelloSignManipulator.java


示例14: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
    if (operands.size() < 4) {
        throw new MissingOperandException(operator, operands);
    }
    if (!checkArrayTypesClass(operands, COSNumber.class)) {
        return;
    }
    COSNumber x = (COSNumber) operands.get(0);
    COSNumber y = (COSNumber) operands.get(1);
    COSNumber w = (COSNumber) operands.get(2);
    COSNumber h = (COSNumber) operands.get(3);

    float x1 = x.floatValue();
    float y1 = y.floatValue();

    // create a pair of coordinates for the transformation
    float x2 = w.floatValue() + x1;
    float y2 = h.floatValue() + y1;

    Point2D p0 = context.transformedPoint(x1, y1);
    Point2D p1 = context.transformedPoint(x2, y1);
    Point2D p2 = context.transformedPoint(x2, y2);
    Point2D p3 = context.transformedPoint(x1, y2);

    // to ensure that the path is created in the right direction, we have to create
    // it by combining single lines instead of creating a simple rectangle
    linePath.moveTo((float) p0.getX(), (float) p0.getY());
    linePath.lineTo((float) p1.getX(), (float) p1.getY());
    linePath.lineTo((float) p2.getX(), (float) p2.getY());
    linePath.lineTo((float) p3.getX(), (float) p3.getY());

    // close the subpath instead of adding the last line so that a possible set line
    // cap style isn't taken into account at the "beginning" of the rectangle
    linePath.closePath();
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox2,代码行数:37,代码来源:PDFVisibleTextStripper.java


示例15: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
/**
   * process : BI : begin inline image.
   * 
   * @param operator
   *          The operator that is being executed.
   * @param arguments
   *          List
   * @throws IOException
   *           If there is an error displaying the inline image.
   */
  public void process(Operator operator, List<COSBase> arguments)
    throws IOException {
    Matrix ctm = context.getCurrentTransformationMatrix();
    COSDictionary params = operator.getImageParameters();
    
    int width = params.getInt(COSName.W, COSName.WIDTH, -1);
    int height = params.getInt(COSName.H, COSName.HEIGHT, -1);
    
    // TODO: use transform().

    float minX = ctm.getTranslateX();
    float maxX = minX + (width * ctm.getScaleX());
    float minY = ctm.getTranslateY();
    float maxY = minY + (height * ctm.getScaleY());

    // Type3 streams may contain BI operands, but we don't wan't to consider
    // those.
    if (!context.isType3Stream()) {
//      Rectangle boundBox = new SimpleRectangle(minX, minY, maxX, maxY);
      
      Rectangle boundBox = SimpleRectangle.from2Vertices(
          new SimplePoint(minX, minY), 
          new SimplePoint(maxX, maxY));
      
      PDImage image = new PDInlineImage(operator.getImageParameters(),
          operator.getImageData(), context.getResources());
      
      PdfBoxColor exclusiveColor = getExclusiveColor(image.getImage());
      
      if (exclusiveColor != null) {
        PdfBoxShape shape = new PdfBoxShape(context.getCurrentPage());
        shape.setRectangle(boundBox);
        shape.setColor(exclusiveColor);
        context.showShape(shape);
      } else {
        PdfBoxFigure figure = new PdfBoxFigure(context.getCurrentPage());
        figure.setRectangle(boundBox);
        context.showFigure(figure);
      }
    }
  }
 
开发者ID:ckorzen,项目名称:icecite,代码行数:52,代码来源:BeginInlineImage.java


示例16: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
public final void process(Operator operator, List<COSBase> operands)
  throws IOException {
  // Call operation "stroke path" with given windingRule.
  // Use COSFloat, because COSInteger is private.
  operands.add(new COSFloat(GeneralPath.WIND_NON_ZERO));
  
  context.processOperator("S", operands); // Stroke path
}
 
开发者ID:ckorzen,项目名称:icecite,代码行数:10,代码来源:FillNonZeroRule.java


示例17: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
  throws IOException {
  // append straight line segment from the current point to the point.
  COSNumber x = (COSNumber) operands.get(0);
  COSNumber y = (COSNumber) operands.get(1);
  
  Point point = new SimplePoint(x.floatValue(), y.floatValue());
  
  context.transform(point);
  context.getLinePath().lineTo(point.getX(), point.getY());  
}
 
开发者ID:ckorzen,项目名称:icecite,代码行数:13,代码来源:LineTo.java


示例18: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
  throws IOException {
  COSNumber x = (COSNumber) operands.get(0);
  COSNumber y = (COSNumber) operands.get(1);
  
  Point point = new SimplePoint(x.floatValue(), y.floatValue());
  
  context.transform(point);
  context.getLinePath().moveTo(point.getX(), point.getY());
}
 
开发者ID:ckorzen,项目名称:icecite,代码行数:12,代码来源:MoveTo.java


示例19: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
  public void process(Operator operator, List<COSBase> arguments)
    throws IOException {
    if (arguments.size() < 6) {
      throw new MissingOperandException(operator, arguments);
    }
    
    // Set glyph with and bounding box for type 3 font
//    COSNumber hDisplacement = (COSNumber) arguments.get(0);
//    COSNumber vDisplacement = (COSNumber) arguments.get(1);
    COSNumber llx = (COSNumber) arguments.get(2);
    COSNumber lly = (COSNumber) arguments.get(3);
    COSNumber urx = (COSNumber) arguments.get(4);
    COSNumber ury = (COSNumber) arguments.get(5);
      
    Point lowerLeft = new SimplePoint(llx.floatValue(), lly.floatValue());
    Point upperRight = new SimplePoint(urx.floatValue(), ury.floatValue());
      
    context.transform(lowerLeft);
    context.transform(upperRight);
    
    float minX = Math.min(lowerLeft.getX(), upperRight.getX());
    float minY = Math.min(lowerLeft.getY(), upperRight.getY());
    float maxX = Math.max(lowerLeft.getX(), upperRight.getX());
    float maxY = Math.max(lowerLeft.getY(), upperRight.getY());
    
    Rectangle boundingBox = new SimpleRectangle(minX, minY, maxX, maxY);
    context.setCurrentType3GlyphBoundingBox(boundingBox);
  }
 
开发者ID:ckorzen,项目名称:icecite,代码行数:30,代码来源:SetType3GlyphWidthAndBoundingBox.java


示例20: process

import org.apache.pdfbox.contentstream.operator.Operator; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
  throws IOException {
  if (arguments.isEmpty()) {
    throw new MissingOperandException(operator, arguments);
  }

  // there are some documents which are incorrectly structured, and have
  // a wrong number of arguments to this, so we will assume the last argument
  // in the list
  Object charSpacing = arguments.get(arguments.size() - 1);
  if (charSpacing instanceof COSNumber) {
    COSNumber characterSpacing = (COSNumber) charSpacing;
    PDTextState textState = context.getGraphicsState().getTextState();
    textState.setCharacterSpacing(characterSpacing.floatValue());
  }
}
 
开发者ID:ckorzen,项目名称:icecite,代码行数:18,代码来源:SetCharacterSpacing.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RegisterFormatter类代码示例发布时间:2022-05-23
下一篇:
Java ThreadControllerWrapper类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap