Esempio n. 1
0
        private void PageEnumProc(PDFDict dict)
        {
            int      num1;
            PDFArray array1;
            PDFDict  dict1;
            PDFName  name1;

            try
            {
                num1   = 0;
                array1 = (dict["Kids"] as PDFArray);
                foreach (PDFObject obj1 in array1)
                {
                    dict1 = (obj1.Direct as PDFDict);
                    name1 = (dict1["Type"].Direct as PDFName);
                    if (name1.Value == "Pages")
                    {
                        this.PageEnumProc(dict1);
                    }
                    if (name1.Value != "Page")
                    {
                        continue;
                    }
                    this.mPagesColl.Add(dict1);
                    num1 += 1;
                }
            }
            catch (InvalidCastException)
            {
            }
            catch (NullReferenceException)
            {
            }
        }
Esempio n. 2
0
        internal static Resource Factory(PDFDirect d)
        {
            PDFName name1;
            PDFDict dict1 = (d as PDFStream).Dict;
            string  text1 = (dict1["Subtype"] as PDFName).Value;

            if (text1 == "Image")
            {
                return(new XObjectImage(d));
            }
            if (text1 == "Form")
            {
                name1 = (dict1["SubType2"] as PDFName);
                if (name1 == null)
                {
                    return(new XObjectForm(d));
                }
                if (name1.Value == "PS")
                {
                    return(new XObjectPS(d));
                }
                return(new XObjectForm(d));
            }
            if (text1 == "PS")
            {
                return(new XObjectPS(d));
            }
            throw new PDFSyntaxException(d, "Invalid XObject type");
        }
Esempio n. 3
0
        public void Delete(int nr)
        {
            PDFDict  dict3;
            PDFDict  dict1  = this[nr].Dict;
            PDFDict  dict2  = ((PDFDict)dict1["Parent"]);
            PDFArray array1 = ((PDFArray)dict2["Kids"]);
            int      num1   = 0;

            while ((num1 < array1.Count))
            {
                if (array1[num1].Indirect.Id == dict1.Indirect.Id)
                {
                    break;
                }
                num1 += 1;
            }
            if (num1 == array1.Count)
            {
                throw new PDFException(string.Format("Invalid page tree - invalid parent pointer in page {0}", nr));
            }
            array1.RemoveAt(num1);
            for (dict3 = dict2; (dict3 != null); dict3 = ((PDFDict)dict3["Parent"]))
            {
                PDFInteger integer1 = ((PDFInteger)dict2["Count"]);
                ((PDFInteger)dict2["Count"]).Value = (integer1.Value - ((long)1));
            }
        }
Esempio n. 4
0
        public static Appearance Create(XObjectForm normalAp)
        {
            PDFDict dict1 = Library.CreateDict();

            dict1["N"] = normalAp.Direct;
            return(new Appearance(dict1));
        }
Esempio n. 5
0
        public void Remove(OutlineItem item)
        {
            if (base.Direct == null)
            {
                throw new PDFException("Attempt to remove from non-existing outline collection");
            }
            PDFDict dict1 = item.Dict;
            PDFDict dict2 = (dict1["Prev"] as PDFDict);
            PDFDict dict3 = (dict1["Next"] as PDFDict);

            if (dict2 != null)
            {
                dict2["Next"] = dict1["Next"];
            }
            else
            {
                this.Dict["First"] = dict1["Next"];
            }
            if (dict3 != null)
            {
                dict3["Prev"] = dict1["Prev"];
            }
            else
            {
                this.Dict["Last"] = dict1["Prev"];
            }
            PDFInteger integer1 = (this.Dict["Count"] as PDFInteger);

            if (integer1 == null)
            {
                throw new PDFSyntaxException(base.Direct, "Non-empty outlines collection missing Count item");
            }
            integer1.Value -= ((long)1);
        }
Esempio n. 6
0
 private Stream ApplyEncodeFilter(Stream str, PDFName filter, PDFDict encodeParams)
 {
     if (filter.Value == "ASCIIHexDecode")
     {
         return(new ASCIIHexEncoder(str));
     }
     if (filter.Value == "ASCII85Decode")
     {
         return(new ASCII85Encoder(str));
     }
     if (filter.Value == "LZWDecode")
     {
         return(new LZW_Encoder(str, encodeParams));
     }
     if (filter.Value == "FlateDecode")
     {
         return(new Flate_Encoder(str, encodeParams));
     }
     if (filter.Value == "RunLengthDecode")
     {
         return(new RLE_Encoder(str));
     }
     if (filter.Value == "CCITTFaxDecode")
     {
         return(new CCITT_Encoder(str, encodeParams));
     }
     if (filter.Value == "DCTDecode")
     {
         return(new DCT_Encoder(str, encodeParams));
     }
     throw new PDFException(string.Format("Unknown filter: {0:S}", filter.Value));
 }
Esempio n. 7
0
        internal static Outlines Create(PDFDict parent)
        {
            Outlines outlines1 = new Outlines(null);

            outlines1.mParentDict = parent;
            return(outlines1);
        }
Esempio n. 8
0
        public static void AddDefaultRGB(Document doc)
        {
            int num1;

            if (doc == null)
            {
                return;
            }
            PDFDict dict1 = Library.CreateDict();

            double[] numArray1 = new double[3] {
                0.95045f, 1f, 1.08905f
            };
            double[] numArray2 = new double[3] {
                2.2f, 2.2f, 2.2f
            };
            double[] numArray3 = new double[9] {
                0.4124f, 0.2126f, 0.0193f, 0.3576f, 0.7152f, 0.1192f, 0.1805f, 0.0722f, 0.9505f
            };
            dict1["WhitePoint"] = PDF.O(numArray1);
            dict1["Gamma"]      = PDF.O(numArray2);
            dict1["Matrix"]     = PDF.O(numArray3);
            PDFArray array1 = Library.CreateArray(2);

            array1[0] = Library.CreateName("CalRGB");
            array1[1] = dict1;
            PDFIndirect indirect1 = doc.Indirects.New(array1);
            Resource    resource1 = doc.Resources[indirect1, typeof(ColorSpace)];

            for (num1 = 0; (num1 < doc.Pages.Count); num1 += 1)
            {
                doc.Pages[num1].Resources.Add("DefaultRGB", resource1);
            }
        }
Esempio n. 9
0
        internal object _GetObject(string index)
        {
            DictionaryEntry entry2;
            PDFObject       obj1  = this.mBaseDict[this.mBaseKeyName];
            PDFDict         dict1 = (obj1 as PDFDict);
            object          obj2  = null;

            if (dict1 == null)
            {
                return(null);
            }
            obj2 = ((object)dict1[index]);
            foreach (DictionaryEntry entry1 in this.mObjectList)
            {
                if (entry1.Key != obj2)
                {
                    continue;
                }
                return(entry1.Value);
            }
            entry2 = new DictionaryEntry(obj2, this.ComplexObjectFactory(((PDFDirect)obj2)));
            if (entry2.Value != null)
            {
                this.mObjectList.Add(entry2);
            }
            return(entry2.Value);
        }
Esempio n. 10
0
        protected void _Remove(object obj)
        {
            PDFDict dict1 = (this.mBaseDict[this.mBaseKeyName] as PDFDict);

            if (dict1 == null)
            {
                return;
            }
            foreach (DictionaryEntry entry1 in this.mObjectList)
            {
                if (obj != entry1.Value)
                {
                    continue;
                }
                this.mObjectList.Remove(entry1);
                if (dict1 == null)
                {
                    return;
                }
                foreach (DictionaryEntry entry2 in dict1)
                {
                    if (((PDFObject)entry2.Value).UniqueID != ((PDFObject)entry1.Key).UniqueID)
                    {
                        continue;
                    }
                    dict1.Remove(((PDFName)entry2.Key));
                }
            }
        }
Esempio n. 11
0
        static string[] get_button_info(PDFDict field)
        {
            string    svalue;
            string    sdefault_value;
            PDFObject entry;

            entry = field.Get("V");
            if (entry is PDFName)
            {
                PDFName field_value_name = (PDFName)entry;
                svalue = "Value: " + field_value_name.Value;
            }
            else
            {
                svalue = "";
            }

            entry = field.Get("DV");
            if (entry is PDFName)
            {
                PDFName field_defvalue_name = (PDFName)entry;
                sdefault_value = "Default Value: " + field_defvalue_name.Value;
            }
            else
            {
                sdefault_value = "";
            }

            return(new string[] { svalue, sdefault_value });
        }
Esempio n. 12
0
        static string[] get_sig_info(PDFDict field)
        {
            String filterName  = null;
            String signerName  = null;
            String contactInfo = null;
            String location    = null;
            String reason      = null;
            String sigM        = null;

            PDFObject entry;

            entry = field.Get("V");
            if (entry is PDFDict)
            {
                // Extracting Signature Dictionary entries, as per Table 8.102 in the PDF (v1.7) Reference.
                var sigDict = entry as PDFDict;
                filterName = "Filter: " + (sigDict.Get("Filter") as PDFName).Value;

                //The following are optional.
                signerName  = (sigDict.Contains("Name") ? "Name: " + (sigDict.Get("Name") as PDFString).Value : "");
                reason      = (sigDict.Contains("Reason") ? "Reason: " + (sigDict.Get("Reason") as PDFString).Value : "");
                contactInfo = (sigDict.Contains("ContactInfo") ? "ContactInfo: " + (sigDict.Get("ContactInfo") as PDFString).Value : "");
                location    = (sigDict.Contains("Location") ? "Location: " + (sigDict.Get("Location") as PDFString).Value : "");
                sigM        = (sigDict.Contains("M") ? "M: " + (sigDict.Get("M") as PDFString).Value : "");


                return(new string[] { filterName, signerName, contactInfo, location, reason, sigM });
            }

            return(new string[] { "", });
        }
Esempio n. 13
0
 // Methods
 internal ComplexObjectArrayBase(PDFDict baseDict, string keyName, bool allowSingleValue)
 {
     this.mObjectList       = new ArrayList();
     this.mBaseDict         = baseDict;
     this.mBaseKeyName      = keyName;
     this.mAllowSingleValue = allowSingleValue;
 }
Esempio n. 14
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));
 }
Esempio n. 15
0
 // Methods
 internal Page(PDFDict dict) : base(dict)
 {
     this.mAnnots       = null;
     this.mPageContents = null;
     this.mResources    = null;
     this.mLastModified = null;
     this.mBeads        = null;
 }
Esempio n. 16
0
        public static InteractiveForm Create()
        {
            PDFDict dict1 = Library.CreateDict();

            dict1["Fields"] = Library.CreateArray(0);
            Library.CreateIndirect(dict1);
            return(new InteractiveForm(dict1));
        }
Esempio n. 17
0
 // Methods
 public NameTreeEnumerator(PDFDict tree)
 {
     this.mCurr = new DictionaryEntry();
     this.mArrs = new PDFArray[16];
     this.mPos = new int[16];
     this.mTop = -1;
     this.mTree = tree;
 }
Esempio n. 18
0
        internal static Resource Factory(PDFDirect d)
        {
            if (d.PDFType != PDFObjectType.tPDFDict)
            {
                goto Label_0061;
            }
            PDFDict dict1 = ((PDFDict)d);
            int     num1  = ((PDFInteger)dict1["FunctionType"]).Int32Value;
            int     num3  = num1;

            switch (num3)
            {
            case 2:
            {
                goto Label_003C;
            }

            case 3:
            {
                goto Label_0043;
            }
            }
            goto Label_004A;
Label_003C:
            return(new FunctionType2(d));

Label_0043:
            return(new FunctionType3(d));

Label_004A:
            throw new PDFSyntaxException(d, string.Format("Unknown function type: {0}", num1));
Label_0061:
            if (d.PDFType != PDFObjectType.tPDFStream)
            {
                goto Label_00C0;
            }
            PDFStream stream1 = ((PDFStream)d);
            int       num2    = ((PDFInteger)stream1.Dict["FunctionType"]).Int32Value;

            num3 = num2;
            if (num3 != 0)
            {
                if (num3 == 4)
                {
                    goto Label_00A2;
                }
                goto Label_00A9;
            }
            return(new FunctionType0(d));

Label_00A2:
            return(new FunctionType4(d));

Label_00A9:
            throw new PDFSyntaxException(d, string.Format("Unknown function type: {0}", num2));
Label_00C0:
            throw new PDFSyntaxException(d, "Invalid Function");
        }
Esempio n. 19
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);
        }
Esempio n. 20
0
        private PDFIndirect BuildEGSDict(Document doc, double opacity)
        {
            PDFDict dict1 = Library.CreateDict();

            dict1["Type"] = Library.CreateName("ExtGState");
            dict1["ca"]   = Library.CreateFixed(opacity);
            dict1["CA"]   = Library.CreateFixed(opacity);
            return(doc.Indirects.New(dict1));
        }
        private void editSelectedDictValue(PDFDict selectedDict, string key, object newValue)
        {
            PDFObject newPDFObject = createNewValueForSelectedScalar(selectedDict.Get(key), newValue.ToString());

            updateDictionaryValue(selectedDict, key, newPDFObject);
            //refresh the tree
            selectedDict.EnumPDFObjects(new EnumObjectsForTree(selectedNodeBeforeEdit));
            mainWindow.expandNode(selectedNodeBeforeEdit);
        }
Esempio n. 22
0
        public static PatternShading Create(Shading sh)
        {
            PDFDict dict1 = Library.CreateDict();

            dict1["Type"]        = Library.CreateName("Pattern");
            dict1["PatternType"] = Library.CreateInteger(((long)2));
            dict1["Shading"]     = sh.Direct;
            return(new PatternShading(dict1));
        }
Esempio n. 23
0
        public static FieldText Create()
        {
            PDFDict dict1 = Library.CreateDict();

            dict1["FT"] = Library.CreateName("Tx");
            dict1["Ff"] = Library.CreateInteger(((long)4096));
            Library.CreateIndirect(dict1);
            return(new FieldText(dict1));
        }
Esempio n. 24
0
        protected void _RemoveAt(string index)
        {
            PDFDict dict1 = (this.mBaseDict[this.mBaseKeyName] as PDFDict);

            if (dict1 != null)
            {
                dict1.Remove(index);
            }
        }
Esempio n. 25
0
        public static FieldRadioButton Create()
        {
            PDFDict dict1 = Library.CreateDict();

            dict1["FT"] = Library.CreateName("Btn");
            dict1["Ff"] = Library.CreateInteger(((long)32768));
            Library.CreateIndirect(dict1);
            return(new FieldRadioButton(dict1));
        }
Esempio n. 26
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));
        }
Esempio n. 27
0
        public static MediaPlayers Create(bool indirect)
        {
            PDFDict dict1 = Library.CreateDict();

            if (indirect)
            {
                Library.CreateIndirect(dict1);
            }
            return(new MediaPlayers(dict1));
        }
Esempio n. 28
0
        private PDFIndirect BuildFontDict(Document doc, string fontname)
        {
            PDFDict dict1 = Library.CreateDict();

            dict1["Type"]     = Library.CreateName("Font");
            dict1["Subtype"]  = Library.CreateName("Type1");
            dict1["BaseFont"] = Library.CreateName(fontname);
            dict1["Encoding"] = Library.CreateName("WinAnsiEncoding");
            return(doc.Indirects.New(dict1));
        }
Esempio n. 29
0
 public void WriteDict(PDFDict val)
 {
     this.WriteOpenDict();
     foreach (DictionaryEntry entry1 in val)
     {
         this.WriteSp(entry1.Key);
         this.WriteLn(entry1.Value);
     }
     this.WriteCloseDict();
 }
Esempio n. 30
0
        public static RenditionMHBE Create(bool indirect)
        {
            PDFDict dict1 = Library.CreateDict();

            if (indirect)
            {
                Library.CreateIndirect(dict1);
            }
            return(new RenditionMHBE(dict1));
        }