Example #1
0
 /// <summary>Initializes a MetaPen object.</summary>
 /// <param name="in">the InputMeta object that holds the inputstream of the WMF image</param>
 public virtual void Init(InputMeta @in)
 {
     style    = @in.ReadWord();
     penWidth = @in.ReadShort();
     @in.ReadWord();
     color = @in.ReadColor();
 }
Example #2
0
        /// <summary>Initializes the MetaFont instance.</summary>
        /// <param name="in">InputMeta containing the WMF data</param>
        /// <exception cref="System.IO.IOException"/>
        public virtual void Init(InputMeta @in)
        {
            height = Math.Abs(@in.ReadShort());
            @in.Skip(2);
            angle = (float)(@in.ReadShort() / 1800.0 * Math.PI);
            @in.Skip(2);
            bold      = (@in.ReadShort() >= BOLDTHRESHOLD ? MARKER_BOLD : 0);
            italic    = (@in.ReadByte() != 0 ? MARKER_ITALIC : 0);
            underline = (@in.ReadByte() != 0);
            strikeout = (@in.ReadByte() != 0);
            charset   = @in.ReadByte();
            @in.Skip(3);
            pitchAndFamily = @in.ReadByte();
            byte[] name = new byte[NAME_SIZE];
            int    k;

            for (k = 0; k < NAME_SIZE; ++k)
            {
                int c = @in.ReadByte();
                if (c == 0)
                {
                    break;
                }
                name[k] = (byte)c;
            }
            try {
                faceName = iText.IO.Util.JavaUtil.GetStringForBytes(name, 0, k, "Cp1252");
            }
            catch (ArgumentException) {
                faceName = iText.IO.Util.JavaUtil.GetStringForBytes(name, 0, k);
            }
            faceName = faceName.ToLower(System.Globalization.CultureInfo.InvariantCulture);
        }
Example #3
0
        /// <summary>This method checks if the image is a valid WMF and processes some parameters.</summary>
        private void ProcessParameters()
        {
            Stream @is = null;

            try {
                String errorID;
                if (wmf.GetData() == null)
                {
                    @is     = UrlUtil.OpenStream(wmf.GetUrl());
                    errorID = wmf.GetUrl().ToString();
                }
                else
                {
                    @is     = new MemoryStream(wmf.GetData());
                    errorID = "Byte array";
                }
                InputMeta @in = new InputMeta(@is);
                if (@in.ReadInt() != unchecked ((int)(0x9AC6CDD7)))
                {
                    throw new PdfException(PdfException._1IsNotAValidPlaceableWindowsMetafile, errorID);
                }
                @in.ReadWord();
                int left   = @in.ReadShort();
                int top    = @in.ReadShort();
                int right  = @in.ReadShort();
                int bottom = @in.ReadShort();
                int inch   = @in.ReadWord();
                wmf.SetDpi(72, 72);
                wmf.SetHeight((float)(bottom - top) / inch * 72f);
                wmf.SetWidth((float)(right - left) / inch * 72f);
            }
            catch (System.IO.IOException) {
                throw new PdfException(PdfException.WmfImageException);
            }
            finally {
                if (@is != null)
                {
                    try {
                        @is.Dispose();
                    }
                    catch (System.IO.IOException) {
                    }
                }
            }
        }
Example #4
0
 /// <summary>Creates a MetaDo instance.</summary>
 /// <param name="in">inputstream containing the data</param>
 /// <param name="cb">PdfCanvas</param>
 public MetaDo(Stream @in, PdfCanvas cb)
 {
     this.cb  = cb;
     this.@in = new InputMeta(@in);
 }
Example #5
0
 /// <summary>Initializes this MetaBrush object.</summary>
 /// <param name="in">the InputMeta</param>
 /// <exception cref="System.IO.IOException"/>
 public virtual void Init(InputMeta @in)
 {
     style = @in.ReadWord();
     color = @in.ReadColor();
     hatch = @in.ReadWord();
 }