public virtual void Invoke(PdfContentStreamProcessor pdfContentStreamProcessor, PdfLiteral oper, List <PdfObject> operands)
        {
            String         operatorStr   = oper.ToString();
            PdfContentByte canvas        = cleanUpStrategy.Context.Canvas;
            PRStream       xFormStream   = null;
            bool           disableOutput = pathConstructionOperators.Contains(operatorStr) || pathPaintingOperators.Contains(operatorStr) || clippingPathOperators.Contains(operatorStr);
            GraphicsState  gs            = pdfContentStreamProcessor.Gs();

            // key - number of a string in the TJ operator, value - number following the string; the first number without string (if it's presented) is stored under 0.
            // BE AWARE: zero-length strings are ignored!!!
            IDictionary <int, float> structuredTJoperands = null;

            if ("Do" == operatorStr)
            {
                if (operands.Count == 2 && operands[0].IsName())
                {
                    PdfDictionary xObjResources = cleanUpStrategy.Context.Resources.GetAsDict(PdfName.XOBJECT);

                    if (xObjResources != null)
                    {
                        PdfStream xObj = xObjResources.GetAsStream((PdfName)operands[0]);

                        if (xObj is PRStream && xObj.GetAsName(PdfName.SUBTYPE) != null &&
                            xObj.GetAsName(PdfName.SUBTYPE).CompareTo(PdfName.FORM) == 0)
                        {
                            xFormStream = (PRStream)xObj;
                            cleanUpStrategy.RegisterNewContext(xObj.GetAsDict(PdfName.RESOURCES), null);
                        }
                    }
                }
            }

            originalContentOperator.Invoke(pdfContentStreamProcessor, oper, operands);
            IList <PdfCleanUpContentChunk> chunks = cleanUpStrategy.Chunks;

            if (xFormStream != null)
            {
                xFormStream.SetData(cleanUpStrategy.Context.Canvas.ToPdf(cleanUpStrategy.Context.Canvas.PdfWriter));
                cleanUpStrategy.PopContext();
                canvas = cleanUpStrategy.Context.Canvas;
            }

            if ("Do" == operatorStr)
            {
                if (chunks.Count > 0 && chunks[0] is PdfCleanUpContentChunk.Image)
                {
                    PdfCleanUpContentChunk.Image chunk = (PdfCleanUpContentChunk.Image)chunks[0];

                    if (chunk.Visible)
                    {
                        PdfDictionary xObjResources = cleanUpStrategy.Context.Resources.GetAsDict(PdfName.XOBJECT);
                        PRStream      imageStream   = (PRStream)xObjResources.GetAsStream((PdfName)operands[0]);
                        UpdateImageStream(imageStream, chunk.NewImageData);
                    }
                    else
                    {
                        disableOutput = true;
                    }
                }
            }
            else if (lineStyleOperators.Contains(operatorStr))
            {
                disableOutput = true;
            }
            else if (textShowingOperators.Contains(operatorStr) && !AllChunksAreVisible(cleanUpStrategy.Chunks))
            {
                disableOutput = true;

                if ("'" == operatorStr)
                {
                    canvas.InternalBuffer.Append(TStar);
                }
                else if ("\"" == operatorStr)
                {
                    operands[0].ToPdf(canvas.PdfWriter, canvas.InternalBuffer);
                    canvas.InternalBuffer.Append(Tw);

                    operands[1].ToPdf(canvas.PdfWriter, canvas.InternalBuffer);
                    canvas.InternalBuffer.Append(TcTStar);
                }
                else if ("TJ" == operatorStr)
                {
                    structuredTJoperands = StructureTJarray((PdfArray)operands[0]);
                }

                WriteTextChunks(structuredTJoperands, chunks, canvas, gs.CharacterSpacing, gs.WordSpacing,
                                gs.FontSize, gs.HorizontalScaling);
            }
            else if (pathPaintingOperators.Contains(operatorStr))
            {
                WritePath(operatorStr, canvas, gs.ColorSpaceStroke);
            }
            else if (strokeColorOperators.Contains(operatorStr))
            {
                // Replace current color with the new one.
                cleanUpStrategy.Context.PopStrokeColor();
                cleanUpStrategy.Context.PushStrokeColor(operands);
            }
            else if ("q" == operatorStr)
            {
                cleanUpStrategy.Context.PushStrokeColor(cleanUpStrategy.Context.PeekStrokeColor());
            }
            else if ("Q" == operatorStr)
            {
                cleanUpStrategy.Context.PopStrokeColor();
            }

            if (!disableOutput)
            {
                WriteOperands(canvas, operands);
            }

            cleanUpStrategy.ClearChunks();
        }
        public void Invoke(PdfContentStreamProcessor pdfContentStreamProcessor, PdfLiteral @operator, List <PdfObject> operands)
        {
            String         operatorStr = @operator.ToString();
            PdfContentByte canvas      = cleanUpStrategy.Context.Canvas;
            PRStream       xFormStream = null;

            // key - number of a string in the TJ operator, value - number following the string; the first number without string (if it's presented) is stored under 0.
            // BE AWARE: zero-length strings are ignored!!!
            IDictionary <int, float> structuredTJoperands = null;

            if ("Do" == operatorStr)
            {
                if (operands.Count == 2 && operands[0].IsName())
                {
                    PdfDictionary xObjResources = cleanUpStrategy.Context.Resources.GetAsDict(PdfName.XOBJECT);

                    if (xObjResources != null)
                    {
                        PdfStream xObj = xObjResources.GetAsStream((PdfName)operands[0]);

                        if (xObj is PRStream && xObj.GetAsName(PdfName.SUBTYPE) != null &&
                            xObj.GetAsName(PdfName.SUBTYPE).CompareTo(PdfName.FORM) == 0)
                        {
                            xFormStream = (PRStream)xObj;
                            cleanUpStrategy.RegisterNewContext(xObj.GetAsDict(PdfName.RESOURCES), null);
                        }
                    }
                }
            }

            originalContentOperator.Invoke(pdfContentStreamProcessor, @operator, operands);
            IList <PdfCleanUpContentChunk> chunks = cleanUpStrategy.Chunks;
            bool disableOutput = false;

            if (xFormStream != null)
            {
                xFormStream.SetData(cleanUpStrategy.Context.Canvas.ToPdf(cleanUpStrategy.Context.Canvas.PdfWriter));
                cleanUpStrategy.PopContext();
                canvas = cleanUpStrategy.Context.Canvas;
            }

            if ("Do" == operatorStr)
            {
                if (chunks.Count > 0 && chunks[0].IsImage())
                {
                    PdfCleanUpContentChunk chunk = chunks[0];

                    if (chunk.IsVisible())
                    {
                        PdfDictionary xObjResources = cleanUpStrategy.Context.Resources.GetAsDict(PdfName.XOBJECT);
                        PRStream      imageStream   = (PRStream)xObjResources.GetAsStream((PdfName)operands[0]);
                        UpdateImage(imageStream, chunk.NewImageData);
                    }
                    else
                    {
                        disableOutput = true;
                    }
                }
            }
            else if ("q" == operatorStr)
            {
                cleanUpStrategy.Context.SaveGraphicsState();
            }
            else if ("Q" == operatorStr)
            {
                cleanUpStrategy.Context.RestoreGraphicsState();
            }
            else if ("Tf" == operatorStr)
            {
                cleanUpStrategy.Context.FontSize = ((PdfNumber)operands[1]).FloatValue;
            }
            else if ("Tc" == operatorStr)
            {
                cleanUpStrategy.Context.CharacterSpacing = ((PdfNumber)operands[0]).FloatValue;
            }
            else if ("Tw" == operatorStr)
            {
                cleanUpStrategy.Context.WordSpacing = ((PdfNumber)operands[0]).FloatValue;
            }
            else if ("Tz" == operatorStr)
            {
                cleanUpStrategy.Context.HorizontalScaling = ((PdfNumber)operands[0]).FloatValue;
            }
            else if (textShowingOperators.Contains(operatorStr) && !AllChunksAreVisible(cleanUpStrategy.Chunks))
            {
                disableOutput = true;

                if ("'" == operatorStr)
                {
                    canvas.InternalBuffer.Append(TStar);
                }
                else if ("\"" == operatorStr)
                {
                    operands[0].ToPdf(canvas.PdfWriter, canvas.InternalBuffer);
                    canvas.InternalBuffer.Append(Tw);

                    operands[1].ToPdf(canvas.PdfWriter, canvas.InternalBuffer);
                    canvas.InternalBuffer.Append(TcTStar);

                    cleanUpStrategy.Context.CharacterSpacing = ((PdfNumber)operands[1]).FloatValue;
                }
                else if ("TJ" == operatorStr)
                {
                    structuredTJoperands = StructureTJarray((PdfArray)operands[0]);
                }

                RenderChunks(structuredTJoperands, chunks, canvas);
            }
            else if ("\"" == operatorStr)
            {
                cleanUpStrategy.Context.CharacterSpacing = ((PdfNumber)operands[1]).FloatValue;
            }

            if (!disableOutput)
            {
                int index = 0;

                foreach (PdfObject o in operands)
                {
                    ToPdf(o, canvas.PdfWriter, canvas.InternalBuffer);
                    canvas.InternalBuffer.Append(operands.Count > ++index ? (byte)' ' : (byte)'\n');
                }
            }

            cleanUpStrategy.ClearChunks();
        }