public byte[] Modify(byte[] contentBytes, PdfDictionary resourcesDictionary)
        {
            _contentStreamBuilderStack.Push(new PdfContentStreamBuilder());
            _resourceDictionaryStack.Push(resourcesDictionary);
            PRTokeniser      tokeniser = new PRTokeniser(new RandomAccessFileOrArray(contentBytes));
            PdfContentParser ps        = new PdfContentParser(tokeniser);

            List <PdfObject> operands = new List <PdfObject>();

            while (ps.Parse(operands).Count > 0)
            {
                PdfLiteral oper = (PdfLiteral)operands[operands.Count - 1];

                //System.Diagnostics.Debug.WriteLine("[Debug] Opr: " + oper.ToString());

                PdfContentOperatorHandler operHandler = null;

                if (_operators.TryGetValue(oper.ToString(), out operHandler))
                {
                    operands = operHandler(oper, operands);
                }

                _contentStreamBuilderStack.Peek().Push(operands);
            }

            _resourceDictionaryStack.Pop();
            return(_contentStreamBuilderStack.Pop().GetBytes());
        }
 public void RegisterOperator(string oper, PdfContentOperatorHandler callback)
 {
     _operators.Add(oper, callback);
 }