Esempio n. 1
0
 public PdfDocument()
     : base(null)
 {
     Version         = new PdfVersion(this, 0, 0);
     IndirectObjects = new PdfIndirectObjects(this);
     DecryptHandler  = new PdfDecryptNone(this);
 }
Esempio n. 2
0
        public static PdfDecrypt CreateDecrypt(PdfDocument doc, PdfDictionary trailer)
        {
            PdfDecrypt ret = new PdfDecryptNone(doc);

            // Check for optional encryption reference
            PdfObjectReference encryptRef = trailer.OptionalValue <PdfObjectReference>("Encrypt");

            if (encryptRef != null)
            {
                PdfDictionary encryptDict = doc.IndirectObjects.OptionalValue <PdfDictionary>(encryptRef);
                PdfName       filter      = encryptDict.MandatoryValue <PdfName>("Filter");
                PdfInteger    v           = encryptDict.OptionalValue <PdfInteger>("V");

                // We only implement the simple Standard, Version 1 scheme
                if ((filter.Value == "Standard") && (v != null) && (v.Value == 1))
                {
                    ret = new PdfDecryptStandard(doc, trailer, encryptDict);
                }
                else
                {
                    throw new ApplicationException("Can only decrypt the standard handler with version 1.");
                }
            }

            return(ret);
        }