コード例 #1
0
        private void AddWatermarks(bool bCheckLicence, bool bAdd_qQ_ToOrigSc)
        {
            bool flag1;
            Snow snow1;

            uint[] numArray1;
            int    num1;
            int    num2;

            if (bCheckLicence)
            {
                flag1 = false;
                snow1 = new Snow();
                snow1.LoadKey(41869, Rect.serial[0], 1, 0);
                numArray1 = new uint[3];
                for (num1 = 0; (num1 < 3); num1 += 1)
                {
                    numArray1[num1] = Rect.serial[(num1 + 1)];
                }
                snow1.EncryptDecrypt(ref numArray1);
                flag1 = ((bool)(((((numArray1[0] ^ numArray1[1]) ^ numArray1[2]) & (Circle.productType & 44933)) != (Circle.productType & 44933)) ? 0 : (numArray1[0] == numArray1[1])));
                if (flag1)
                {
                    return;
                }
            }
            WTM_Stamper stamper1 = new WTM_Stamper(this, false, bAdd_qQ_ToOrigSc);

            for (num2 = 0; (num2 < base.Pages.Count); num2 += 1)
            {
                stamper1.AddWatermarks(base.Pages[num2]);
            }
        }
コード例 #2
0
        public override void SaveAs(Stream strm, string header, IEncryption encrypt)
        {
            int num1;

            this.UpdateInfo();
            bool flag1 = false;
            Snow snow1 = new Snow();

            snow1.LoadKey(41869, Rect.serial[0], 1, 0);
            uint[] numArray1 = new uint[3];
            for (num1 = 0; (num1 < 3); num1 += 1)
            {
                numArray1[num1] = Rect.serial[(num1 + 1)];
            }
            snow1.EncryptDecrypt(ref numArray1);
            flag1 = ((bool)(((((numArray1[0] ^ numArray1[1]) ^ numArray1[2]) & (Circle.productType & 44933)) != (Circle.productType & 44933)) ? 0 : (numArray1[0] == numArray1[1])));
            if (!flag1 && (encrypt != null))
            {
                throw new SecurityException("Ecnryption is unsupported in the trial version");
            }
            PDFDict   dict1 = this.mTrailer;
            ArrayList list1 = ((ArrayList)this.mXRef.Clone());

            this.mTrailer         = ((PDFDict)dict1.Clone());
            this.mTrailer["Info"] = dict1["Info"];
            string text1 = Encoding.ASCII.GetString(this.GenerateFileId(this.mPath));

            string[] textArray1 = new string[2];
            textArray1[0]       = text1;
            textArray1[1]       = text1;
            this.mTrailer["ID"] = PDF.O(textArray1);
            PDFDict dict2 = encrypt.CreateEncryptionDict(this);

            this.mTrailer["Encrypt"] = this.Indirects.New(dict2);
            this.mWriter.Encryption  = encrypt;
            this.SaveAs(strm, header);
            this.mWriter.Encryption = null;
            this.mXRef    = list1;
            this.mTrailer = dict1;
        }
コード例 #3
0
        public override void SaveAs(Stream str, string header)
        {
            int num1;

            byte[] numArray2;
            UserAccessPermissions permissions1;
            PDFDict   dict2;
            PDFArray  array1;
            PDFStream stream1;
            Stream    stream2;
            int       num4;

            this.UpdateInfo();
            PDFDict dict1 = ((PDFDict)this.mTrailer.Clone());
            string  text1 = Encoding.ASCII.GetString(this.GenerateFileId(this.mPath));

            string[] textArray1 = new string[2];
            textArray1[0]       = text1;
            textArray1[1]       = text1;
            this.mTrailer["ID"] = PDF.O(textArray1);
            bool flag1 = false;
            Snow snow1 = new Snow();

            snow1.LoadKey(41869, Rect.serial[0], 1, 0);
            uint[] numArray1 = new uint[3];
            for (num1 = 0; (num1 < 3); num1 += 1)
            {
                numArray1[num1] = Rect.serial[(num1 + 1)];
            }
            snow1.EncryptDecrypt(ref numArray1);
            flag1 = ((bool)(((((numArray1[0] ^ numArray1[1]) ^ numArray1[2]) & (Circle.productType & 44933)) != (Circle.productType & 44933)) ? 0 : (numArray1[0] == numArray1[1])));
            DateTime time1   = DateTime.Now;
            Random   random1 = new Random(time1.Millisecond);

            if (!flag1)
            {
                this.AddWatermarks(false, false);
                numArray2 = new byte[32];
                random1.NextBytes(numArray2);
                permissions1            = -1340;
                this.mWriter.Encryption = EncryptionStandard.Create(Encoding.ASCII.GetString(numArray2), "", permissions1, 128, true);
                dict2 = this.mWriter.Encryption.CreateEncryptionDict(this);
                this.mTrailer["Encrypt"] = this.Indirects.New(dict2);
            }
            else
            {
                array1    = Library.CreateArray(1);
                array1[0] = Library.CreateName("FlateDecode");
                foreach (PDFIndirect indirect1 in this.Indirects)
                {
                    if (((indirect1 == null) || (indirect1.Direct == null)) || (indirect1.Direct.PDFType != PDFObjectType.tPDFStream))
                    {
                        continue;
                    }
                    stream1 = (indirect1.Direct as PDFStream);
                    if (stream1 == null)
                    {
                        continue;
                    }
                    stream2 = stream1.Decode();
                    stream1.Dict["Filter"] = base.CloneObject(array1);
                    stream1.Dict.Remove("DecodeParms");
                    stream1.Encode(stream2);
                }
            }
            if (this.mWriter == null)
            {
                this.mWriter = new PDFWriter();
            }
            this.mWriter.AttachToStream(str);
            this.mWriter.WriteRaw(header);
            this.mWriter.WriteEOL();
            string text2 = "%\u00cd\u00ce\u00cf\u00ff";

            this.mWriter.WriteRaw(text2);
            this.mWriter.WriteEOL();
            Hashtable hashtable1 = new Hashtable();

            this.mTrailer.Remove("Prev");
            if (this.mTrailer["Root"] != null)
            {
                this.EnqeueIndirects(hashtable1, this.mTrailer["Root"]);
            }
            if (this.mTrailer["Info"] != null)
            {
                this.EnqeueIndirects(hashtable1, this.mTrailer["Info"]);
            }
            if (this.mTrailer["Encrypt"] != null)
            {
                this.EnqeueIndirects(hashtable1, this.mTrailer["Encrypt"]);
            }
            this.mToSaveQueue = new Queue();
            int       num2  = 1;
            ArrayList list1 = this.mXRef;

            this.mXRef = new ArrayList();
            XRefEntry entry1 = new XRefEntry();

            entry1.dirty      = false;
            entry1.type       = 0;
            entry1.generation = 65535;
            entry1.indirect   = null;
            entry1.offset     = ((long)0);
            this.mXRef.Add(entry1);
            foreach (DictionaryEntry entry2 in hashtable1)
            {
                ((CorePDFIndirect)entry2.Key).mId = num2;
                entry1            = new XRefEntry();
                entry1.dirty      = true;
                entry1.type       = 1;
                entry1.generation = 0;
                entry1.indirect   = ((CorePDFIndirect)entry2.Key);
                entry1.offset     = ((long)-1);
                this.mXRef.Add(entry1);
                num2 += 1;
                this.mToSaveQueue.Enqueue(entry2.Key);
            }
            num2 = 0;
            foreach (PDFIndirect indirect2 in this.mToSaveQueue)
            {
                num2 += 1;
                this.SaveIndirect(((XRefEntry)this.mXRef[num2]), indirect2);
            }
            long num3 = this.mWriter.Position;

            this.mWriter.WriteRaw("xref");
            this.mWriter.WriteEOL();
            this.mWriter.WriteXRefSection(this.mXRef, 0, 0, this.mXRef.Count);
            this.mWriter.WriteRaw("trailer");
            this.mWriter.WriteEOL();
            this.mTrailer["Root"] = this.mRoot.Indirect;
            if (this.mInfo != null)
            {
                this.mTrailer["Info"] = this.mInfo.Indirect;
            }
            if (this.mEncrypt != null)
            {
                this.mTrailer["Encrypt"] = this.mEncrypt.Indirect;
            }
            this.mTrailer["Size"] = new CorePDFInteger(((long)this.mXRef.Count));
            this.mWriter.WriteLn(this.mTrailer);
            this.mWriter.WriteRaw("startxref");
            this.mWriter.WriteEOL();
            this.mWriter.Write(num3);
            this.mWriter.WriteEOL();
            this.mWriter.WriteRaw("%%EOF");
            this.mWriter.WriteEOL();
            this.mWriter.Flush();
            this.mTrailer = dict1;
            this.mXRef    = list1;
            for (num4 = 0; (num4 < this.mXRef.Count); num4 += 1)
            {
                entry1 = ((XRefEntry)this.mXRef[num4]);
                if (entry1.indirect != null)
                {
                    ((CorePDFIndirect)entry1.indirect).mId = num4;
                }
            }
        }