Ejemplo n.º 1
0
        public IPDFToken Parse(Stack <IPDFToken> stack)
        {
            switch (TokenType)
            {
            case PDFTokenType.EndDictionary:
                return(PDFDictionary.Parse(stack));

            case PDFTokenType.EndList:
                return(PDFList.Parse(stack));

            case PDFTokenType.EOF:
                return(PDFTrailer.Parse(stack));

            default:
                return(this);
            }
        }
Ejemplo n.º 2
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);
        }