Exemplo n.º 1
0
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <iTextSharp.text.pdf.PdfObject> operands)
            {
                PdfName       dictionaryName = (PdfName)operands[0];
                PdfDictionary extGState      = processor.resources.GetAsDict(PdfName.EXTGSTATE);

                if (extGState == null)
                {
                    throw new ArgumentException(MessageLocalization.GetComposedMessage("resources.do.not.contain.extgstate.entry.unable.to.process.oper.1", oper));
                }
                PdfDictionary gsDic = extGState.GetAsDict(dictionaryName);

                if (gsDic == null)
                {
                    throw new ArgumentException(MessageLocalization.GetComposedMessage("1.is.an.unknown.graphics.state.dictionary", dictionaryName));
                }

                // at this point, all we care about is the FONT entry in the GS dictionary
                PdfArray fontParameter = gsDic.GetAsArray(PdfName.FONT);

                if (fontParameter != null)
                {
                    CMapAwareDocumentFont font = processor.GetFont((PRIndirectReference)fontParameter[0]);
                    float size = fontParameter.GetAsNumber(1).FloatValue;

                    processor.Gs().font     = font;
                    processor.Gs().fontSize = size;
                }
            }
Exemplo n.º 2
0
            public void HandleXObject(PdfContentStreamProcessor processor, PdfStream stream, PdfIndirectReference refi)
            {
                PdfDictionary resources = stream.GetAsDict(PdfName.RESOURCES);

                // we read the content bytes up here so if it fails we don't leave the graphics state stack corrupted
                // this is probably not necessary (if we fail on this, probably the entire content stream processing
                // operation should be rejected
                byte[] contentBytes;
                contentBytes = ContentByteUtils.GetContentBytesFromContentObject(stream);
                PdfArray matrix = stream.GetAsArray(PdfName.MATRIX);

                new PushGraphicsState().Invoke(processor, null, null);

                if (matrix != null)
                {
                    float  a          = matrix.GetAsNumber(0).FloatValue;
                    float  b          = matrix.GetAsNumber(1).FloatValue;
                    float  c          = matrix.GetAsNumber(2).FloatValue;
                    float  d          = matrix.GetAsNumber(3).FloatValue;
                    float  e          = matrix.GetAsNumber(4).FloatValue;
                    float  f          = matrix.GetAsNumber(5).FloatValue;
                    Matrix formMatrix = new Matrix(a, b, c, d, e, f);

                    processor.Gs().ctm = formMatrix.Multiply(processor.Gs().ctm);
                }

                processor.ProcessContent(contentBytes, resources);

                new PopGraphicsState().Invoke(processor, null, null);
            }
Exemplo n.º 3
0
            public void HandleXObject(PdfContentStreamProcessor processor, PdfStream xobjectStream, PdfIndirectReference refi)
            {
                PdfDictionary   colorSpaceDic = processor.resources.GetAsDict(PdfName.COLORSPACE);
                ImageRenderInfo renderInfo    = ImageRenderInfo.CreateForXObject(processor.Gs().ctm, refi, colorSpaceDic);

                processor.renderListener.RenderImage(renderInfo);
            }
Exemplo n.º 4
0
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <iTextSharp.text.pdf.PdfObject> operands)
            {
                List <iTextSharp.text.pdf.PdfObject> tdoperands = new List <iTextSharp.text.pdf.PdfObject>(2);

                tdoperands.Insert(0, new PdfNumber(0));
                tdoperands.Insert(1, new PdfNumber(-processor.Gs().leading));
                moveStartNextLine.Invoke(processor, null, tdoperands);
            }
Exemplo n.º 5
0
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <iTextSharp.text.pdf.PdfObject> operands)
            {
                PdfName fontResourceName = (PdfName)operands[0];
                float   size             = ((PdfNumber)operands[1]).FloatValue;

                PdfDictionary         fontsDictionary = processor.resources.GetAsDict(PdfName.FONT);
                CMapAwareDocumentFont font;

                iTextSharp.text.pdf.PdfObject fontObject = fontsDictionary.Get(fontResourceName);
                if (fontObject is PdfDictionary)
                {
                    font = processor.GetFont((PdfDictionary)fontObject);
                }
                else
                {
                    font = processor.GetFont((PRIndirectReference)fontObject);
                }

                processor.Gs().font     = font;
                processor.Gs().fontSize = size;
            }
Exemplo n.º 6
0
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <iTextSharp.text.pdf.PdfObject> operands)
            {
                PdfNumber wordSpace = (PdfNumber)operands[0];

                processor.Gs().wordSpacing = wordSpace.FloatValue;
            }
Exemplo n.º 7
0
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <iTextSharp.text.pdf.PdfObject> operands)
            {
                PdfNumber scale = (PdfNumber)operands[0];

                processor.Gs().horizontalScaling = scale.FloatValue / 100f;
            }
Exemplo n.º 8
0
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <iTextSharp.text.pdf.PdfObject> operands)
            {
                PdfNumber render = (PdfNumber)operands[0];

                processor.Gs().renderMode = render.IntValue;
            }