org.apache.pdfbox.contentstream.operator.Operator Java Examples

The following examples show how to use org.apache.pdfbox.contentstream.operator.Operator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PDFVisibleTextStripper.java    From testarea-pdfbox2 with Apache License 2.0 6 votes vote down vote up
@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 x1 = (COSNumber) operands.get(0);
    COSNumber y1 = (COSNumber) operands.get(1);
    COSNumber x3 = (COSNumber) operands.get(2);
    COSNumber y3 = (COSNumber) operands.get(3);

    Point2D.Float point1 = context.transformedPoint(x1.floatValue(), y1.floatValue());
    Point2D.Float point3 = context.transformedPoint(x3.floatValue(), y3.floatValue());

    linePath.curveTo(point1.x, point1.y, point3.x, point3.y, point3.x, point3.y);
}
 
Example #2
Source File: PDDefaultAppearanceString.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Processes the operators of the given content stream.
 *
 * @param content the content to parse.
 * @throws IOException if there is an error reading or parsing the content stream.
 */
private void processAppearanceStringOperators(byte[] content) throws IOException
{
    List<COSBase> arguments = new ArrayList<COSBase>();
    PDFStreamParser parser = new PDFStreamParser(content);
    Object token = parser.parseNextToken();
    while (token != null)
    {
        if (token instanceof COSObject)
        {
            arguments.add(((COSObject) token).getObject());
        }
        else if (token instanceof Operator)
        {
            processOperator((Operator) token, arguments);
            arguments = new ArrayList<COSBase>();
        }
        else
        {
            arguments.add((COSBase) token);
        }
        token = parser.parseNextToken();
    }
}
 
Example #3
Source File: PDFStreamEngine.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Processes the operators of the given content stream.
 *
 * @param contentStream to content stream to parse.
 * @throws IOException if there is an error reading or parsing the content stream.
 */
private void processStreamOperators(PDContentStream contentStream) throws IOException
{
    List<COSBase> arguments = new ArrayList<COSBase>();
    PDFStreamParser parser = new PDFStreamParser(contentStream);
    Object token = parser.parseNextToken();
    while (token != null)
    {
        if (token instanceof COSObject)
        {
            arguments.add(((COSObject) token).getObject());
        }
        else if (token instanceof Operator)
        {
            processOperator((Operator) token, arguments);
            arguments = new ArrayList<COSBase>();
        }
        else
        {
            arguments.add((COSBase) token);
        }
        token = parser.parseNextToken();
    }
}
 
Example #4
Source File: PDDefaultAppearanceString.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * This is used to handle an operation.
 * 
 * @param operator The operation to perform.
 * @param operands The list of arguments.
 * @throws IOException If there is an error processing the operation.
 */
private void processOperator(Operator operator, List<COSBase> operands) throws IOException
{
    String name = operator.getName();
    
    if (OperatorName.SET_FONT_AND_SIZE.equals(name))
    {
        processSetFont(operands);
    }
    else if (OperatorName.NON_STROKING_GRAY.equals(name))
    {
        processSetFontColor(operands);
    }
    else if (OperatorName.NON_STROKING_RGB.equals(name))
    {
        processSetFontColor(operands);
    }
    else if (OperatorName.NON_STROKING_CMYK.equals(name))
    {
        processSetFontColor(operands);
    }
}
 
Example #5
Source File: PdfToTextInfoConverter.java    From testarea-pdfbox2 with Apache License 2.0 6 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
    if (operands.size() < 2) {
        throw new MissingOperandException(operator, operands);
    }
    COSBase base0 = operands.get(0);
    if (!(base0 instanceof COSNumber)) {
        return;
    }
    COSBase base1 = operands.get(1);
    if (!(base1 instanceof COSNumber)) {
        return;
    }
    // append straight line segment from the current point to the point
    COSNumber x = (COSNumber) base0;
    COSNumber y = (COSNumber) base1;

    Point2D.Float pos = context.transformedPoint(x.floatValue(), y.floatValue());

    linePath.lineTo(pos.x, pos.y);
}
 
Example #6
Source File: PDFVisibleTextStripper.java    From testarea-pdfbox2 with Apache License 2.0 6 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
    if (operands.size() < 2) {
        throw new MissingOperandException(operator, operands);
    }
    COSBase base0 = operands.get(0);
    if (!(base0 instanceof COSNumber)) {
        return;
    }
    COSBase base1 = operands.get(1);
    if (!(base1 instanceof COSNumber)) {
        return;
    }
    COSNumber x = (COSNumber) base0;
    COSNumber y = (COSNumber) base1;
    Point2D.Float pos = context.transformedPoint(x.floatValue(), y.floatValue());
    linePath.moveTo(pos.x, pos.y);
}
 
Example #7
Source File: PDFStreamEngine.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Called when an exception is thrown by an operator.
 *
 * @param operator The unknown operator.
 * @param operands The list of operands.
 * @param e the thrown exception.
 * 
 * @throws IOException if something went wrong
 */
protected void operatorException(Operator operator, List<COSBase> operands, IOException e)
        throws IOException
{
    if (e instanceof MissingOperandException ||
        e instanceof MissingResourceException ||
        e instanceof MissingImageReaderException)
    {
        LOG.error(e.getMessage());
    }
    else if (e instanceof EmptyGraphicsStackException)
    {
        LOG.warn(e.getMessage());
    }
    else if (operator.getName().equals("Do"))
    {
        // todo: this too forgiving, but PDFBox has always worked this way for DrawObject
        //       some careful refactoring is needed
        LOG.warn(e.getMessage());
    }
    else
    {
        throw e;
    }
}
 
Example #8
Source File: HelloSignAnalyzer.java    From testarea-pdfbox2 with Apache License 2.0 6 votes vote down vote up
@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;
    }
}
 
Example #9
Source File: MoveTo.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> operands) throws IOException
{
    if (operands.size() < 2)
    {
        throw new MissingOperandException(operator, operands);
    }
    COSBase base0 = operands.get(0);
    if (!(base0 instanceof COSNumber))
    {
        return;
    }
    COSBase base1 = operands.get(1);
    if (!(base1 instanceof COSNumber))
    {
        return;
    }
    COSNumber x = (COSNumber) base0;
    COSNumber y = (COSNumber) base1;
    Point2D.Float pos = context.transformedPoint(x.floatValue(), y.floatValue());
    context.moveTo(pos.x, pos.y);
}
 
Example #10
Source File: PdfToTextInfoConverter.java    From testarea-pdfbox2 with Apache License 2.0 6 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
    if (operands.size() < 6) {
        throw new MissingOperandException(operator, operands);
    }
    if (!checkArrayTypesClass(operands, COSNumber.class)) {
        return;
    }
    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);

    Point2D.Float point1 = context.transformedPoint(x1.floatValue(), y1.floatValue());
    Point2D.Float point2 = context.transformedPoint(x2.floatValue(), y2.floatValue());
    Point2D.Float point3 = context.transformedPoint(x3.floatValue(), y3.floatValue());

    linePath.curveTo(point1.x, point1.y, point2.x, point2.y, point3.x, point3.y);
}
 
Example #11
Source File: PDFVisibleTextStripper.java    From testarea-pdfbox2 with Apache License 2.0 6 votes vote down vote up
@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 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 = linePath.getCurrentPoint();

    Point2D.Float point2 = context.transformedPoint(x2.floatValue(), y2.floatValue());
    Point2D.Float point3 = context.transformedPoint(x3.floatValue(), y3.floatValue());

    linePath.curveTo((float) currentPoint.getX(), (float) currentPoint.getY(), point2.x, point2.y, point3.x, point3.y);
}
 
Example #12
Source File: DrawObject.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException
{
    if (arguments.isEmpty())
    {
        throw new MissingOperandException(operator, arguments);
    }
    COSBase base0 = arguments.get(0);
    if (!(base0 instanceof COSName))
    {
        return;
    }
    COSName name = (COSName) base0;
    PDXObject xobject =  context.getResources().getXObject(name);
    ((PDFMarkedContentExtractor) context).xobject(xobject);

    if (xobject instanceof PDTransparencyGroup)
    {
        context.showTransparencyGroup((PDTransparencyGroup) xobject);
    }
    else if (xobject instanceof PDFormXObject)
    {
        PDFormXObject form = (PDFormXObject) xobject;
        context.showForm(form);
    }
}
 
Example #13
Source File: CurveToReplicateFinalPoint.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@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 x1 = (COSNumber)operands.get(0);
    COSNumber y1 = (COSNumber)operands.get(1);
    COSNumber x3 = (COSNumber)operands.get(2);
    COSNumber y3 = (COSNumber)operands.get(3);

    Point2D.Float point1 = context.transformedPoint(x1.floatValue(), y1.floatValue());
    Point2D.Float point3 = context.transformedPoint(x3.floatValue(), y3.floatValue());

    context.curveTo(point1.x, point1.y,
                    point3.x, point3.y,
                    point3.x, point3.y);
}
 
Example #14
Source File: SetFontAndSize.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException
{
    if (arguments.size() < 2)
    {
        throw new MissingOperandException(operator, arguments);
    }

    COSBase base0 = arguments.get(0);
    COSBase base1 = arguments.get(1);
    if (!(base0 instanceof COSName))
    {
        return;
    }
    if (!(base1 instanceof COSNumber))
    {
        return;
    }
    COSName fontName = (COSName) base0;
    float fontSize = ((COSNumber) base1).floatValue();
    context.getGraphicsState().getTextState().setFontSize(fontSize);
    PDFont font = context.getResources().getFont(fontName);
    context.getGraphicsState().getTextState().setFont(font);
}
 
Example #15
Source File: SetCharSpacing.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@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;
        context.getGraphicsState().getTextState().setCharacterSpacing(characterSpacing.floatValue());
    }
}
 
Example #16
Source File: PdfToTextInfoConverter.java    From testarea-pdfbox2 with Apache License 2.0 6 votes vote down vote up
@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 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 = linePath.getCurrentPoint();

    Point2D.Float point2 = context.transformedPoint(x2.floatValue(), y2.floatValue());
    Point2D.Float point3 = context.transformedPoint(x3.floatValue(), y3.floatValue());

    linePath.curveTo((float) currentPoint.getX(), (float) currentPoint.getY(), point2.x, point2.y, point3.x, point3.y);
}
 
Example #17
Source File: MoveTextSetLeading.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException
{
    if (arguments.size() < 2)
    {
        throw new MissingOperandException(operator, arguments);
    }
    
    //move text position and set leading
    COSBase base1 = arguments.get(1);
    if (!(base1 instanceof COSNumber))
    {
        return;
    }
    COSNumber y = (COSNumber) base1;
    
    List<COSBase> args = new ArrayList<COSBase>();
    args.add(new COSFloat(-1 * y.floatValue()));
    context.processOperator(OperatorName.SET_TEXT_LEADING, args);
    context.processOperator(OperatorName.MOVE_TEXT, arguments);
}
 
Example #18
Source File: ShowTextAdjusted.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException
{
    if (arguments.isEmpty())
    {
        return;
    }
    COSBase base = arguments.get(0);
    if (!(base instanceof COSArray))
    {
        return;
    }
    if (context.getTextMatrix() == null)
    {
        // ignore: outside of BT...ET
        return;
    }
    COSArray array = (COSArray) base;
    context.showTextStrings(array);
}
 
Example #19
Source File: PDFVisibleTextStripper.java    From testarea-pdfbox2 with Apache License 2.0 6 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
    if (operands.size() < 2) {
        throw new MissingOperandException(operator, operands);
    }
    COSBase base0 = operands.get(0);
    if (!(base0 instanceof COSNumber)) {
        return;
    }
    COSBase base1 = operands.get(1);
    if (!(base1 instanceof COSNumber)) {
        return;
    }
    // append straight line segment from the current point to the point
    COSNumber x = (COSNumber) base0;
    COSNumber y = (COSNumber) base1;

    Point2D.Float pos = context.transformedPoint(x.floatValue(), y.floatValue());

    linePath.lineTo(pos.x, pos.y);
}
 
Example #20
Source File: SetTextRenderingMode.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException
{
    if (arguments.isEmpty())
    {
        throw new MissingOperandException(operator, arguments);
    }
    COSBase base0 = arguments.get(0);
    if (!(base0 instanceof COSNumber))
    {
        return;
    }
    COSNumber mode = (COSNumber) base0;
    int val = mode.intValue();
    if (val < 0 || val >= RenderingMode.values().length)
    {
        return;
    }
    RenderingMode renderingMode = RenderingMode.fromInt(val);
    context.getGraphicsState().getTextState().setRenderingMode(renderingMode);
}
 
Example #21
Source File: Concatenate.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException
{
    if (arguments.size() < 6)
    {
        throw new MissingOperandException(operator, arguments);
    }
    if (!checkArrayTypesClass(arguments, COSNumber.class))
    {
        return;
    }
    
    // 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.getGraphicsState().getCurrentTransformationMatrix().concatenate(matrix);
}
 
Example #22
Source File: ImageExtractor.java    From inception with Apache License 2.0 5 votes vote down vote up
@Override protected void processOperator(Operator operator, List<COSBase> operands)
    throws IOException
{
    String operation = operator.getName();
    if ("Do".equals(operation)) {
        COSName objectName = (COSName) operands.get(0);
        PDXObject xobject = getResources().getXObject(objectName);

        if (xobject instanceof PDImageXObject) {
            PDImageXObject image = (PDImageXObject) xobject;
            Matrix ctmNew = getGraphicsState().getCurrentTransformationMatrix();
            PDRectangle pageRect = this.getCurrentPage().getCropBox();
            float w = ctmNew.getScalingFactorX();
            float h = ctmNew.getScalingFactorY();
            float x = ctmNew.getTranslateX();
            float y = pageRect.getHeight() - ctmNew.getTranslateY() - h;
            buffer.add(new ImageOperator(x, y, w, h));
        }
        else if (xobject instanceof PDFormXObject) {
            PDFormXObject form = (PDFormXObject) xobject;
            showForm(form);
        }
    }
    else {
        super.processOperator(operator, operands);
    }
}
 
Example #23
Source File: PDFVisibleTextStripper.java    From testarea-pdfbox2 with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #24
Source File: SetWordSpacing.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> arguments)
{
    if (arguments.isEmpty())
    {
        return;
    }
    COSBase base = arguments.get(0);
    if (!(base instanceof COSNumber))
    {
        return;
    }
    COSNumber wordSpacing = (COSNumber) base;
    context.getGraphicsState().getTextState().setWordSpacing( wordSpacing.floatValue() );
}
 
Example #25
Source File: SetTextRise.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException
{
    if (arguments.isEmpty())
    {
        return;
    }
    COSBase base = arguments.get(0);
    if (!(base instanceof COSNumber))
    {
        return;
    }
    COSNumber rise = (COSNumber) base;
    context.getGraphicsState().getTextState().setRise( rise.floatValue() );
}
 
Example #26
Source File: PdfToTextInfoConverter.java    From testarea-pdfbox2 with Apache License 2.0 5 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
    PDGraphicsState gs = getGraphicsState();
    linePath.setWindingRule(GeneralPath.WIND_EVEN_ODD);
    addFillPath(gs.getNonStrokingColor());
    linePath.reset();
}
 
Example #27
Source File: SetLineMiterLimit.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException
{
    if (arguments.isEmpty())
    {
        throw new MissingOperandException(operator, arguments);
    }
    COSNumber miterLimit = (COSNumber)arguments.get( 0 );
    context.getGraphicsState().setMiterLimit( miterLimit.floatValue() );
}
 
Example #28
Source File: SetLineCapStyle.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException
{
    if (arguments.isEmpty())
    {
        throw new MissingOperandException(operator, arguments);
    }
    int lineCapStyle = ((COSNumber)arguments.get( 0 )).intValue();
    context.getGraphicsState().setLineCap( lineCapStyle );
}
 
Example #29
Source File: PdfToTextInfoConverter.java    From testarea-pdfbox2 with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #30
Source File: PdfContentStreamEditor.java    From testarea-pdfbox2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void processOperator(Operator operator, List<COSBase> operands) throws IOException {
    if (inOperator) {
        super.processOperator(operator, operands);
    } else {
        inOperator = true;
        nextOperation(operator, operands);
        super.processOperator(operator, operands);
        write(replacement, operator, operands);
        inOperator = false;
    }
}