Exemplo n.º 1
0
        public static OutlineItem Create()
        {
            PDFDict dict1 = Library.CreateDict();

            dict1["Type"]  = PDF.N("Outlines");
            dict1["Count"] = PDF.O(0);
            Library.CreateIndirect(dict1);
            return(Resources.Get(dict1, typeof(OutlineItem)) as OutlineItem);
        }
Exemplo n.º 2
0
        public static ColorSpaceDeviceCMYK Create(bool indirect)
        {
            ColorSpaceDeviceCMYK ecmyk1 = (Resources.Get(PDF.N("DeviceCMYK"), typeof(ColorSpaceDeviceCMYK)) as ColorSpaceDeviceCMYK);

            if (indirect)
            {
                Library.CreateIndirect(ecmyk1.Direct);
            }
            return(ecmyk1);
        }
Exemplo n.º 3
0
        public static XObjectPS Create(Stream ps)
        {
            PDFDict dict1 = Library.CreateDict();

            dict1["Type"]    = PDF.N("XObject");
            dict1["Subtype"] = PDF.N("PS");
            PDFStream stream1 = Library.CreateStream(ps, dict1);

            return(Resources.Get(stream1, typeof(XObjectPS)) as XObjectPS);
        }
Exemplo n.º 4
0
        public static ColorSpaceDeviceGray Create(bool indirect)
        {
            ColorSpaceDeviceGray gray1 = (Resources.Get(PDF.N("DeviceGray"), typeof(ColorSpaceDeviceGray)) as ColorSpaceDeviceGray);

            if (indirect)
            {
                Library.CreateIndirect(gray1.Direct);
            }
            return(gray1);
        }
Exemplo n.º 5
0
        public static ColorSpaceDeviceRGB Create(bool indirect)
        {
            ColorSpaceDeviceRGB ergb1 = (Resources.Get(PDF.N("DeviceRGB"), typeof(ColorSpaceDeviceRGB)) as ColorSpaceDeviceRGB);

            if (indirect)
            {
                Library.CreateIndirect(ergb1.Direct);
            }
            return(ergb1);
        }
Exemplo n.º 6
0
        public static ColorSpacePattern Create(bool indirect, ColorSpace baseCS)
        {
            PDFArray array1 = Library.CreateArray(2);

            array1[0] = PDF.N("Pattern");
            ColorSpacePattern pattern1 = (Resources.Get(array1, typeof(ColorSpacePattern)) as ColorSpacePattern);

            if (indirect)
            {
                Library.CreateIndirect(array1);
            }
            return(pattern1);
        }
Exemplo n.º 7
0
        public static ColorSpaceDeviceN Create(bool indirect, params string[] sepNames)
        {
            PDFArray array1 = Library.CreateArray(4);

            array1[0] = PDF.N("DeviceN");
            array1[1] = Library.CreateObject(true, sepNames);
            ColorSpaceDeviceN en1 = (Resources.Get(array1, typeof(ColorSpaceDeviceN)) as ColorSpaceDeviceN);

            if (indirect)
            {
                Library.CreateIndirect(array1);
            }
            return(en1);
        }
Exemplo n.º 8
0
        public PDFDict CreateEncryptionDict(Document doc)
        {
            PDFDict dict1 = Library.CreateDict();

            this.mDocId     = doc.Id1;
            dict1["V"]      = PDF.O(2);
            dict1["O"]      = PDF.S(this.OEntry);
            dict1["U"]      = PDF.S(this.UEntry);
            dict1["R"]      = PDF.O(this.Rev);
            dict1["P"]      = PDF.O(this.UserPermissions);
            dict1["Length"] = PDF.O(this.KeyLength);
            dict1["Filter"] = PDF.N("Standard");
            return(dict1);
        }
Exemplo n.º 9
0
        public static ColorSpaceSeparation Create(bool indirect, string name)
        {
            PDFArray array1 = Library.CreateArray(4);

            array1[0] = PDF.N("Separation");
            array1[1] = PDF.N(name);
            ColorSpaceSeparation separation1 = (Resources.Get(array1, typeof(ColorSpaceSeparation)) as ColorSpaceSeparation);

            if (indirect)
            {
                Library.CreateIndirect(array1);
            }
            return(separation1);
        }
Exemplo n.º 10
0
        public static ColorSpaceICCBased Create(Document doc, bool indirect, Stream profile, params string[] encoding)
        {
            PDFArray array2;
            int      num2;
            PDFArray array1 = Library.CreateArray(2);

            array1[0] = PDF.N("ICCBased");
            PDFStream stream1 = Library.CreateStream();

            byte[] numArray1 = new byte[30];
            profile.Position = ((long)0);
            int num1 = profile.Read(numArray1, 0, 30);

            if (num1 == 0)
            {
                throw new Exception("Empty ICC profile");
            }
            string text1 = Utils.BytesToString(numArray1);

            if (text1.IndexOf("GRAY") != -1)
            {
                stream1.Dict["N"] = Library.CreateInteger(((long)1));
            }
            if (text1.IndexOf("RGB") != -1)
            {
                stream1.Dict["N"] = Library.CreateInteger(((long)3));
            }
            if (text1.IndexOf("CMYK") != -1)
            {
                stream1.Dict["N"] = Library.CreateInteger(((long)4));
            }
            if ((encoding != null) && (encoding.Length > 0))
            {
                array2 = Library.CreateArray(encoding.Length);
                stream1.Dict["Filter"] = array2;
                for (num2 = 0; (num2 < encoding.Length); num2 += 1)
                {
                    array2[num2] = PDF.N(encoding[num2]);
                }
            }
            stream1.Encode(profile);
            array1[1] = doc.Indirects.New(stream1);
            ColorSpaceICCBased based1 = (Resources.Get(array1, typeof(ColorSpaceICCBased)) as ColorSpaceICCBased);

            if (indirect)
            {
                doc.Indirects.New(array1);
            }
            return(based1);
        }
Exemplo n.º 11
0
        public static ColorSpaceIndexed Create(bool indirect, ColorSpace baseCS)
        {
            PDFArray array1 = Library.CreateArray(4);

            array1[0] = PDF.N("Indexed");
            array1[1] = baseCS.Direct;
            array1[2] = PDF.O(0);
            array1[3] = PDF.O("");
            ColorSpaceIndexed indexed1 = (Resources.Get(array1, typeof(ColorSpaceIndexed)) as ColorSpaceIndexed);

            if (indirect)
            {
                Library.CreateIndirect(indexed1.Direct);
            }
            return(indexed1);
        }
Exemplo n.º 12
0
        public static ColorSpaceCalRGB Create(bool indirect, double[] whitePoint)
        {
            PDFArray array1 = Library.CreateArray(2);

            array1[0] = PDF.N("CalRGB");
            PDFDict dict1 = Library.CreateDict();

            array1[1]           = dict1;
            dict1["WhitePoint"] = PDF.O(whitePoint);
            ColorSpaceCalRGB lrgb1 = (Resources.Get(array1, typeof(ColorSpaceCalRGB)) as ColorSpaceCalRGB);

            if (indirect)
            {
                Library.CreateIndirect(array1);
            }
            return(lrgb1);
        }
Exemplo n.º 13
0
        public static EncryptionPKCS Create(X509Certificate[] certs, UserAccessPermissions[] perms, int keyLength)
        {
            int            num1;
            Random         random1 = new Random();
            EncryptionPKCS npkcs1  = new EncryptionPKCS();

            npkcs1.mSeed = new byte[20];
            random1.NextBytes(npkcs1.mSeed);
            npkcs1.mDict      = Library.CreateDict();
            npkcs1.mDict["V"] = PDF.O(2);
            npkcs1.mDict["R"] = PDF.O(1);
            PDFArray array1 = Library.CreateArray();

            npkcs1.mDict["Recipients"] = array1;
            for (num1 = 0; (num1 < certs.Length); num1 += 1)
            {
                array1.Add(npkcs1.CreateRecipientString(certs[num1], perms[num1], keyLength));
            }
            npkcs1.mDict["Length"] = PDF.O(keyLength);
            npkcs1.mDict["Filter"] = PDF.N("Adobe.PubSec");
            return(npkcs1);
        }
Exemplo n.º 14
0
        public static XObjectImage Create(Document doc, Bitmap img, params string[] encoding)
        {
            int       num3;
            int       num4;
            int       num5;
            Color     color1;
            int       num6;
            PDFArray  array1;
            int       num7;
            int       num8;
            PDFStream stream1 = Library.CreateStream();
            PDFDict   dict1   = stream1.Dict;

            dict1["Width"]   = PDF.O(img.Width);
            dict1["Height"]  = PDF.O(img.Height);
            dict1["Subtype"] = PDF.N("Image");
            dict1["Type"]    = PDF.N("XObject");
            byte[]           numArray1 = null;
            BitArrayAccessor accessor1 = null;
            int num1 = 0;
            int num2 = 0;

            if (doc == null)
            {
                doc = Library.Resources.Doc;
            }
            XObjectImage image1 = ((XObjectImage)doc.Resources[doc.Indirects.New(stream1), typeof(XObjectImage)]);

            image1.ColorSpace = ColorSpaceDeviceRGB.Create();
            numArray1         = new byte[((3 * img.Width) * img.Height)];
            num1 = 8;
            num2 = (3 * img.Width);
            dict1["BitsPerComponent"] = PDF.O(8);
            for (num3 = 0; (num3 < img.Height); num3 += 1)
            {
                num4      = 0;
                accessor1 = new BitArrayAccessor(numArray1, ((num3 * num2) * 8), num1, false);
                for (num5 = 0; (num5 < img.Width); num5 += 1)
                {
                    color1 = img.GetPixel(num5, num3);
                    num6   = 0;
                    while ((num6 < 3))
                    {
                        num8 = num6;
                        switch (num8)
                        {
                        case 0:
                        {
                            int num9 = num4;
                            num4            = (num9 + 1);
                            accessor1[num4] = ((long)((ulong)color1.R));
                            goto Label_0180;
                        }

                        case 1:
                        {
                            int num10 = num4;
                            num4            = (num10 + 1);
                            accessor1[num4] = ((long)((ulong)color1.G));
                            goto Label_0180;
                        }

                        case 2:
                        {
                            goto Label_016B;
                        }
                        }
                        goto Label_0180;
Label_016B:
                        int num11       = num4;
                        num4            = (num11 + 1);
                        accessor1[num4] = ((long)((ulong)color1.B));
Label_0180:
                        num6 += 1;
                    }
                }
            }
            MemoryStream stream2 = new MemoryStream(numArray1);

            if (encoding.Length > 0)
            {
                array1 = Library.CreateArray(encoding.Length);
                stream1.Dict["Filter"] = array1;
                for (num7 = 0; (num7 < encoding.Length); num7 += 1)
                {
                    array1[num7] = PDF.N(encoding[num7]);
                }
            }
            stream1.Encode(stream2);
            return(image1);
        }