예제 #1
0
 public PDFImage(PDFStream stream, PDFDictionary filterParams)
     : base(stream)
 {
     try
     {
         Image = new Bitmap(new MemoryStream(Data));
     }
     catch
     {
     }
 }
예제 #2
0
        public static IEnumerable <PDFObject> FromObjStm(PDFStream sobj)
        {
            PDFInteger nobjsv;

            if (sobj.Options.TryGet("N", out nobjsv))
            {
                int           nobjs  = (int)nobjsv.Value;
                PDFObject[]   objs   = new PDFObject[nobjs];
                PDFTokenStack stack  = new PDFTokenStack();
                PDFTokenizer  tokens = new PDFTokenizer(new ByteStreamReader(sobj.Data));

                foreach (IPDFToken token in tokens)
                {
                    stack.ProcessToken(token);
                }

                for (int i = 0; i < nobjs; i++)
                {
                    objs[i] = new PDFObject {
                        Value = stack.Pop <IPDFElement>()
                    };
                }

                for (int i = 0; i < nobjs; i++)
                {
                    int offset = (int)stack.Pop <PDFInteger>().Value;
                    objs[i].ID      = (int)stack.Pop <PDFInteger>().Value;
                    objs[i].Version = 0;
                }

                return(objs);
            }
            else
            {
                return(new PDFObject[0]);
            }
        }
예제 #3
0
        protected PDFStream ApplyFilters()
        {
            PDFStream data = this;

            if (Options != null)
            {
                PDFInteger length;
                if (Options.TryGet("Length", out length))
                {
                    data = new PDFStream {
                        Data = new byte[length.Value], Options = Options
                    };
                    Array.Copy(Data, data.Data, data.Data.Length);

                    PDFList filters;
                    PDFName filter;

                    if (Options.TryGet("Filter", out filter))
                    {
                        filters = new PDFList {
                            filter
                        };
                    }
                    else
                    {
                        Options.TryGet("Filter", out filters);
                    }

                    if (filters != null)
                    {
                        PDFDictionary decodeparams;
                        PDFList       decodeparamslist;

                        if (Options.TryGet("DecodeParams", out decodeparams))
                        {
                            decodeparamslist = new PDFList {
                                decodeparams
                            };
                        }
                        else
                        {
                            Options.TryGet("DecodeParams", out decodeparamslist);

                            if (decodeparamslist == null)
                            {
                                decodeparamslist = new PDFList();
                            }
                        }

                        for (int i = 0; i < filters.Count; i++)
                        {
                            string        filtername = filters.Get <PDFName>(i).Name;
                            PDFDictionary filterparams;
                            decodeparamslist.TryGet <PDFDictionary>(i, out filterparams);
                            data = data.ApplyFilter(filtername, filterparams);
                        }
                    }
                }
            }

            return(data);
        }
예제 #4
0
 public PDFStream(PDFStream other)
 {
     this.Data    = other.Data;
     this.Options = other.Options;
 }