示例#1
0
        public void AddXRef(TokenXRefEntry xref)
        {
            PdfIndirectObject indirect = new PdfIndirectObject(this, xref);

            if (_gens == null)
            {
                if (_single == null)
                {
                    // Cache the single object
                    _single = indirect;
                    return;
                }
                else
                {
                    // Convert from single entry to using a dictionary
                    _gens = new Dictionary <int, PdfIndirectObject> {
                        { _single.Gen, _single }
                    };
                    _single = null;
                }
            }

            if (_gens.ContainsKey(xref.Gen))
            {
                // PH: ignore this ref and let the document be still loaded
                // TODO: should signal any kind of warning to the caller
                return;
                //throw new ApplicationException($"Indirect object with Id:{xref.Id} Gen:{xref.Gen} already exists.");
            }

            _gens.Add(indirect.Gen, indirect);
        }
示例#2
0
 public PdfIndirectObject(PdfObject parent, TokenXRefEntry xref)
     : base(parent)
 {
     Id     = xref.Id;
     Gen    = xref.Gen;
     Offset = xref.Offset;
 }
        public void AddXRef(TokenXRefEntry xref)
        {
            PdfIndirectObject indirect = new PdfIndirectObject(this, xref);

            if (_gens == null)
            {
                if (_single == null)
                {
                    // Cache the single object
                    _single = indirect;
                    return;
                }
                else
                {
                    // Convert from single entry to using a dictionary
                    _gens = new Dictionary <int, PdfIndirectObject> {
                        { _single.Gen, _single }
                    };
                    _single = null;
                }
            }

            if (_gens.ContainsKey(xref.Gen))
            {
                throw new ApplicationException($"Indirect object with Id:{xref.Id} Gen:{xref.Gen} already exists.");
            }

            _gens.Add(indirect.Gen, indirect);
        }
示例#4
0
        public TokenObject GetXRefEntry(int id)
        {
            // Ignore zero or more whitespace characters
            SkipWhitespace();

            if ((_length - _index) < 18)
            {
                return(new TokenError(_position, $"Cross-reference entry data is {_length - _index} bytes instead of the expected 18."));
            }

            TokenXRefEntry ret = new TokenXRefEntry(id,
                                                    ConvertDecimalToInteger(11, 5),
                                                    ConvertDecimalToInteger(0, 10),
                                                    (_line[_index + 17] == 110));       // 'n' = used, otherwise free

            _index = _length;

            return(ret);
        }