Exemplo n.º 1
0
 public static FieldRadioButton Create(PDFDict dict, string partial_name)
 {
     dict["FT"] = Library.CreateName("Btn");
     dict["Ff"] = Library.CreateInteger(((long)32768));
     dict["T"]  = Library.CreateString(partial_name);
     return(new FieldRadioButton(dict));
 }
Exemplo n.º 2
0
        public static AnnotationFileAttachment Create(Rect rect, string filename)
        {
            AnnotationFileAttachment attachment1 = AnnotationFileAttachment.Create(rect);

            attachment1.FileSpecification = new FileSpec(Library.CreateString(filename));
            return(attachment1);
        }
Exemplo n.º 3
0
        public static Movie Create(string filename)
        {
            Movie movie1 = new Movie(Library.CreateDict());

            movie1.FileSpecification = new FileSpec(Library.CreateString(filename));
            return(movie1);
        }
Exemplo n.º 4
0
        public static ActionLaunch Create(string file)
        {
            ActionLaunch launch1 = ActionLaunch.Create(true);

            launch1.FileSpecification = new FileSpec(Library.CreateString(file));
            return(launch1);
        }
Exemplo n.º 5
0
        public static ActionGotoR Create(bool indirect, string file, LinkDestination dest)
        {
            ActionGotoR or1 = ActionGotoR.Create(indirect);

            or1.FileSpecification = new FileSpec(Library.CreateString(file));
            or1.JumpDestination   = dest;
            return(or1);
        }
Exemplo n.º 6
0
        public static ActionLaunch Create(bool indirect, string file, WindowsLaunch parms)
        {
            ActionLaunch launch1 = ActionLaunch.Create(indirect);

            launch1.FileSpecification = new FileSpec(Library.CreateString(file));
            launch1.WinLaunch         = parms;
            return(launch1);
        }
Exemplo n.º 7
0
        public static ChoiceOptItem Create(string item)
        {
            PDFArray array1 = Library.CreateArray(2);

            array1[0] = Library.CreateString(item);
            array1[1] = Library.CreateString(item);
            return(new ChoiceOptItem(array1));
        }
Exemplo n.º 8
0
        public static ActionGotoR Create(string file, LinkDestination dest, bool newWindow)
        {
            ActionGotoR or1 = ActionGotoR.Create(true);

            or1.FileSpecification = new FileSpec(Library.CreateString(file));
            or1.JumpDestination   = dest;
            or1.NewWindow         = newWindow;
            return(or1);
        }
Exemplo n.º 9
0
        public static ActionLaunch Create(string file, WindowsLaunch parms, bool newWindow)
        {
            ActionLaunch launch1 = ActionLaunch.Create(true);

            launch1.FileSpecification = new FileSpec(Library.CreateString(file));
            launch1.WinLaunch         = parms;
            launch1.NewWindow         = newWindow;
            return(launch1);
        }
Exemplo n.º 10
0
        public static FieldCheckBox Create(string partial_name)
        {
            PDFDict dict1 = Library.CreateDict();

            dict1["FT"] = Library.CreateName("Btn");
            dict1["T"]  = Library.CreateString(partial_name);
            Library.CreateIndirect(dict1);
            return(new FieldCheckBox(dict1));
        }
Exemplo n.º 11
0
        public static MediaOffsetMarker Create(bool indirect, string namedoffset)
        {
            PDFDict dict1 = Library.CreateDict();

            dict1["M"] = Library.CreateString(namedoffset);
            if (indirect)
            {
                Library.CreateIndirect(dict1);
            }
            return(new MediaOffsetMarker(dict1));
        }
Exemplo n.º 12
0
 // Properties
 public string this[int index]
 {
     get
     {
         return((base._GetObject(index) as PDFString).Value);
     }
     set
     {
         PDFString text1 = Library.CreateString(value);
         base._SetObject(index, text1, text1.Direct);
     }
 }
Exemplo n.º 13
0
        public static PDFObject CreateObject(bool treatStringAsName, object o)
        {
            if (o == null)
            {
                return(Library.CreateNull());
            }
            Type type1 = o.GetType();

            if (type1.Equals(typeof(double)))
            {
                return(Library.CreateFixed(((double)o)));
            }
            if (type1.Equals(typeof(float)))
            {
                return(Library.CreateFixed(((double)((float)o))));
            }
            if (type1.Equals(typeof(int)))
            {
                return(Library.CreateInteger(((long)((int)o))));
            }
            if (type1.Equals(typeof(uint)))
            {
                return(Library.CreateInteger(((ulong)((uint)o))));
            }
            if (type1.Equals(typeof(string)))
            {
                if (treatStringAsName)
                {
                    return(Library.CreateName(((string)o)));
                }
                return(Library.CreateString(((string)o)));
            }
            if (type1.Equals(typeof(bool)))
            {
                return(Library.CreateBoolean(((bool)o)));
            }
            if (type1.IsArray)
            {
                return(Library.CreateArray(treatStringAsName, o));
            }
            if (type1.GetInterface("System.Collections.IDictionary", false) != null)
            {
                return(Library.CreateDict(treatStringAsName, ((IDictionary)o)));
            }
            if (type1.GetInterface("System.Collections.ICollection", false) != null)
            {
                return(Library.CreateArray(treatStringAsName, o));
            }
            throw new ArgumentException("Invalid item", "o");
        }
Exemplo n.º 14
0
        private PDFString CreateRecipientString(X509Certificate cert, UserAccessPermissions perm, int keyLength)
        {
            PDFString text1 = Library.CreateString("");
            ASN1      asn1  = new ASN1(48);

            asn1.Add(ASN1Convert.FromOID("1.2.840.113549.1.7.3"));
            ASN1 asn2 = new ASN1(160);

            byte[] numArray1 = new byte[1];
            asn2.Add(new ASN1(2, numArray1));
            ASN1 asn3 = new ASN1(48);
            ASN1 asn4 = new ASN1(48);

            asn3.Add(asn4);
            new ASN1(2, cert.GetSerialNumber());
            return(text1);
        }
Exemplo n.º 15
0
 public string this[int index]
 {
     get
     {
         if (index < this.Count)
         {
             return((this.mArr[index] as PDFString).Value);
         }
         return(null);
     }
     set
     {
         if (index < this.Count)
         {
             this.mArr[index] = Library.CreateString(value);
         }
     }
 }
Exemplo n.º 16
0
        public static Document BuildDefaultResources(string pathToFileToBuildTo)
        {
            Document document1 = Library.OpenDocument(pathToFileToBuildTo, DocOpenMode.Create);
            PDFDict  dict1     = document1.Info;

            dict1["Title"]  = Library.CreateString("Standard Resources Container for PDFO.NET based projects");
            dict1["Author"] = Library.CreateString("Victor Vishnyakov via PDFO.NET");
            Page page1 = document1.Pages.Add();

            page1.MediaBox = new Rect(0f, 0f, 612f, 792f);
            Resource resource1 = document1.Resources[Library.BuildStandardFont(document1, "Helvetica"), typeof(Font)];

            page1.Resources.Add("HELVETICA", resource1);
            resource1 = document1.Resources[Library.BuildStandardFont(document1, "Times-Roman"), typeof(Font)];
            page1.Resources.Add("TIMES_ROMAN", resource1);
            resource1 = document1.Resources[Library.BuildStandardFont(document1, "Times-Bold"), typeof(Font)];
            page1.Resources.Add("TIMES_BOLD", resource1);
            resource1 = document1.Resources[Library.BuildStandardFont(document1, "Courier"), typeof(Font)];
            page1.Resources.Add("COURIER", resource1);
            resource1 = document1.Resources[Library.BuildStandardFont(document1, "Symbol"), typeof(Font)];
            page1.Resources.Add("SYMBOL", resource1);
            resource1 = document1.Resources[Library.BuildStandardFont(document1, "Helvetica-Bold"), typeof(Font)];
            page1.Resources.Add("HELVETICA_BOLD", resource1);
            resource1 = document1.Resources[Library.BuildStandardFont(document1, "Courier-Bold"), typeof(Font)];
            page1.Resources.Add("COURIER_BOLD", resource1);
            resource1 = document1.Resources[Library.BuildStandardFont(document1, "ZapfDingbats"), typeof(Font)];
            page1.Resources.Add("ZAPFDINGBATS", resource1);
            resource1 = document1.Resources[Library.BuildStandardFont(document1, "Times-Italic"), typeof(Font)];
            page1.Resources.Add("TIMES_ITALIC", resource1);
            resource1 = document1.Resources[Library.BuildStandardFont(document1, "Helvetica-Oblique"), typeof(Font)];
            page1.Resources.Add("HELVETICA_OBLIQUE", resource1);
            resource1 = document1.Resources[Library.BuildStandardFont(document1, "Courier-Oblique"), typeof(Font)];
            page1.Resources.Add("COURIER_OBLIQUE", resource1);
            resource1 = document1.Resources[Library.BuildStandardFont(document1, "Times-BoldItalic"), typeof(Font)];
            page1.Resources.Add("TIMES_BOLDITALIC", resource1);
            resource1 = document1.Resources[Library.BuildStandardFont(document1, "Helvetica-BoldOblique"), typeof(Font)];
            page1.Resources.Add("HELVETICA_BOLDOBLIQUE", resource1);
            resource1 = document1.Resources[Library.BuildStandardFont(document1, "Courier-BoldOblique"), typeof(Font)];
            page1.Resources.Add("COURIER_BOLDOBLIQUE", resource1);
            return(document1);
        }
Exemplo n.º 17
0
        public static Altsoft.PDFO.Font EmbedFont(Document doc, Stream fontstream, string encoding, bool embedFontFile, bool isVertical)
        {
            int      num2;
            PDFArray array2;
            int      num10;

            Altsoft.FTMB.Font font1 = Altsoft.FTMB.Font.OpenFont(fontstream);
            if ((font1.FontType != FontType.TrueTypeFontT) || (encoding != "Unicode"))
            {
                return(null);
            }
            TrueTypeFont font2 = (font1 as TrueTypeFont);
            double       num1  = ((double)font2.UnitsPerEm);
            PDFDict      dict1 = Library.CreateDict();

            dict1["Type"]     = Library.CreateName("Font");
            dict1["Subtype"]  = Library.CreateName("CIDFontType2");
            dict1["BaseFont"] = Library.CreateName(font2.FontName);
            PDFDict dict2 = Library.CreateDict();

            dict2["Registry"]      = Library.CreateString("Adobe");
            dict2["Ordering"]      = Library.CreateString("Identity");
            dict2["Supplement"]    = Library.CreateInteger(((long)0));
            dict1["CIDSystemInfo"] = dict2;
            TTEncoding encoding1 = null;

            for (num2 = 0; ((num2 < font2.Encodings.Count) && (encoding1 == null)); num2 += 1)
            {
                encoding1 = ((TTEncoding)font2.Encodings[num2]);
                if ((encoding1.platformID != 3) || ((encoding1.specificID != 1) && (encoding1.specificID != 0)))
                {
                    encoding1 = null;
                }
            }
            if (encoding1 == null)
            {
                return(null);
            }
            dict1["DW"] = Library.CreateInteger(((long)((((double)font2.GetWidth(encoding1.GetGID(0))) * 1000f) / num1)));
            int      num3   = 0;
            int      num4   = encoding1.GetLastCharCode(ref num3);
            int      num5   = encoding1.GetFirstCharCode(ref num3);
            PDFArray array1 = Library.CreateArray(0);

            if (num5 != 0)
            {
                array1.Add(Library.CreateInteger(((long)0)));
                array2 = Library.CreateArray(0);
                array2.Add(Library.CreateInteger(((long)((((double)font2.GetWidth(0, 3, 1)) * 1000f) / num1))));
                array1.Add(array2);
            }
            array1.Add(Library.CreateInteger(((long)num5)));
            array2 = Library.CreateArray(0);
            array2.Add(Library.CreateInteger(((long)((((double)font2.GetWidth(num3)) * 1000f) / num1))));
            int num6 = num5;

            while ((num5 != num4))
            {
                num5 = encoding1.GetNextCharCode(num5, ref num3);
                if (num5 != (num6 + 1))
                {
                    array1.Add(array2);
                    array1.Add(Library.CreateInteger(((long)num5)));
                    array2 = Library.CreateArray(0);
                }
                num6 = num5;
                array2.Add(Library.CreateInteger(((long)((((double)font2.GetWidth(num3)) * 1000f) / num1))));
            }
            array1.Add(array2);
            dict1["W"] = array1;
            Stream stream1 = new MemoryStream();
            int    num7    = encoding1.GetFirstCharCode(ref num3);
            int    num8    = 0;

            while ((num8 < num7))
            {
                stream1.WriteByte(0);
                stream1.WriteByte(0);
                num8 += 1;
            }
            stream1.WriteByte(((byte)(num3 / 256)));
            stream1.WriteByte(((byte)(num3 % 256)));
            num8 += 1;
            int num9 = encoding1.GetLastCharCode(ref num3);

            do
            {
                num7 = encoding1.GetNextCharCode(num7, ref num3);
                while ((num8 < num7))
                {
                    stream1.WriteByte(0);
                    stream1.WriteByte(0);
                    num8 += 1;
                }
                stream1.WriteByte(((byte)(num3 / 256)));
                stream1.WriteByte(((byte)(num3 % 256)));
                num8 += 1;
            }while ((num7 != num9));
            stream1.Position = ((long)0);
            PDFDict dict3 = Library.CreateDict();

            dict3["Filter"] = Library.CreateName("FlateDecode");
            PDFStream stream2 = Library.CreateStream(stream1, dict3);

            dict1["CIDToGIDMap"] = doc.Indirects.New(stream2);
            PDFDict dict4 = Library.CreateDict();

            dict4["Type"]     = Library.CreateName("FontDescriptor");
            dict4["FontName"] = Library.CreateName(font2.FontName);
            dict4["Flags"]    = Library.CreateInteger(((long)4));
            PDFArray array3 = Library.CreateArray(4);

            for (num10 = 0; (num10 < 4); num10 += 1)
            {
                array3[num10] = Library.CreateInteger(((long)font2.FontBBox[num10]));
            }
            dict4["FontBBox"]    = array3;
            dict4["ItalicAngle"] = Library.CreateFixed(font2.ItalicAngle);
            dict4["Ascent"]      = Library.CreateInteger(((long)font2.FontBBox[3]));
            dict4["Descent"]     = Library.CreateInteger(((long)font2.FontBBox[1]));
            dict4["CapHeight"]   = Library.CreateInteger(((long)font2.FontBBox[3]));
            dict4["StemV"]       = Library.CreateInteger(((long)0));
            if (((font2.EmbeddingRights == 0) || ((font2.EmbeddingRights & 8) != 0)) && embedFontFile)
            {
                font2.FontStream.Position = ((long)0);
                dict3              = Library.CreateDict();
                dict3["Filter"]    = Library.CreateName("FlateDecode");
                dict3["Length1"]   = Library.CreateInteger(font2.FontStream.Length);
                dict4["FontFile2"] = doc.Indirects.New(Library.CreateStream(font2.FontStream, dict3));
            }
            dict1["FontDescriptor"] = doc.Indirects.New(dict4);
            PDFDict dict5 = Library.CreateDict();

            dict5["Type"]     = Library.CreateName("Font");
            dict5["Subtype"]  = Library.CreateName("Type0");
            dict5["BaseFont"] = Library.CreateName(font2.FontName);
            if (!isVertical)
            {
                dict5["Encoding"] = Library.CreateName("Identity-H");
            }
            else
            {
                dict5["Encoding"] = Library.CreateName("Identity-V");
            }
            PDFArray array4 = Library.CreateArray(1);

            array4[0] = doc.Indirects.New(dict1);
            dict5["DescendantFonts"] = array4;
            return(new FontType0(dict5));
        }
Exemplo n.º 18
0
 private void BuildString()
 {
     this.mStr = Library.CreateString(Date.GetPDFString(this.mDateTime));
 }
Exemplo n.º 19
0
 public Date(DateTime dt)
 {
     this.mDateTime = dt;
     this.mStr      = Library.CreateString("");
     this.BuildString();
 }
Exemplo n.º 20
0
        public void AddWatermarks(Page page)
        {
            PDFStream stream1;
            Stream    stream2;
            PDFStream stream3;
            Stream    stream4;
            PDFStream stream5;
            Stream    stream6;
            PDFStream stream7;
            Stream    stream8;
            object    obj1;
            DateTime  time1;

            this.m_sContents = "";
            if (this.m_bAdd_qQ_ToOrigSc)
            {
                this.m_sContents = this.m_sContents + "\nQ";
            }
            this.mPage = page;
            page.Resources.Add(this.m_sLogoFont, this.mWTM_LogoFont);
            PDFDict dict1 = Library.CreateDict();

            dict1["S"]   = Library.CreateName("URI");
            dict1["URI"] = Library.CreateString("http://www.alt-soft.com/");
            PDFIndirect indirect1 = this.mPage.Dict.Doc.Indirects.New(dict1);
            int         num1      = this.mPage.Rotate;
            double      num2      = (this.mPage.CropBox.Left + (this.mPage.CropBox.Width / 2f));
            double      num3      = (this.mPage.CropBox.Bottom + (this.mPage.CropBox.Height / 2f));
            double      num4      = ((this.mPage.CropBox.Width - this.mPage.CropBox.Height) / 2f);
            int         num5      = num1;

            if (num5 <= 90)
            {
                if (num5 == 0)
                {
                    goto Label_02F9;
                }
                if (num5 == 90)
                {
                    goto Label_015E;
                }
                goto Label_02EE;
            }
            if (num5 == 180)
            {
                goto Label_01E2;
            }
            if (num5 == 270)
            {
                goto Label_026E;
            }
            goto Label_02EE;
Label_015E:
            obj1 = this.m_sContents;
            object[] objArray1 = new object[6];
            objArray1[0] = obj1;
            objArray1[1] = "0 1 -1 0 ";
            double num6 = ((num2 + num3) + num4);

            objArray1[2]     = num6.ToString("N", this.mNumberFormat);
            objArray1[3]     = 32;
            num6             = ((-num2 + num3) + num4);
            objArray1[4]     = num6.ToString("N", this.mNumberFormat);
            objArray1[5]     = " cm\n";
            this.m_sContents = objArray1;
            goto Label_02F9;
Label_01E2:
            obj1             = this.m_sContents;
            objArray1        = new object[6];
            objArray1[0]     = obj1;
            objArray1[1]     = "-1 0 0 -1 ";
            num6             = (2f * num2);
            objArray1[2]     = num6.ToString("N", this.mNumberFormat);
            objArray1[3]     = 32;
            num6             = (2f * num3);
            objArray1[4]     = num6.ToString("N", this.mNumberFormat);
            objArray1[5]     = " cm\n";
            this.m_sContents = objArray1;
            goto Label_02F9;
Label_026E:
            obj1             = this.m_sContents;
            objArray1        = new object[6];
            objArray1[0]     = obj1;
            objArray1[1]     = "0 -1 1 0 ";
            num6             = ((num2 - num3) - num4);
            objArray1[2]     = num6.ToString("N", this.mNumberFormat);
            objArray1[3]     = 32;
            num6             = ((num2 + num3) - num4);
            objArray1[4]     = num6.ToString("N", this.mNumberFormat);
            objArray1[5]     = " cm\n";
            this.m_sContents = objArray1;
            goto Label_02F9;
Label_02EE:
            throw new FormatException("Rotate parameter should be a multiple of 90");
Label_02F9:
            time1 = DateTime.Now;
            new Random(time1.Millisecond);
            this.AddLogo(indirect1);
            this.AddTextLogo(indirect1);
            PDFArray array1 = Library.CreateArray(1);

            array1[0] = Library.CreateName("FlateDecode");
            string text1 = "q\n";

            if (this.m_bAdd_qQ_ToOrigSc)
            {
                if (this.m_bWMAsNewStream)
                {
                    page.Contents.InsertStream(text1, 0);
                    stream1 = page.Contents.GetPDFStream(0);
                    stream2 = stream1.Decode();
                    stream1.Dict["Filter"] = page.Dict.Doc.CloneObject(array1);
                    stream1.Dict.Remove("DecodeParms");
                    stream1.Encode(stream2);
                }
                else
                {
                    page.Contents.AppendStream(text1, "", 0);
                    stream3 = page.Contents.GetPDFStream(0);
                    stream4 = stream3.Decode();
                    stream3.Dict["Filter"] = page.Dict.Doc.CloneObject(array1);
                    stream3.Dict.Remove("DecodeParms");
                    stream3.Encode(stream4);
                }
            }
            if (this.m_bWMAsNewStream)
            {
                page.Contents.AddStream(this.m_sContents);
                stream5 = page.Contents.GetPDFStream((page.Contents.Count - 1));
                stream6 = stream5.Decode();
                stream5.Dict["Filter"] = page.Dict.Doc.CloneObject(array1);
                stream5.Dict.Remove("DecodeParms");
                stream5.Encode(stream6);
            }
            else
            {
                page.Contents.AppendStream("", this.m_sContents, (page.Contents.Count - 1));
                stream7 = page.Contents.GetPDFStream((page.Contents.Count - 1));
                stream8 = stream7.Decode();
                stream7.Dict["Filter"] = page.Dict.Doc.CloneObject(array1);
                stream7.Dict.Remove("DecodeParms");
                stream7.Encode(stream8);
            }
            this.mPage = null;
        }
Exemplo n.º 21
0
        protected internal virtual PDFDirect CopyHandlerDirect(PDFDirect src, CopyHandlerDelegate ch)
        {
            PDFObject obj1;
            PDFArray  array1;
            PDFArray  array2;
            int       num1;
            PDFDict   dict1;
            PDFDict   dict2;
            PDFStream stream1;
            PDFStream stream2;

            if (ch != null)
            {
                obj1 = ch.Invoke(this.dstDoc, src);
                if ((obj1 is PDFDirect))
                {
                    src = ((PDFDirect)obj1);
                }
                else
                {
                    throw new PDFException("Can\'t convert direct into indirect");
                }
            }
            PDFObjectType type1 = src.PDFType;

            switch (type1)
            {
            case PDFObjectType.tPDFNull:
            {
                goto Label_0155;
            }

            case PDFObjectType.tPDFInteger:
            {
                goto Label_0133;
            }

            case PDFObjectType.tPDFFixed:
            {
                goto Label_0122;
            }

            case PDFObjectType.tPDFBoolean:
            {
                goto Label_00A2;
            }

            case PDFObjectType.tPDFName:
            {
                goto Label_0144;
            }

            case PDFObjectType.tPDFString:
            {
                goto Label_01E7;
            }

            case PDFObjectType.tPDFDict:
            {
                dict1 = (src as PDFDict);
                dict2 = Library.CreateDict();
                foreach (PDFName name1 in dict1.Keys)
                {
                    dict2[name1.Value] = this.CopyHandler(dict1[name1, 0], ch);
                }
                return(dict2);
            }

            case PDFObjectType.tPDFArray:
            {
                array1 = (src as PDFArray);
                array2 = Library.CreateArray(array1.Count);
                num1   = 0;
                goto Label_0097;
            }

            case PDFObjectType.tPDFStream:
            {
                stream1 = (src as PDFStream);
                stream2 = Library.CreateStream();
                foreach (PDFName name2 in stream1.Dict.Keys)
                {
                    stream2.Dict[name2.Value] = this.CopyHandler(stream1.Dict[name2, 0], ch);
                }
                stream2.SetRawStream(stream1.Decrypt());
                return(stream2);
            }
            }
            goto Label_01F8;
Label_007D:
            array2[num1] = this.CopyHandler(array1[num1, 0], ch);
            num1        += 1;
Label_0097:
            if (num1 < array1.Count)
            {
                goto Label_007D;
            }
            return(array2);

Label_00A2:
            return(Library.CreateBoolean((src as PDFBoolean).Value));

Label_0122:
            return(Library.CreateFixed((src as PDFFixed).Value));

Label_0133:
            return(Library.CreateInteger((src as PDFInteger).Value));

Label_0144:
            return(Library.CreateName((src as PDFName).Value));

Label_0155:
            return(Library.CreateNull());

Label_01E7:
            return(Library.CreateString((src as PDFString).Value));

Label_01F8:
            throw new Exception("Invalid object type");
        }
Exemplo n.º 22
0
 public void Add(string value)
 {
     this.mArr.Add(Library.CreateString(value));
 }
Exemplo n.º 23
0
        public static PDFObject DefaultCopyHandler(Document dstDoc, PDFObject src)
        {
            PDFIndirect indirect1;
            PDFStream   stream1;

            if (src == null)
            {
                return(Library.CreateNull());
            }
            if ((src is PDFIndirect))
            {
                indirect1        = dstDoc.Indirects.New();
                indirect1.Direct = ((PDFDirect)Document.DefaultCopyHandler(dstDoc, src.Direct));
                return(indirect1);
            }
            PDFDirect     direct1 = null;
            PDFDirect     direct2 = ((PDFDirect)src);
            PDFObjectType type1   = src.PDFType;

            switch (type1)
            {
            case PDFObjectType.tPDFNull:
            {
                return(Library.CreateNull());
            }

            case PDFObjectType.tPDFInteger:
            {
                return(Library.CreateInteger(((PDFInteger)direct2).Value));
            }

            case PDFObjectType.tPDFFixed:
            {
                return(Library.CreateFixed(((PDFFixed)direct2).Value));
            }

            case PDFObjectType.tPDFBoolean:
            {
                return(Library.CreateBoolean(((PDFBoolean)direct2).Value));
            }

            case PDFObjectType.tPDFName:
            {
                return(Library.CreateName(((PDFName)direct2).Value));
            }

            case PDFObjectType.tPDFString:
            {
                return(Library.CreateString(((PDFString)direct2).Value));
            }

            case PDFObjectType.tPDFDict:
            case PDFObjectType.tPDFArray:
            {
                goto Label_0108;
            }

            case PDFObjectType.tPDFStream:
            {
                stream1 = ((PDFStream)direct2);
                return(Library.CreateStream(stream1.Decrypt(), ((PDFDict)dstDoc.CloneObject(stream1.Dict)), false));
            }
            }
Label_0108:
            return(Library.CreateDirect(src.PDFType));
        }
Exemplo n.º 24
0
 public static PDFString S(byte[] s)
 {
     return(Library.CreateString(Utils.BytesToString(s)));
 }
Exemplo n.º 25
0
        public PDFObject ReadNextObject()
        {
            int       num1;
            PDFArray  array1;
            PDFObject obj1;
            bool      flag1;
            int       num2;
            int       num3;
            int       num4;
            PDFObject obj3;
            PDFObject obj4;
            PDFObject obj5;
            TokenType type1 = base.GetNextToken();

            switch (type1)
            {
            case ((TokenType)0):
            {
                goto Label_00DC;
            }

            case ((TokenType)1):
            {
                if (this.m_sName == "null")
                {
                    return(Library.CreateNull());
                }
                goto Label_009E;
            }

            case ((TokenType)2):
            case ((TokenType)11):
            {
                goto Label_006E;
            }

            case ((TokenType)3):
            {
                goto Label_0230;
            }

            case ((TokenType)4):
            {
                if (this.m_iDictCounter == 0)
                {
                    throw new PDFParserException("Invalid end of dict found!");
                }
                this.m_iDictCounter -= 1;
                return(Library.CreateDict());
            }

            case ((TokenType)5):
            {
                this.m_iArrCounter += 1;
                num1   = this.m_iArrCounter;
                array1 = Library.CreateArray(0);
                flag1  = true;
                do
                {
                    obj1 = this.ReadNextObject();
                    if (num1 != this.m_iArrCounter)
                    {
                        flag1 = false;
                    }
                    else if (obj1.PDFType == PDFObjectType.tPDFName)
                    {
                        num2 = array1.Count;
                        if (((((PDFName)obj1).Value == "R") || (((PDFName)obj1).Value == "r")) && (((num2 >= 2) && (array1[(num2 - 1)].PDFType == PDFObjectType.tPDFInteger)) && (array1[(num2 - 2)].PDFType == PDFObjectType.tPDFInteger)))
                        {
                            num3 = ((PDFInteger)array1[(num2 - 2)]).Int32Value;
                            num4 = ((PDFInteger)array1[(num2 - 1)]).Int32Value;
                            array1.Add(this.m_doc.CreateIndirectObject(num3, num4));
                            array1.RemoveAt((num2 - 1));
                            array1.RemoveAt((num2 - 2));
                        }
                        else
                        {
                            array1.Add(obj1);
                        }
                    }
                    else
                    {
                        array1.Add(obj1);
                    }
                }while (flag1);
                return(array1);
            }

            case ((TokenType)6):
            {
                if (this.m_iArrCounter == 0)
                {
                    throw new PDFParserException("Invalid end of array found!");
                }
                this.m_iArrCounter -= 1;
                return(Library.CreateArray(0));
            }

            case ((TokenType)7):
            {
                goto Label_00E8;
            }

            case ((TokenType)8):
            {
                goto Label_007A;
            }

            case ((TokenType)9):
            {
                goto Label_036E;
            }

            case ((TokenType)10):
            {
                goto Label_0053;
            }

            case ((TokenType)12):
            {
                goto Label_0048;
            }
            }
            goto Label_0379;
Label_0048:
            throw new PDFParserException("Invalid token encountered");
Label_0053:
            if (this.SkipComments)
            {
                return(this.ReadNextObject());
            }
            return(Library.CreateString(this.m_sName));

Label_006E:
            return(Library.CreateString(this.m_sName));

Label_007A:
            return(Library.CreateFixed(this.m_dReal));

Label_009E:
            if (this.m_sName == "false")
            {
                return(Library.CreateBoolean(false));
            }
            if (this.m_sName == "true")
            {
                return(Library.CreateBoolean(true));
            }
            return(Library.CreateName(this.m_sName));

Label_00DC:
            return(Library.CreateName(this.m_sName));

Label_00E8:
            return(Library.CreateInteger(this.m_iInteger));

Label_0230:
            this.m_iDictCounter += 1;
            PDFDict   dict1 = Library.CreateDict();
            bool      flag2 = true;
            PDFObject obj2  = this.ReadNextObject();

Label_0250:
            if (obj2.PDFType == PDFObjectType.tPDFDict)
            {
                flag2 = false;
            }
            else
            {
                if (obj2.PDFType != PDFObjectType.tPDFName)
                {
                    throw new PDFParserException("Invalid key entry found!");
                }
                obj3 = this.ReadNextObject();
                obj4 = this.ReadNextObject();
                if ((obj4.PDFType == PDFObjectType.tPDFInteger) && (obj3.PDFType == PDFObjectType.tPDFInteger))
                {
                    obj5 = this.ReadNextObject();
                    if ((obj5.PDFType == PDFObjectType.tPDFName) && ((((PDFName)obj5).Value == "R") || (((PDFName)obj5).Value == "r")))
                    {
                        dict1[((PDFName)obj2)] = this.m_doc.CreateIndirectObject(((PDFInteger)obj3).Int32Value, ((PDFInteger)obj4).Int32Value);
                        obj2 = this.ReadNextObject();
                        goto Label_033D;
                    }
                    throw new PDFParserException("Invalid dict entry!");
                }
                dict1[((PDFName)obj2)] = obj3;
                obj2 = obj4;
            }
Label_033D:
            if (flag2)
            {
                goto Label_0250;
            }
            return(dict1);

Label_036E:
            throw new PDFParserException("Unexpected end of file found!");
Label_0379:
            throw new PDFParserException("Fatal ERROR!");
        }
Exemplo n.º 26
0
        public static PDFDirect CreateDirect(PDFObjectType type)
        {
            PDFObjectType type1 = type;

            switch (type1)
            {
            case PDFObjectType.tPDFNull:
            {
                goto Label_0060;
            }

            case PDFObjectType.tPDFInteger:
            {
                goto Label_004D;
            }

            case PDFObjectType.tPDFFixed:
            {
                goto Label_003E;
            }

            case PDFObjectType.tPDFBoolean:
            {
                goto Label_0031;
            }

            case PDFObjectType.tPDFName:
            {
                goto Label_0055;
            }

            case PDFObjectType.tPDFString:
            {
                goto Label_0066;
            }

            case PDFObjectType.tPDFDict:
            {
                goto Label_0038;
            }

            case PDFObjectType.tPDFArray:
            {
                goto Label_002A;
            }
            }
            goto Label_0071;
Label_002A:
            return(Library.CreateArray(0));

Label_0031:
            return(Library.CreateBoolean(false));

Label_0038:
            return(Library.CreateDict());

Label_003E:
            return(Library.CreateFixed(0f));

Label_004D:
            return(Library.CreateInteger(((long)0)));

Label_0055:
            return(Library.CreateName(""));

Label_0060:
            return(Library.CreateNull());

Label_0066:
            return(Library.CreateString(""));

Label_0071:
            throw new ArgumentOutOfRangeException("type", type, "Invalid direct type");
        }
Exemplo n.º 27
0
 public static FieldCheckBox Create(PDFDict dict, string partial_name)
 {
     dict["FT"] = Library.CreateName("Btn");
     dict["T"]  = Library.CreateString(partial_name);
     return(new FieldCheckBox(dict));
 }