Esempio n. 1
0
 /**
  * @see com.itextpdf.text.pdf.mc.MCParser.PdfOperator#process(com.itextpdf.text.pdf.mc.MCParser, com.itextpdf.text.pdf.PdfLiteral, java.util.List)
  */
 virtual public void Process(MCParser parser, PdfLiteral opr, IList <PdfObject> operands)
 {
     parser.PrintTextOperator(opr, operands);
 }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     processor.Gs().strokeColor = GetColor(processor.Gs().colorSpaceStroke, operands);
 }
 public void Invoke(PdfContentStreamProcessor processor,
         PdfLiteral oper, List<PdfObject> operands)
         {
     processor.BeginMarkedContent((PdfName)operands[0], new PdfDictionary());
 }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     PdfNumber leading = (PdfNumber)operands[0];
     processor.Gs().leading = leading.FloatValue;
 }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     GraphicsState gs = processor.gsStack.Peek();
     GraphicsState copy = new GraphicsState(gs);
     processor.gsStack.Push(copy);
 }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     textMoveNextLine.Invoke(processor, null, new List<PdfObject>(0));
     showText.Invoke(processor, null, operands);
 }
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
                float ty = ((PdfNumber)operands[1]).FloatValue;

                List<PdfObject> tlOperands = new List<PdfObject>(1);
                tlOperands.Insert(0, new PdfNumber(-ty));
                setTextLeading.Invoke(processor, null, tlOperands);
                moveStartNextLine.Invoke(processor, null, operands);
            }
Esempio n. 8
0
 public void Write(PdfLiteral value)
 {
     WriteSeparator(CharCat.Character);
     WriteRaw(value.Value);
     _lastCat = CharCat.Character;
 }
 protected override void Write(PdfContentStreamProcessor processor, PdfLiteral oper, List <PdfObject> operands)
 {
     base.Write(processor, oper, operands);
 }
Esempio n. 10
0
            virtual public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <PdfObject> operands)
            {
                PdfNumber rise = (PdfNumber)operands[0];

                processor.Gs().rise = rise.FloatValue;
            }
Esempio n. 11
0
 /// <seealso cref= "PdfOperator.Process(OCGParser, PdfLiteral, List{T})"> </seealso>
 virtual public void Process(OCGParser parser, PdfLiteral @operator, IList <PdfObject> operands)
 {
     parser.Process(@operator, operands, true);
 }
Esempio n. 12
0
            virtual public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <PdfObject> operands)
            {
                PdfString str = (PdfString)operands[0];

                processor.DisplayPdfString(str);
            }
Esempio n. 13
0
 /// <summary>This is the last method to be called when using external signatures.</summary>
 /// <remarks>
 /// This is the last method to be called when using external signatures. The general sequence is:
 /// preClose(), getDocumentBytes() and close().
 /// <p>
 /// update is a PdfDictionary that must have exactly the
 /// same keys as the ones provided in
 /// <see cref="PreClose(System.Collections.Generic.IDictionary{K, V})"/>
 /// .
 /// </remarks>
 /// <param name="update">
 /// a PdfDictionary with the key/value that will fill the holes defined
 /// in
 /// <see cref="PreClose(System.Collections.Generic.IDictionary{K, V})"/>
 /// </param>
 /// <exception cref="System.IO.IOException">on error</exception>
 protected internal virtual void Close(PdfDictionary update)
 {
     try {
         if (!preClosed)
         {
             throw new PdfException(PdfException.DocumentMustBePreclosed);
         }
         MemoryStream    bous = new MemoryStream();
         PdfOutputStream os   = new PdfOutputStream(bous);
         foreach (PdfName key in update.KeySet())
         {
             PdfObject  obj = update.Get(key);
             PdfLiteral lit = exclusionLocations.Get(key);
             if (lit == null)
             {
                 throw new ArgumentException("The key didn't reserve space in preclose");
             }
             bous.JReset();
             os.Write(obj);
             if (bous.Length > lit.GetBytesCount())
             {
                 throw new ArgumentException("The key is too big");
             }
             if (tempFile == null)
             {
                 System.Array.Copy(bous.ToArray(), 0, bout, (int)lit.GetPosition(), bous.Length);
             }
             else
             {
                 raf.Seek(lit.GetPosition());
                 raf.Write(bous.ToArray(), 0, (int)bous.Length);
             }
         }
         if (update.Size() != exclusionLocations.Count)
         {
             throw new ArgumentException("The update dictionary has less keys than required");
         }
         if (tempFile == null)
         {
             originalOS.Write(bout, 0, bout.Length);
         }
         else
         {
             if (originalOS != null)
             {
                 raf.Seek(0);
                 long   length = raf.Length;
                 byte[] buf    = new byte[8192];
                 while (length > 0)
                 {
                     int r = raf.JRead(buf, 0, (int)Math.Min((long)buf.Length, length));
                     if (r < 0)
                     {
                         throw new EndOfStreamException("unexpected eof");
                     }
                     originalOS.Write(buf, 0, r);
                     length -= r;
                 }
             }
         }
     }
     finally {
         if (tempFile != null)
         {
             raf.Close();
             if (originalOS != null)
             {
                 tempFile.Delete();
             }
         }
         if (originalOS != null)
         {
             try {
                 originalOS.Close();
             }
             catch (Exception) {
             }
         }
     }
 }
Esempio n. 14
0
        /// <summary>This is the first method to be called when using external signatures.</summary>
        /// <remarks>
        /// This is the first method to be called when using external signatures. The general sequence is:
        /// preClose(), getDocumentBytes() and close().
        /// <p>
        /// <CODE>exclusionSizes</CODE> must contain at least
        /// the <CODE>PdfName.CONTENTS</CODE> key with the size that it will take in the
        /// document. Note that due to the hex string coding this size should be byte_size*2+2.
        /// </remarks>
        /// <param name="exclusionSizes">
        /// Map with names and sizes to be excluded in the signature
        /// calculation. The key is a PdfName and the value an Integer. At least the /Contents must be present
        /// </param>
        /// <exception cref="System.IO.IOException">on error</exception>
        protected internal virtual void PreClose(IDictionary <PdfName, int?> exclusionSizes)
        {
            if (preClosed)
            {
                throw new PdfException(PdfException.DocumentAlreadyPreClosed);
            }
            // TODO: add mergeVerification functionality
            preClosed = true;
            PdfAcroForm   acroForm   = PdfAcroForm.GetAcroForm(document, true);
            SignatureUtil sgnUtil    = new SignatureUtil(document);
            String        name       = GetFieldName();
            bool          fieldExist = sgnUtil.DoesSignatureFieldExist(name);

            acroForm.SetSignatureFlags(PdfAcroForm.SIGNATURE_EXIST | PdfAcroForm.APPEND_ONLY);
            PdfSigFieldLockDictionary fieldLock = null;

            if (cryptoDictionary == null)
            {
                throw new PdfException(PdfException.NoCryptoDictionaryDefined);
            }
            cryptoDictionary.GetPdfObject().MakeIndirect(document);
            if (fieldExist)
            {
                PdfSignatureFormField sigField = (PdfSignatureFormField)acroForm.GetField(fieldName);
                sigField.Put(PdfName.V, cryptoDictionary.GetPdfObject());
                fieldLock = sigField.GetSigFieldLockDictionary();
                if (fieldLock == null && this.fieldLock != null)
                {
                    this.fieldLock.GetPdfObject().MakeIndirect(document);
                    sigField.Put(PdfName.Lock, this.fieldLock.GetPdfObject());
                    fieldLock = this.fieldLock;
                }
                sigField.Put(PdfName.P, document.GetPage(appearance.GetPageNumber()).GetPdfObject());
                sigField.Put(PdfName.V, cryptoDictionary.GetPdfObject());
                PdfObject obj   = sigField.GetPdfObject().Get(PdfName.F);
                int       flags = 0;
                if (obj != null && obj.IsNumber())
                {
                    flags = ((PdfNumber)obj).IntValue();
                }
                flags |= PdfAnnotation.LOCKED;
                sigField.Put(PdfName.F, new PdfNumber(flags));
                PdfDictionary ap = new PdfDictionary();
                ap.Put(PdfName.N, appearance.GetAppearance().GetPdfObject());
                sigField.Put(PdfName.AP, ap);
                sigField.SetModified();
            }
            else
            {
                PdfWidgetAnnotation widget = new PdfWidgetAnnotation(appearance.GetPageRect());
                widget.SetFlags(PdfAnnotation.PRINT | PdfAnnotation.LOCKED);
                PdfSignatureFormField sigField = PdfFormField.CreateSignature(document);
                sigField.SetFieldName(name);
                sigField.Put(PdfName.V, cryptoDictionary.GetPdfObject());
                sigField.AddKid(widget);
                if (this.fieldLock != null)
                {
                    this.fieldLock.GetPdfObject().MakeIndirect(document);
                    sigField.Put(PdfName.Lock, this.fieldLock.GetPdfObject());
                    fieldLock = this.fieldLock;
                }
                int pagen = appearance.GetPageNumber();
                widget.SetPage(document.GetPage(pagen));
                PdfDictionary ap = widget.GetAppearanceDictionary();
                if (ap == null)
                {
                    ap = new PdfDictionary();
                    widget.Put(PdfName.AP, ap);
                }
                ap.Put(PdfName.N, appearance.GetAppearance().GetPdfObject());
                acroForm.AddField(sigField, document.GetPage(pagen));
                acroForm.SetModified();
            }
            // TODO: test this (ain't sure whether I need this)
            exclusionLocations = new Dictionary <PdfName, PdfLiteral>();
            PdfLiteral lit = new PdfLiteral(80);

            exclusionLocations[PdfName.ByteRange] = lit;
            cryptoDictionary.Put(PdfName.ByteRange, lit);
            foreach (KeyValuePair <PdfName, int?> entry in exclusionSizes)
            {
                PdfName key = entry.Key;
                lit = new PdfLiteral((int)entry.Value);
                exclusionLocations[key] = lit;
                cryptoDictionary.Put(key, lit);
            }
            if (certificationLevel > 0)
            {
                AddDocMDP(cryptoDictionary);
            }
            if (fieldLock != null)
            {
                AddFieldMDP(cryptoDictionary, fieldLock);
            }
            if (signatureEvent != null)
            {
                signatureEvent.GetSignatureDictionary(cryptoDictionary);
            }
            if (certificationLevel > 0)
            {
                // add DocMDP entry to root
                PdfDictionary docmdp = new PdfDictionary();
                docmdp.Put(PdfName.DocMDP, cryptoDictionary.GetPdfObject());
                document.GetCatalog().Put(PdfName.Perms, docmdp);
            }
            // TODO: setModified?
            document.Close();
            range = new long[exclusionLocations.Count * 2];
            long byteRangePosition = exclusionLocations.Get(PdfName.ByteRange).GetPosition();

            exclusionLocations.JRemove(PdfName.ByteRange);
            int idx = 1;

            foreach (PdfLiteral lit1 in exclusionLocations.Values)
            {
                long n = lit1.GetPosition();
                range[idx++] = n;
                range[idx++] = lit1.GetBytesCount() + n;
            }
            iText.IO.Util.JavaUtil.Sort(range, 1, range.Length - 1);
            for (int k = 3; k < range.Length - 2; k += 2)
            {
                range[k] -= range[k - 1];
            }
            if (tempFile == null)
            {
                bout = temporaryOS.ToArray();
                range[range.Length - 1] = bout.Length - range[range.Length - 2];
                MemoryStream    bos = new MemoryStream();
                PdfOutputStream os  = new PdfOutputStream(bos);
                os.Write('[');
                for (int k_1 = 0; k_1 < range.Length; ++k_1)
                {
                    os.WriteLong(range[k_1]).Write(' ');
                }
                os.Write(']');
                System.Array.Copy(bos.ToArray(), 0, bout, (int)byteRangePosition, bos.Length);
            }
            else
            {
                try {
                    raf = FileUtil.GetRandomAccessFile(tempFile);
                    long len = raf.Length;
                    range[range.Length - 1] = len - range[range.Length - 2];
                    MemoryStream    bos = new MemoryStream();
                    PdfOutputStream os  = new PdfOutputStream(bos);
                    os.Write('[');
                    for (int k_1 = 0; k_1 < range.Length; ++k_1)
                    {
                        os.WriteLong(range[k_1]).Write(' ');
                    }
                    os.Write(']');
                    raf.Seek(byteRangePosition);
                    raf.Write(bos.ToArray(), 0, (int)bos.Length);
                }
                catch (System.IO.IOException e) {
                    try {
                        raf.Close();
                    }
                    catch (Exception) {
                    }
                    try {
                        tempFile.Delete();
                    }
                    catch (Exception) {
                    }
                    throw;
                }
            }
        }
        /**
         * Invokes an oper.
         * @param oper  the PDF Syntax of the oper
         * @param operands  a list with operands
         */
        private void InvokeOperator(PdfLiteral oper, List<PdfObject> operands) {
            IContentOperator op;
            operators.TryGetValue(oper.ToString(), out op);
            if (op == null)
                op = operators[DEFAULTOPERATOR];

            op.Invoke(this, oper, operands);
        }
Esempio n. 16
0
 PdfObject GetColorspace()
 {
     if (icc_profile != null)
     {
         if ((colorType & 2) == 0)
         {
             return(PdfName.DEVICEGRAY);
         }
         else
         {
             return(PdfName.DEVICERGB);
         }
     }
     if (gamma == 1f && !hasCHRM)
     {
         if ((colorType & 2) == 0)
         {
             return(PdfName.DEVICEGRAY);
         }
         else
         {
             return(PdfName.DEVICERGB);
         }
     }
     else
     {
         PdfArray      array = new PdfArray();
         PdfDictionary dic   = new PdfDictionary();
         if ((colorType & 2) == 0)
         {
             if (gamma == 1f)
             {
                 return(PdfName.DEVICEGRAY);
             }
             array.Add(PdfName.CALGRAY);
             dic.Put(PdfName.GAMMA, new PdfNumber(gamma));
             dic.Put(PdfName.WHITEPOINT, new PdfLiteral("[1 1 1]"));
             array.Add(dic);
         }
         else
         {
             PdfObject wp = new PdfLiteral("[1 1 1]");
             array.Add(PdfName.CALRGB);
             if (gamma != 1f)
             {
                 PdfArray  gm = new PdfArray();
                 PdfNumber n  = new PdfNumber(gamma);
                 gm.Add(n);
                 gm.Add(n);
                 gm.Add(n);
                 dic.Put(PdfName.GAMMA, gm);
             }
             if (hasCHRM)
             {
                 float    z   = yW * ((xG - xB) * yR - (xR - xB) * yG + (xR - xG) * yB);
                 float    YA  = yR * ((xG - xB) * yW - (xW - xB) * yG + (xW - xG) * yB) / z;
                 float    XA  = YA * xR / yR;
                 float    ZA  = YA * ((1 - xR) / yR - 1);
                 float    YB  = -yG * ((xR - xB) * yW - (xW - xB) * yR + (xW - xR) * yB) / z;
                 float    XB  = YB * xG / yG;
                 float    ZB  = YB * ((1 - xG) / yG - 1);
                 float    YC  = yB * ((xR - xG) * yW - (xW - xG) * yW + (xW - xR) * yG) / z;
                 float    XC  = YC * xB / yB;
                 float    ZC  = YC * ((1 - xB) / yB - 1);
                 float    XW  = XA + XB + XC;
                 float    YW  = 1;//YA+YB+YC;
                 float    ZW  = ZA + ZB + ZC;
                 PdfArray wpa = new PdfArray();
                 wpa.Add(new PdfNumber(XW));
                 wpa.Add(new PdfNumber(YW));
                 wpa.Add(new PdfNumber(ZW));
                 wp = wpa;
                 PdfArray matrix = new PdfArray();
                 matrix.Add(new PdfNumber(XA));
                 matrix.Add(new PdfNumber(YA));
                 matrix.Add(new PdfNumber(ZA));
                 matrix.Add(new PdfNumber(XB));
                 matrix.Add(new PdfNumber(YB));
                 matrix.Add(new PdfNumber(ZB));
                 matrix.Add(new PdfNumber(XC));
                 matrix.Add(new PdfNumber(YC));
                 matrix.Add(new PdfNumber(ZC));
                 dic.Put(PdfName.MATRIX, matrix);
             }
             dic.Put(PdfName.WHITEPOINT, wp);
             array.Add(dic);
         }
         return(array);
     }
 }
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
                PdfArray array = (PdfArray)operands[0];
                float tj = 0;
                foreach (PdfObject entryObj in array) {
                    if (entryObj is PdfString){
                        processor.DisplayPdfString((PdfString)entryObj);
                        tj = 0;
                    } else {
                        tj = ((PdfNumber)entryObj).FloatValue;
                        processor.ApplyTextAdjust(tj);
                    }
                }

            }
Esempio n. 18
0
        /**
         * Processes PDF syntax
         * @param contentBytes  the bytes of a content stream
         * @param resources     the resources that come with the content stream
         */
        public void ProcessContent(byte[] contentBytes, PdfDictionary resources)
        {
            this.resources.Push(resources);
            PRTokeniser      tokeniser = new PRTokeniser(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];

                // special handling for embedded images.  If we hit an ID oper, we need
                // to skip all content until we reach an EI oper surrounded by whitespace.
                // The following algorithm has one potential issue: what if the image stream
                // contains <ws>EI<ws> ?
                // it sounds like we would have to actually decode the content stream, which
                // I'd rather avoid right now.
                if ("ID".Equals(oper.ToString()))
                {
                    MemoryStream baos        = new MemoryStream();
                    MemoryStream accumulated = new MemoryStream();
                    int          ch;
                    int          found = 0;
                    while ((ch = tokeniser.Read()) != -1)
                    {
                        if (found == 0 && PRTokeniser.IsWhitespace(ch))
                        {
                            found++;
                            accumulated.WriteByte((byte)ch);
                        }
                        else if (found == 1 && ch == 'E')
                        {
                            found++;
                            accumulated.WriteByte((byte)ch);
                        }
                        else if (found == 2 && ch == 'I')
                        {
                            found++;
                            accumulated.WriteByte((byte)ch);
                        }
                        else if (found == 3 && PRTokeniser.IsWhitespace(ch))
                        {
                            operands = new List <PdfObject>();
                            operands.Add(new PdfLiteral("ID"));
                            InvokeOperator((PdfLiteral)operands[operands.Count - 1], operands);

                            // we should probably eventually do something to make the accumulated image content stream available

                            operands = new List <PdfObject>();
                            operands.Add(new PdfLiteral("EI"));
                            InvokeOperator((PdfLiteral)operands[operands.Count - 1], operands);

                            break;
                        }
                        else
                        {
                            accumulated.WriteTo(baos);
                            accumulated.SetLength(0);

                            baos.WriteByte((byte)ch);
                            found = 0;
                        }
                    }
                }
                InvokeOperator(oper, operands);
            }

            this.resources.Pop();
        }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     List<PdfObject> tdoperands = new List<PdfObject>(2);
     tdoperands.Insert(0, new PdfNumber(0));
     tdoperands.Insert(1, new PdfNumber(-processor.Gs().leading));
     moveStartNextLine.Invoke(processor, null, tdoperands);
 }
Esempio n. 20
0
        void RealizeLinearGradientBrush(LinearGradientBrush brush, XForm xform)
        {
            XMatrix           matrix  = this.currentTransform;
            PdfShadingPattern pattern = new PdfShadingPattern(this.writer.Owner);

            pattern.Elements[PdfShadingPattern.Keys.PatternType] = new PdfInteger(2); // shading pattern

            // Setup shading
            PdfShading   shading   = new PdfShading(this.writer.Owner);
            PdfColorMode colorMode = PdfColorMode.Rgb; //this.document.Options.ColorMode;

            PdfDictionary function = BuildShadingFunction(brush.GradientStops, colorMode);

            function.Elements.SetString("/@", "This is the shading function of a LinearGradientBrush");
            shading.Elements[PdfShading.Keys.Function] = function;

            shading.Elements[PdfShading.Keys.ShadingType] = new PdfInteger(2); // Axial shading
            //if (colorMode != PdfColorMode.Cmyk)
            shading.Elements[PdfShading.Keys.ColorSpace] = new PdfName("/DeviceRGB");
            //else
            //shading.Elements[Keys.ColorSpace] = new PdfName("/DeviceCMYK");

            //double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
            double x1 = brush.StartPoint.X;
            double y1 = brush.StartPoint.Y;
            double x2 = brush.EndPoint.X;
            double y2 = brush.EndPoint.Y;

            shading.Elements[PdfShading.Keys.Coords] = new PdfLiteral("[{0:0.###} {1:0.###} {2:0.###} {3:0.###}]", x1, y1, x2, y2);

            // old: Elements[Keys.Background] = new PdfRawItem("[0 1 1]");
            // old: Elements[Keys.Domain] =
            shading.Elements[PdfShading.Keys.Extend] = new PdfLiteral("[true true]");

            // Setup pattern
            pattern.Elements[PdfShadingPattern.Keys.Shading] = shading;
            pattern.Elements[PdfShadingPattern.Keys.Matrix]  = PdfLiteral.FromMatrix(matrix); // new PdfLiteral("[" + PdfEncoders.ToString(matrix) + "]");

            string name = this.writer.Resources.AddPattern(pattern);

            this.writer.WriteLiteral("/Pattern cs\n", name);
            this.writer.WriteLiteral("{0} scn\n", name);

            double alpha = brush.Opacity * brush.GradientStops.GetAverageAlpha();

            if (alpha < 1 && this.writer.renderMode == RenderMode.Default)
            {
#if true
                PdfExtGState extGState = this.writer.Owner.ExtGStateTable.GetExtGStateNonStroke(alpha);
                string       gs        = this.writer.Resources.AddExtGState(extGState);
                this.writer.WriteLiteral("{0} gs\n", gs);
#else
#if true
                if (xform == null)
                {
                    PdfExtGState extGState = this.writer.Owner.ExtGStateTable.GetExtGStateNonStroke(alpha);
                    string       gs        = this.writer.Resources.AddExtGState(extGState);
                    this.writer.WriteGraphicState(extGState);
                }
                else
                {
                    //PdfFormXObject pdfForm = this.writer.Owner.FormTable.GetForm(form);
                    PdfFormXObject pdfForm = xform.pdfForm;
                    pdfForm.Elements.SetString("/@", "This is the Form XObject of the soft mask");

                    string formName = this.writer.Resources.AddForm(pdfForm);

                    PdfTransparencyGroupAttributes tgAttributes = new PdfTransparencyGroupAttributes(this.writer.Owner);
                    //this.writer.Owner.Internals.AddObject(tgAttributes);
                    tgAttributes.Elements.SetName(PdfTransparencyGroupAttributes.Keys.CS, "/DeviceRGB");

                    // Set reference to transparency group attributes
                    pdfForm.Elements.SetObject(PdfFormXObject.Keys.Group, tgAttributes);
                    pdfForm.Elements[PdfFormXObject.Keys.Matrix] = new PdfLiteral("[1.001 0 0 1.001 0.001 0.001]");


                    PdfSoftMask softmask = new PdfSoftMask(this.writer.Owner);
                    this.writer.Owner.Internals.AddObject(softmask);
                    softmask.Elements.SetString("/@", "This is the soft mask");
                    softmask.Elements.SetName(PdfSoftMask.Keys.S, "/Luminosity");
                    softmask.Elements.SetReference(PdfSoftMask.Keys.G, pdfForm);
                    //pdfForm.Elements.SetName(PdfFormXObject.Keys.Type, "Group");
                    //pdfForm.Elements.SetName(PdfFormXObject.Keys.ss.Ss.Type, "Group");

                    PdfExtGState extGState = new PdfExtGState(this.writer.Owner);
                    this.writer.Owner.Internals.AddObject(extGState);
                    extGState.Elements.SetReference(PdfExtGState.Keys.SMask, softmask);
                    this.writer.WriteGraphicState(extGState);
                }
#else
                XForm     form    = new XForm(this.writer.Owner, 220, 140);
                XGraphics formGfx = XGraphics.FromForm(form);

                // draw something
                //XSolidBrush xbrush = new XSolidBrush(XColor.FromArgb(128, 128, 128));
                XLinearGradientBrush xbrush = new XLinearGradientBrush(new XPoint(0, 0), new XPoint(220, 0), XColors.White, XColors.Black);
                formGfx.DrawRectangle(xbrush, -10000, -10000, 20000, 20000);
                //formGfx.DrawString("Text, Graphics, Images, and Forms", new XFont("Verdana", 10, XFontStyle.Regular), XBrushes.Navy, 3, 0, XStringFormat.TopLeft);
                formGfx.Dispose();

                // Close form
                form.Finish();
                PdfFormXObject pdfForm  = this.writer.Owner.FormTable.GetForm(form);
                string         formName = this.writer.Resources.AddForm(pdfForm);

                //double x = 20, y = 20;
                //double cx = 1;
                //double cy = 1;

                //this.writer.AppendFormat("q {2:0.###} 0 0 -{3:0.###} {0:0.###} {4:0.###} cm 100 Tz {5} Do Q\n",
                //  x, y, cx, cy, y + 0, formName);

                //this.writer.AppendFormat("q {2:0.###} 0 0 -{3:0.###} {0:0.###} {4:0.###} cm 100 Tz {5} Do Q\n",
                //  x, y, cx, cy, y + 220/1.5, formName);

                PdfTransparencyGroupAttributes tgAttributes = new PdfTransparencyGroupAttributes(this.writer.Owner);
                this.writer.Owner.Internals.AddObject(tgAttributes);

                tgAttributes.Elements.SetName(PdfTransparencyGroupAttributes.Keys.CS, "/DeviceRGB");


                // Set reference to transparency group attributes
                pdfForm.Elements.SetReference(PdfFormXObject.Keys.Group, tgAttributes);


                PdfSoftMask softmask = new PdfSoftMask(this.writer.Owner);
                this.writer.Owner.Internals.AddObject(softmask);
                softmask.Elements.SetName(PdfSoftMask.Keys.S, "/Luminosity");
                softmask.Elements.SetReference(PdfSoftMask.Keys.G, pdfForm);
                //pdfForm.Elements.SetName(PdfFormXObject.Keys.Type, "Group");
                //pdfForm.Elements.SetName(PdfFormXObject.Keys.ss.Ss.Type, "Group");

                PdfExtGState extGState = new PdfExtGState(this.writer.Owner);
                this.writer.Owner.Internals.AddObject(extGState);
                extGState.Elements.SetReference(PdfExtGState.Keys.SMask, softmask);
                this.writer.WriteGraphicState(extGState);
#endif
#endif
            }
        }
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
                PdfName fontResourceName = (PdfName)operands[0];
                float size = ((PdfNumber)operands[1]).FloatValue;

                PdfDictionary fontsDictionary = processor.resources.GetAsDict(PdfName.FONT);
                CMapAwareDocumentFont font;
                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;

            }
 public void Invoke(PdfContentStreamProcessor processor,
                    PdfLiteral oper, List <PdfObject> operands)
 {
     processor.EndMarkedContent();
 }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     PdfNumber wordSpace = (PdfNumber)operands[0];
     processor.Gs().wordSpacing = wordSpace.FloatValue;
 }
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <PdfObject> operands)
            {
                PdfName xobjectName = (PdfName)operands[0];

                processor.DisplayXObject(xobjectName);
            }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     processor.Gs().fillColor = GetColor(4, operands);
 }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <PdfObject> operands)
 {
     // ignore the oper
 }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     processor.textMatrix = new Matrix();
     processor.textLineMatrix = processor.textMatrix;
     processor.BeginText();
 }
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <PdfObject> operands)
            {
                PdfNumber leading = (PdfNumber)operands[0];

                processor.Gs().leading = leading.FloatValue;
            }
 public void Invoke(PdfContentStreamProcessor processor,
         PdfLiteral oper, List<PdfObject> operands)
         {
     processor.EndMarkedContent();
 }
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <PdfObject> operands)
            {
                PdfNumber charSpace = (PdfNumber)operands[0];

                processor.Gs().characterSpacing = charSpace.FloatValue;
            }
Esempio n. 31
0
 virtual public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     PdfNumber charSpace = (PdfNumber)operands[0];
     processor.Gs().characterSpacing = charSpace.FloatValue;
 }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <PdfObject> operands)
 {
     processor.Gs().fillColor = GetColor(4, operands);
 }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands){
     // ignore the oper
 }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <PdfObject> operands)
 {
     processor.Gs().colorSpaceStroke = (PdfName)operands[0];
 }
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
                PdfNumber aw = (PdfNumber)operands[0];
                PdfNumber ac = (PdfNumber)operands[1];
                PdfString str = (PdfString)operands[2];

                List<PdfObject> twOperands = new List<PdfObject>(1);
                twOperands.Insert(0, aw);
                setTextWordSpacing.Invoke(processor, null, twOperands);

                List<PdfObject> tcOperands = new List<PdfObject>(1);
                tcOperands.Insert(0, ac);
                setTextCharacterSpacing.Invoke(processor, null, tcOperands);

                List<PdfObject> tickOperands = new List<PdfObject>(1);
                tickOperands.Insert(0, str);
                moveNextLineAndShowText.Invoke(processor, null, tickOperands);
            }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <PdfObject> operands)
 {
     processor.Gs().strokeColor = GetColor(processor.Gs().colorSpaceStroke, operands);
 }
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
                PdfString str = (PdfString)operands[0];

                processor.DisplayPdfString(str);
            }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <PdfObject> operands)
 {
     processor.gsStack.Pop();
 }
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
                float a = ((PdfNumber)operands[0]).FloatValue;
                float b = ((PdfNumber)operands[1]).FloatValue;
                float c = ((PdfNumber)operands[2]).FloatValue;
                float d = ((PdfNumber)operands[3]).FloatValue;
                float e = ((PdfNumber)operands[4]).FloatValue;
                float f = ((PdfNumber)operands[5]).FloatValue;

                processor.textLineMatrix = new Matrix(a, b, c, d, e, f);
                processor.textMatrix = processor.textLineMatrix;
            }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <PdfObject> operands)
 {
     processor.textMatrix     = new Matrix();
     processor.textLineMatrix = processor.textMatrix;
     processor.BeginText();
 }
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
                float tx = ((PdfNumber)operands[0]).FloatValue;
                float ty = ((PdfNumber)operands[1]).FloatValue;

                Matrix translationMatrix = new Matrix(tx, ty);
                processor.textMatrix =  translationMatrix.Multiply(processor.textLineMatrix);
                processor.textLineMatrix = processor.textMatrix;
            }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <PdfObject> operands)
 {
     processor.textMatrix     = null;
     processor.textLineMatrix = null;
     processor.EndText();
 }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     PdfNumber render = (PdfNumber)operands[0];
     processor.Gs().renderMode = render.IntValue;
 }
 public void Invoke(PdfContentStreamProcessor processor,
                    PdfLiteral oper, List <PdfObject> operands)
 {
     processor.BeginMarkedContent((PdfName)operands[0], new PdfDictionary());
 }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     PdfNumber scale = (PdfNumber)operands[0];
     processor.Gs().horizontalScaling = scale.FloatValue/100f;
 }
Esempio n. 46
0
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <iTextSharp.text.pdf.PdfObject> operands)
 {
     // ignore the oper
 }
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<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;
                }
            }
Esempio n. 48
0
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <iTextSharp.text.pdf.PdfObject> operands)
 {
     textMoveNextLine.Invoke(processor, null, new List <iTextSharp.text.pdf.PdfObject>(0));
     showText.Invoke(processor, null, operands);
 }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     float a = ((PdfNumber)operands[0]).FloatValue;
     float b = ((PdfNumber)operands[1]).FloatValue;
     float c = ((PdfNumber)operands[2]).FloatValue;
     float d = ((PdfNumber)operands[3]).FloatValue;
     float e = ((PdfNumber)operands[4]).FloatValue;
     float f = ((PdfNumber)operands[5]).FloatValue;
     Matrix matrix = new Matrix(a, b, c, d, e, f);
     GraphicsState gs = processor.gsStack.Peek();
     gs.ctm = matrix.Multiply(gs.ctm);
 }
Esempio n. 50
0
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <iTextSharp.text.pdf.PdfObject> operands)
            {
                PdfString str = (PdfString)operands[0];

                processor.DisplayPdfString(str);
            }
		    public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
			    processor.Gs().colorSpaceStroke = (PdfName)operands[0];		
		    }
Esempio n. 52
0
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <iTextSharp.text.pdf.PdfObject> operands)
            {
                PdfNumber render = (PdfNumber)operands[0];

                processor.Gs().renderMode = render.IntValue;
            }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     processor.gsStack.Pop();
 }
Esempio n. 54
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;
            }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     processor.textMatrix = null;
     processor.textLineMatrix = null;
     processor.EndText();
 }
Esempio n. 56
0
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List <iTextSharp.text.pdf.PdfObject> operands)
            {
                PdfNumber wordSpace = (PdfNumber)operands[0];

                processor.Gs().wordSpacing = wordSpace.FloatValue;
            }
 public void Invoke(PdfContentStreamProcessor processor,
         PdfLiteral oper, List<PdfObject> operands)
         {
     
     PdfObject properties = operands[1];
     
     processor.BeginMarkedContent((PdfName)operands[0], GetPropertiesDictionary(properties, processor.resources));
 }
Esempio n. 58
0
 virtual public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     PdfNumber rise = (PdfNumber)operands[0];
     processor.Gs().rise = rise.FloatValue;
 }
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
     PdfName xobjectName = (PdfName)operands[0];
     processor.DisplayXObject(xobjectName);
 }
Esempio n. 60
0
 /**
  * @see com.itextpdf.text.pdf.mc.MCParser.PdfOperator#process(com.itextpdf.text.pdf.mc.MCParser, com.itextpdf.text.pdf.PdfLiteral, java.util.List)
  */
 virtual public void Process(MCParser parser, PdfLiteral opr, IList <PdfObject> operands)
 {
     LOGGER.Debug("ET: end text block");
     parser.SetInText(false);
     parser.PrintOperator(opr, operands);
 }