Beispiel #1
0
        public File(IInputStream stream)
        {
            Initialize();

            reader = new Reader(stream, this);
            try // [FIX:45] File constructor didn't dispose reader on error.
            {
                Reader.FileInfo info = reader.ReadInfo();
                version                = info.Version;
                trailer                = PrepareTrailer(info.Trailer);
                indirectObjects        = new IndirectObjects(this, info.XrefEntries);
                document               = new Document(trailer[PdfName.Root]);
                Configuration.XRefMode = (PdfName.XRef.Equals(trailer[PdfName.Type])
                  ? XRefModeEnum.Compressed
                  : XRefModeEnum.Plain);
                if (trailer.ContainsKey(PdfName.Encrypt)) // Encrypted file.
                {
                    throw new NotImplementedException("Encrypted files are currently not supported.");
                    var encript = trailer.Resolve(PdfName.Encrypt);
                }
            }
            catch (Exception)
            {
                reader.Dispose();
                throw;
            }
        }
Beispiel #2
0
        public File()
        {
            Initialize();

            version         = VersionEnum.PDF14.GetVersion();
            trailer         = PrepareTrailer(new PdfDictionary());
            indirectObjects = new IndirectObjects(this, null);
            document        = new Document(this);
        }
Beispiel #3
0
        public File(IInputStream stream)
        {
            Initialize();

            reader = new Reader(stream, this);
            try // [FIX:45] File constructor didn't dispose reader on error.
            {
                Reader.FileInfo info = reader.ReadInfo();
                version         = info.Version;
                trailer         = PrepareTrailer(info.Trailer);
                indirectObjects = new IndirectObjects(this, info.XrefEntries);

                reader.PrepareDecryption();

                var documentReference = trailer[PdfName.Root];
                if (documentReference.Resolve() is PdfDictionary)
                {
                    document = new Document(documentReference);
                }
                else
                {
                    foreach (var inderectObject in indirectObjects)
                    {
                        var entry = inderectObject.Resolve();
                        if (entry is PdfDictionary entryDictionary &&
                            entryDictionary[PdfName.Pages] != null)
                        {
                            document = new Document(entry.Reference);
                        }
                    }
                }
                Configuration.XRefMode = (PdfName.XRef.Equals(trailer[PdfName.Type])
                  ? XRefModeEnum.Compressed
                  : XRefModeEnum.Plain);
            }
            catch (Exception)
            {
                reader.Dispose();
                throw;
            }
        }