/// <summary>
        /// Adds the specified action to the end of the collection.
        /// </summary>
        /// <param name="action">Action to be added.</param>
        public void Add(Action action)
        {
            if (action == null)
            {
                throw new ArgumentNullException();
            }

            IPDFObject obj = _parent[_key];

            if (obj == null || obj is PDFDictionary)
            {
                _parent.AddItem(_key, new PDFArray());
            }

            PDFArray arr = _parent[_key] as PDFArray;

            if (obj is PDFDictionary)
            {
                arr.AddItem(obj);
            }

            Action copy = action.Clone(_owner);

            _actions.Add(copy);
            arr.AddItem(copy.GetDictionary());
        }
Beispiel #2
0
        private void addSymbolDescriptor()
        {
            PDFDictionary descriptor = new PDFDictionary();

            descriptor.AddItem("Ascent", new PDFNumber(692));
            descriptor.AddItem("CapHeight", new PDFNumber(0));
            descriptor.AddItem("Descent", new PDFNumber(-14));
            descriptor.AddItem("Flags", new PDFNumber(4));
            descriptor.AddItem("FontName", new PDFName("Symbol"));
            descriptor.AddItem("FontWeight", new PDFNumber(500));
            descriptor.AddItem("ItalicAngle", new PDFNumber(0));
            descriptor.AddItem("MissingWidth", new PDFNumber(250));
            descriptor.AddItem("StemV", new PDFNumber(0));
            descriptor.AddItem("XHeight", new PDFNumber(0));
            descriptor.AddItem("Type", new PDFName("FontDescriptor"));

            PDFArray bbox = new PDFArray();

            bbox.AddItem(new PDFNumber(-180));
            bbox.AddItem(new PDFNumber(-293));
            bbox.AddItem(new PDFNumber(1090));
            bbox.AddItem(new PDFNumber(1010));
            descriptor.AddItem("FontBBox", bbox);

            byte[] data = System.Text.Encoding.ASCII.GetBytes("/space/exclam/universal/numbersign/existential/percent/ampersand/suchthat/parenleft/parenright/asteriskmath/plus/comma/minus/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon/less/equal/greater/question/congruent/Alpha/Beta/Chi/Delta/Epsilon/Phi/Gamma/Eta/Iota/theta1/Kappa/Lambda/Mu/Nu/Omicron/Pi/Theta/Rho/Sigma/Tau/Upsilon/sigma1/Omega/Xi/Psi/Zeta/bracketleft/therefore/bracketright/perpendicular/underscore/radicalex/alpha/beta/chi/delta/epsilon/phi/gamma/eta/iota/phi1/kappa/lambda/mu/nu/omicron/pi/theta/rho/sigma/tau/upsilon/omega1/omega/xi/psi/zeta/braceleft/bar/braceright/similar/Euro/Upsilon1/minute/lessequal/fraction/infinity/florin/club/diamond/heart/spade/arrowboth/arrowleft/arrowup/arrowright/arrowdown/degree/plusminus/second/greaterequal/multiply/proportional/partialdiff/bullet/divide/notequal/equivalence/approxequal/ellipsis/arrowvertex/arrowhorizex/carriagereturn/aleph/Ifraktur/Rfraktur/weierstrass/circlemultiply/circleplus/emptyset/intersection/union/propersuperset/reflexsuperset/notsubset/propersubset/reflexsubset/element/notelement/angle/gradient/registerserif/copyrightserif/trademarkserif/product/radical/dotmath/logicalnot/logicaland/logicalor/arrowdblboth/arrowdblleft/arrowdblup/arrowdblright/arrowdbldown/lozenge/angleleft/registersans/copyrightsans/trademarksans/summation/parenlefttp/parenleftex/parenleftbt/bracketlefttp/bracketleftex/bracketleftbt/bracelefttp/braceleftmid/braceleftbt/braceex/angleright/integral/integraltp/integralex/integralbt/parenrighttp/parenrightex/parenrightbt/bracketrighttp/bracketrightex/bracketrightbt/bracerighttp/bracerightmid/bracerightbt");
            descriptor.AddItem("CharSet", new PDFString(data, false));

            GetDictionary().AddItem("FontDescriptor", descriptor);

            addSymbolEncodingDictionary();
        }
Beispiel #3
0
        private void init(float[] matrix)
        {
            _dict = new PDFDictionaryStream(new PDFDictionary(), Stream);
            _dict.Dictionary.AddItem("Type", new PDFName("XObject"));
            _dict.Dictionary.AddItem("Subtype", new PDFName("Form"));
            PDFArray array = new PDFArray();

            array.AddItem(new PDFNumber(0));
            array.AddItem(new PDFNumber(0));
            array.AddItem(new PDFNumber(Width));
            array.AddItem(new PDFNumber(Height));
            _dict.Dictionary.AddItem("BBox", array);
            _dict.Dictionary.AddItem("Resources", Resources.Dictionary);
            array = new PDFArray();

            if (matrix != null)
            {
                array.AddItem(new PDFNumber(matrix[0]));
                array.AddItem(new PDFNumber(matrix[1]));
                array.AddItem(new PDFNumber(matrix[2]));
                array.AddItem(new PDFNumber(matrix[3]));
                array.AddItem(new PDFNumber(matrix[4]));
                array.AddItem(new PDFNumber(matrix[5]));
                _dict.Dictionary.AddItem("Matrix", array);
            }
        }
Beispiel #4
0
        private PDFDictionary createFontDescriptorDictionary()
        {
            PDFDictionary dict = new PDFDictionary();

            dict.AddItem("Ascent", new PDFNumber(_trueTypeData.Ascent));
            dict.AddItem("Descent", new PDFNumber(_trueTypeData.Descent));
            dict.AddItem("CapHeight", new PDFNumber(0));
            dict.AddItem("Flags", new PDFNumber(32));
            dict.AddItem("FontName", new PDFName(_trueTypeData.FontName));
            dict.AddItem("ItalicAngle", new PDFNumber(_trueTypeData.ItalicAngle));
            dict.AddItem("MissingWidth", new PDFNumber(_trueTypeData.MissingWidth));
            dict.AddItem("StemV", new PDFNumber(0));
            dict.AddItem("Type", new PDFName("FontDescriptor"));

            PDFArray bbox = new PDFArray();

            System.Drawing.Rectangle rect = _trueTypeData.FontBBox;
            bbox.AddItem(new PDFNumber(rect.X));
            bbox.AddItem(new PDFNumber(rect.Y));
            bbox.AddItem(new PDFNumber(rect.Width));
            bbox.AddItem(new PDFNumber(rect.Height));
            dict.AddItem("FontBBox", bbox);

            PDFDictionary fontFileDict = new PDFDictionary();

            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            _trueTypeData.Write(stream, _fontMap.GetIndexes(), _fontMap);

            fontFileDict.AddItem("Length1", new PDFNumber(stream.Length));
            dict.AddItem("FontFile2", new PDFDictionaryStream(fontFileDict, stream));

            return(dict);
        }
Beispiel #5
0
        private void addCourierObliqueDescriptor()
        {
            PDFDictionary descriptor = new PDFDictionary();

            descriptor.AddItem("Ascent", new PDFNumber(629));
            descriptor.AddItem("CapHeight", new PDFNumber(562));
            descriptor.AddItem("Descent", new PDFNumber(-157));
            descriptor.AddItem("Flags", new PDFNumber(32));
            descriptor.AddItem("FontName", new PDFName("Courier-Oblique"));
            descriptor.AddItem("FontWeight", new PDFNumber(500));
            descriptor.AddItem("ItalicAngle", new PDFNumber(-11));
            descriptor.AddItem("MissingWidth", new PDFNumber(600));
            descriptor.AddItem("StemV", new PDFNumber(0));
            descriptor.AddItem("XHeight", new PDFNumber(426));
            descriptor.AddItem("Type", new PDFName("FontDescriptor"));

            PDFArray bbox = new PDFArray();

            bbox.AddItem(new PDFNumber(-6));
            bbox.AddItem(new PDFNumber(-249));
            bbox.AddItem(new PDFNumber(639));
            bbox.AddItem(new PDFNumber(803));
            descriptor.AddItem("FontBBox", bbox);

            GetDictionary().AddItem("FontDescriptor", descriptor);
            addEncoding();
        }
Beispiel #6
0
        /// <summary>
        /// Adds the specified annotation to the collection.
        /// </summary>
        /// <param name="annotation">Annotation to be added.</param>
        public void Add(Annotation annotation)
        {
            if (annotation == null)
            {
                throw new ArgumentNullException();
            }

            Annotation copy = annotation.Clone(_owner, _page);

            _annotations.Add(copy);
            _array.AddItem(copy.Dictionary);

            if (annotation is MarkupAnnotation)
            {
                PopupAnnotation popup = (annotation as MarkupAnnotation).Popup;
                if (popup != null)
                {
                    Annotation popupClone = popup.Clone(_owner, _page);
                    (popupClone as PopupAnnotation).SetParent(copy);

                    copy.Dictionary.AddItem("Popup", popupClone.Dictionary);
                    _array.AddItem(popupClone.Dictionary);
                }
            }
            else if (annotation is Field)
            {
                if (_owner != null)
                {
                    _owner.AddField(copy as Field);
                }
            }
        }
Beispiel #7
0
        private void addHelveticaObliqueDescriptor()
        {
            PDFDictionary descriptor = new PDFDictionary();

            descriptor.AddItem("Ascent", new PDFNumber(718));
            descriptor.AddItem("CapHeight", new PDFNumber(718));
            descriptor.AddItem("Descent", new PDFNumber(-207));
            descriptor.AddItem("Flags", new PDFNumber(32));
            descriptor.AddItem("FontName", new PDFName("Helvetica-Oblique"));
            descriptor.AddItem("FontWeight", new PDFNumber(500));
            descriptor.AddItem("ItalicAngle", new PDFNumber(-12));
            descriptor.AddItem("MissingWidth", new PDFNumber(278));
            descriptor.AddItem("StemV", new PDFNumber(0));
            descriptor.AddItem("XHeight", new PDFNumber(532));
            descriptor.AddItem("Type", new PDFName("FontDescriptor"));

            PDFArray bbox = new PDFArray();

            bbox.AddItem(new PDFNumber(-166));
            bbox.AddItem(new PDFNumber(-225));
            bbox.AddItem(new PDFNumber(1000));
            bbox.AddItem(new PDFNumber(931));
            descriptor.AddItem("FontBBox", bbox);

            GetDictionary().AddItem("FontDescriptor", descriptor);
            addEncoding();
        }
Beispiel #8
0
        private void initCalRGB(PDFArray array, int gamma)
        {
            PDFDictionary dict = new PDFDictionary();

            array.AddItem(new PDFName("CalRGB"));
            PDFArray arrayWhite  = new PDFArray();
            PDFArray arrayMatrix = new PDFArray();

            arrayWhite.AddItem(new PDFNumber(0.95044f));
            arrayWhite.AddItem(new PDFNumber(1));
            arrayWhite.AddItem(new PDFNumber(1.08893f));
            arrayMatrix.AddItem(new PDFNumber(0.4124f));
            arrayMatrix.AddItem(new PDFNumber(0.21264f));
            arrayMatrix.AddItem(new PDFNumber(0.01934f));
            arrayMatrix.AddItem(new PDFNumber(0.35759f));
            arrayMatrix.AddItem(new PDFNumber(0.71517f));
            arrayMatrix.AddItem(new PDFNumber(0.1192f));
            arrayMatrix.AddItem(new PDFNumber(0.18046f));
            arrayMatrix.AddItem(new PDFNumber(0.07219f));
            arrayMatrix.AddItem(new PDFNumber(0.9504f));
            dict.AddItem("WhitePoint", arrayWhite);
            dict.AddItem("Matrix", arrayMatrix);
            PDFArray gammaA = new PDFArray();

            gammaA.AddItem(new PDFNumber((float)100000 / gamma));
            gammaA.AddItem(new PDFNumber((float)100000 / gamma));
            gammaA.AddItem(new PDFNumber((float)100000 / gamma));
            dict.AddItem("Gamma", gammaA);
            array.AddItem(dict);
        }
Beispiel #9
0
 private void initialize2IDAT(FileStream fs, long positionTRNS)
 {
     if (positionTRNS != 0)
     {
         long oldPosition = fs.Position;
         fs.Position = positionTRNS;
         byte[] buf = new byte[4];
         fs.Read(buf, 0, buf.Length);
         fs.Position += 4;
         byte[] data = new byte[toInt32(buf)];
         fs.Read(data, 0, data.Length);
         PDFArray array = new PDFArray();
         for (int i = 0; i < 3; ++i)
         {
             int tRNS = data[i * 2 + 1];
             if (_bitdepth == 16)
             {
                 tRNS = (((int)data[i * 2] << 8) | data[i * 2 + 1]);
             }
             array.AddItem(new PDFNumber(tRNS));
             array.AddItem(new PDFNumber(tRNS));
         }
         Dictionary.AddItem("Mask", array);
         fs.Position = oldPosition;
     }
     initNotAlphaIDAT(fs, "DeviceRGB", 3);
 }
Beispiel #10
0
        private void addTimesItalicDescriptor()
        {
            PDFDictionary descriptor = new PDFDictionary();

            descriptor.AddItem("Ascent", new PDFNumber(683));
            descriptor.AddItem("CapHeight", new PDFNumber(653));
            descriptor.AddItem("Descent", new PDFNumber(-217));
            descriptor.AddItem("Flags", new PDFNumber(32));
            descriptor.AddItem("FontName", new PDFName("Times-Italic"));
            descriptor.AddItem("FontWeight", new PDFNumber(500));
            descriptor.AddItem("ItalicAngle", new PDFNumber(-15));
            descriptor.AddItem("MissingWidth", new PDFNumber(250));
            descriptor.AddItem("StemV", new PDFNumber(0));
            descriptor.AddItem("XHeight", new PDFNumber(441));
            descriptor.AddItem("Type", new PDFName("FontDescriptor"));

            PDFArray bbox = new PDFArray();

            bbox.AddItem(new PDFNumber(-169));
            bbox.AddItem(new PDFNumber(-217));
            bbox.AddItem(new PDFNumber(1010));
            bbox.AddItem(new PDFNumber(883));
            descriptor.AddItem("FontBBox", bbox);

            GetDictionary().AddItem("FontDescriptor", descriptor);
            addEncoding();
        }
Beispiel #11
0
        private void addZapfDingbatsDescriptor()
        {
            PDFDictionary descriptor = new PDFDictionary();

            descriptor.AddItem("Ascent", new PDFNumber(692));
            descriptor.AddItem("CapHeight", new PDFNumber(0));
            descriptor.AddItem("Descent", new PDFNumber(-140));
            descriptor.AddItem("Flags", new PDFNumber(4));
            descriptor.AddItem("FontName", new PDFName("ZapfDingbats"));
            descriptor.AddItem("FontWeight", new PDFNumber(500));
            descriptor.AddItem("ItalicAngle", new PDFNumber(0));
            descriptor.AddItem("MissingWidth", new PDFNumber(278));
            descriptor.AddItem("StemV", new PDFNumber(0));
            descriptor.AddItem("XHeight", new PDFNumber(0));
            descriptor.AddItem("Type", new PDFName("FontDescriptor"));

            PDFArray bbox = new PDFArray();

            bbox.AddItem(new PDFNumber(-1));
            bbox.AddItem(new PDFNumber(-143));
            bbox.AddItem(new PDFNumber(981));
            bbox.AddItem(new PDFNumber(820));
            descriptor.AddItem("FontBBox", bbox);

            byte[] data = System.Text.Encoding.ASCII.GetBytes("/space/a1/a2/a202/a3/a4/a5/a119/a118/a117/a11/a12/a13/a14/a15/a16/a105/a17/a18/a19/a20/a21/a22/a23/a24/a25/a26/a27/a28/a6/a7/a8/a9/a10/a29/a30/a31/a32/a33/a34/a35/a36/a37/a38/a39/a40/a41/a42/a43/a44/a45/a46/a47/a48/a49/a50/a51/a52/a53/a54/a55/a56/a57/a58/a59/a60/a61/a62/a63/a64/a65/a66/a67/a68/a69/a70/a71/a72/a73/a74/a203/a75/a204/a76/a77/a78/a79/a81/a82/a83/a84/a97/a98/a99/a100/a89/a90/a93/a94/a91/a92/a205/a85/a206/a86/a87/a88/a95/a96/a101/a102/a103/a104/a106/a107/a108/a112/a111/a110/a109/a120/a121/a122/a123/a124/a125/a126/a127/a128/a129/a130/a131/a132/a133/a134/a135/a136/a137/a138/a139/a140/a141/a142/a143/a144/a145/a146/a147/a148/a149/a150/a151/a152/a153/a154/a155/a156/a157/a158/a159/a160/a161/a163/a164/a196/a165/a192/a166/a167/a168/a169/a170/a171/a172/a173/a162/a174/a175/a176/a177/a178/a179/a193/a180/a199/a181/a200/a182/a201/a183/a184/a197/a185/a194/a198/a186/a195/a187/a188/a189/a190/a191");
            descriptor.AddItem("CharSet", new PDFString(data, false));

            GetDictionary().AddItem("FontDescriptor", descriptor);

            addZapfDingbatsEncodingDictionary();
        }
Beispiel #12
0
 /// <summary>
 /// Adds the specified field.
 /// </summary>
 /// <param name="field">The field item to be added.</param>
 public void Add(Field field)
 {
     if (field == null)
     {
         throw new ArgumentNullException();
     }
     _fields.AddItem(field.Dictionary);
 }
Beispiel #13
0
        private void addFirstItem(PDFDictionary dict, IPDFObject key, IPDFObject value)
        {
            PDFArray nums = new PDFArray();

            nums.AddItem(key);
            nums.AddItem(value);
            dict.AddItem(NodeType, nums);
        }
Beispiel #14
0
        private void init(Stream stream)
        {
            _stream = new MemoryStream();
            _dict   = new PDFDictionaryStream(new PDFDictionary(), _stream);

            _alternate = new string[1];
            byte[] buf = new byte[4];
            stream.Position = 12;
            stream.Read(buf, 0, 4);
            GetDeviceClass(Encoding.GetString(buf));
            stream.Position = 16;
            stream.Read(buf, 0, 4);
            _n = 0;
            switch (GetColorSpaceICC(Encoding.GetString(buf)))
            {
            case ColorSpaceICC.icSigRgbData:
                _alternate[0] = "DeviceRGB";
                _n            = 3;

                break;

            case ColorSpaceICC.icSigCmykData:
                _alternate[0] = "DeviceCMYK";
                _n            = 4;
                break;

            case ColorSpaceICC.icSigGrayData:
                _alternate[0] = "DeviceGray";
                _n            = 1;
                break;
            }

            _range = new float[_n * 2];
            for (int i = 0; i < _n; ++i)
            {
                _range[i * 2]     = 0.0f;
                _range[i * 2 + 1] = 1.0f;
            }

            _dict.Dictionary.AddItem("N", new PDFNumber(_n));
            PDFArray array = new PDFArray();

            array.AddItem(new PDFName(_alternate[0]));
            _dict.Dictionary.AddItem("Alternate", array);
            array = new PDFArray();
            for (int i = 0; i < _n; ++i)
            {
                array.AddItem(new PDFNumber(_range[i * 2]));
                array.AddItem(new PDFNumber(_range[i * 2 + 1]));
            }
            _dict.Dictionary.AddItem("Range", array);
            buf             = new byte[stream.Length];
            stream.Position = 0;
            stream.Read(buf, 0, (int)stream.Length);
            _stream.Write(buf, 0, buf.Length);

            _name = "";
        }
Beispiel #15
0
        private void addZapfDingbatsEncodingDictionary()
        {
            PDFDictionary encoding = new PDFDictionary();

            encoding.AddItem("Type", new PDFName("Encoding"));
            encoding.AddItem("BaseEncoding", new PDFName("WinAnsiEncoding"));

            PDFArray differences = new PDFArray();

            int[] indexes =
            {
                0,     1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
                16,   17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
                33,   34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,  48,
                49,   50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,  64,
                65,   66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,  80,
                81,   82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,  96,
                97,   98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
                113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 128, 129,
                130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 145, 146, 147,
                148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 159, 161, 162, 163, 164, 165,
                166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181,
                182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
                198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213,
                214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
                230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245,
                246, 247, 248, 249, 250, 251, 252, 253, 254, 255
            };

            string[] names =
            {
                ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
                ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
                "a1",      "a2",      "a202",    "a3",      "a4",      "a5",      "a119",    "a118",    "a117",    "a11",     "a12",     "a13",     "a14",     "a15",     "a16",     "a105",
                "a17",     "a18",     "a19",     "a20",     "a21",     "a22",     "a23",     "a24",     "a25",     "a26",     "a27",     "a28",     "a6",      "a7",      "a8",      "a9",
                "a10",     "a29",     "a30",     "a31",     "a32",     "a33",     "a34",     "a35",     "a36",     "a37",     "a38",     "a39",     "a40",     "a41",     "a42",     "a43",
                "a44",     "a45",     "a46",     "a47",     "a48",     "a49",     "a50",     "a51",     "a52",     "a53",     "a54",     "a55",     "a56",     "a57",     "a58",     "a59",
                "a60",     "a61",     "a62",     "a63",     "a64",     "a65",     "a66",     "a67",     "a68",     "a69",     "a70",     "a71",     "a72",     "a73",     "a74",     "a203",
                "a75",     "a204",    "a76",     "a77",     "a78",     "a79",     "a81",     "a82",     "a83",     "a84",     "a97",     "a98",     "a99",     "a100",    "a89",     "a90",
                "a93",     "a94",     "a91",     "a92",     "a205",    "a85",     "a206",    "a86",     "a87",     "a88",     "a95",     "a96",     ".notdef", ".notdef", ".notdef", ".notdef",
                ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", ".notdef", "a101",    "a102",    "a103",    "a104",    "a106",
                "a107",    "a108",    "a112",    "a111",    "a110",    "a109",    "a120",    "a121",    "a122",    "a123",    "a124",    "a125",    "a126",    "a127",    "a128",    "a129",
                "a130",    "a131",    "a132",    "a133",    "a134",    "a135",    "a136",    "a137",    "a138",    "a139",    "a140",    "a141",    "a142",    "a143",    "a144",    "a145",
                "a146",    "a147",    "a148",    "a149",    "a150",    "a151",    "a152",    "a153",    "a154",    "a155",    "a156",    "a157",    "a158",    "a159",    "a160",    "a161",
                "a163",    "a164",    "a196",    "a165",    "a192",    "a166",    "a167",    "a168",    "a169",    "a170",    "a171",    "a172",    "a173",    "a162",    "a174",    "a175",
                "a176",    "a177",    "a178",    "a179",    "a193",    "a180",    "a199",    "a181",    "a200",    "a182",    ".notdef", "a201",    "a183",    "a184",    "a197",    "a185",
                "a194",    "a198",    "a186",    "a195",    "a187",    "a188",    "a189",    "a190",    "a191",    ".notdef"
            };

            for (int i = 0; i < names.Length; ++i)
            {
                differences.AddItem(new PDFNumber(indexes[i]));
                differences.AddItem(new PDFName(names[i]));
            }

            encoding.AddItem("Differences", differences);
            GetDictionary().AddItem("Encoding", encoding);
        }
Beispiel #16
0
        private void setRect(float left, float top, float right, float bottom)
        {
            PDFArray rect = new PDFArray();

            rect.AddItem(new PDFNumber(left));
            rect.AddItem(new PDFNumber(top));
            rect.AddItem(new PDFNumber(right));
            rect.AddItem(new PDFNumber(bottom));
            _dictionary.AddItem("Rect", rect);
        }
Beispiel #17
0
        private IPDFObject getID()
        {
            PDFArray arr = new PDFArray();

            byte[] id = _encryptor != null?_encryptor.GetDocumentID() : createID();

            arr.AddItem(new PDFString(id, true));
            arr.AddItem(new PDFString(id, true));
            return(arr);
        }
Beispiel #18
0
        private static PDFArray createBox(System.Drawing.RectangleF rect)
        {
            PDFArray box = new PDFArray();

            box.AddItem(new PDFNumber(rect.X));
            box.AddItem(new PDFNumber(rect.Y));
            box.AddItem(new PDFNumber(rect.Right));
            box.AddItem(new PDFNumber(rect.Bottom));
            return(box);
        }
Beispiel #19
0
        private static PDFArray createBox(float left, float top, float width, float height)
        {
            PDFArray box = new PDFArray();

            box.AddItem(new PDFNumber(left));
            box.AddItem(new PDFNumber(top));
            box.AddItem(new PDFNumber(left + width));
            box.AddItem(new PDFNumber(top + height));
            return(box);
        }
Beispiel #20
0
        internal override void WriteColorSpaceForStroking(MemoryStream stream, Resources resources)
        {
            PDFArray array = new PDFArray();

            array.AddItem(new PDFName(Name));
            array.AddItem(_dict);
            _name = resources.AddResources(ResourceType.ColorSpace, array);
            IPDFPageOperation operation = new ColorSpaceForStroking(_name);

            operation.WriteBytes(stream);
        }
Beispiel #21
0
        private void addSymbolEncodingDictionary()
        {
            PDFDictionary encoding = new PDFDictionary();

            encoding.AddItem("Type", new PDFName("Encoding"));
            encoding.AddItem("BaseEncoding", new PDFName("WinAnsiEncoding"));

            PDFArray differences = new PDFArray();

            int[] indexes =
            {
                0,     1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
                16,   17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
                34,   36,  39,  42,  45,  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,
                75,   76,  77,  78,  79,  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,
                92,   94,  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
                110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 126, 128, 130,
                131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 142, 145, 146, 147, 148, 149,
                150, 151, 152, 153, 154, 155, 156, 158, 159, 160, 161, 162, 163, 164, 165, 166,
                167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 178, 179, 180, 181, 182, 183,
                184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
                200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215,
                216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231,
                232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
                248, 249, 250, 251, 252, 253, 254, 255
            };

            string[] names =
            {
                ".notdef",      ".notdef",        ".notdef",        ".notdef",        ".notdef",      ".notdef",       ".notdef",       ".notdef",        ".notdef",   ".notdef",    ".notdef",       ".notdef",        ".notdef",        ".notdef",      ".notdef",      ".notdef",
                ".notdef",      ".notdef",        ".notdef",        ".notdef",        ".notdef",      ".notdef",       ".notdef",       ".notdef",        ".notdef",   ".notdef",    ".notdef",       ".notdef",        ".notdef",        ".notdef",      ".notdef",      ".notdef",
                "universal",    "existential",    "suchthat",       "asteriskmath",   "minus",        "congruent",     "Alpha",         "Beta",           "Chi",       "Delta",      "Epsilon",       "Phi",            "Gamma",          "Eta",          "Iota",         "theta1",
                "Kappa",        "Lambda",         "Mu",             "Nu",             "Omicron",      "Pi",            "Theta",         "Rho",            "Sigma",     "Tau",        "Upsilon",       "sigma1",         "Omega",          "Xi",           "Psi",          "Zeta",
                "therefore",    "perpendicular",  "radicalex",      "alpha",          "beta",         "chi",           "delta",         "epsilon",        "phi",       "gamma",      "eta",           "iota",           "phi1",           "kappa",        "lambda",       "mu",
                "nu",           "omicron",        "pi",             "theta",          "rho",          "sigma",         "tau",           "upsilon",        "omega1",    "omega",      "xi",            "psi",            "zeta",           "similar",      ".notdef",      ".notdef",
                ".notdef",      ".notdef",        ".notdef",        ".notdef",        ".notdef",      ".notdef",       ".notdef",       ".notdef",        ".notdef",   ".notdef",    ".notdef",       ".notdef",        ".notdef",        ".notdef",      ".notdef",      ".notdef",
                ".notdef",      ".notdef",        ".notdef",        ".notdef",        ".notdef",      ".notdef",       ".notdef",       ".notdef",        ".notdef",   "Euro",       "Upsilon1",      "minute",         "lessequal",      "fraction",     "infinity",     "florin",
                "club",         "diamond",        "heart",          "spade",          "arrowboth",    "arrowleft",     "arrowup",       "arrowright",     "arrowdown", "degree",     "second",        "greaterequal",   "multiply",       "proportional", "partialdiff",  "bullet",
                "divide",       "notequal",       "equivalence",    "approxequal",    "ellipsis",     "arrowvertex",   "arrowhorizex",  "carriagereturn", "aleph",     "Ifraktur",   "Rfraktur",      "weierstrass",    "circlemultiply", "circleplus",   "emptyset",     "intersection",
                "union",        "propersuperset", "reflexsuperset", "notsubset",      "propersubset", "reflexsubset",  "element",       "notelement",     "angle",     "gradient",   "registerserif", "copyrightserif", "trademarkserif", "product",      "radical",      "dotmath",
                "logicalnot",   "logicaland",     "logicalor",      "arrowdblboth",   "arrowdblleft", "arrowdblup",    "arrowdblright", "arrowdbldown",   "lozenge",   "angleleft",  "registersans",  "copyrightsans",  "trademarksans",  "summation",    "parenlefttp",  "parenleftex",
                "parenleftbt",  "bracketlefttp",  "bracketleftex",  "bracketleftbt",  "bracelefttp",  "braceleftmid",  "braceleftbt",   "braceex",        ".notdef",   "angleright", "integral",      "integraltp",     "integralex",     "integralbt",   "parenrighttp", "parenrightex",
                "parenrightbt", "bracketrighttp", "bracketrightex", "bracketrightbt", "bracerighttp", "bracerightmid", "bracerightbt",  ".notdef"
            };

            for (int i = 0; i < names.Length; ++i)
            {
                differences.AddItem(new PDFNumber(indexes[i]));
                differences.AddItem(new PDFName(names[i]));
            }

            encoding.AddItem("Differences", differences);
            GetDictionary().AddItem("Encoding", encoding);
        }
Beispiel #22
0
        private void addProcSet()
        {
            PDFArray procSet = new PDFArray();

            procSet.AddItem(new PDFName("PDF"));
            procSet.AddItem(new PDFName("Text"));
            procSet.AddItem(new PDFName("ImageB"));
            procSet.AddItem(new PDFName("ImageC"));
            procSet.AddItem(new PDFName("ImageI"));
            _dictionary.AddItem("ProcSet", procSet);
        }
Beispiel #23
0
        private void initCalGray(PDFArray array, int gamma)
        {
            PDFDictionary dict = new PDFDictionary();

            array.AddItem(new PDFName("CalGray"));
            PDFArray arrayWhite = new PDFArray();

            arrayWhite.AddItem(new PDFNumber(0.95044f));
            arrayWhite.AddItem(new PDFNumber(1));
            arrayWhite.AddItem(new PDFNumber(1.08893f));
            dict.AddItem("WhitePoint", arrayWhite);
            dict.AddItem("Gamma", new PDFNumber((float)100000 / gamma));
            array.AddItem(dict);
        }
Beispiel #24
0
        internal override void WriteColorSpaceForStroking(MemoryStream stream, Resources resources)
        {
            _name = resources.AddResources(ResourceType.Pattern, _streamDict);
            PDFArray colorspace = new PDFArray();

            colorspace.AddItem(new PDFName(Name));
            colorspace.AddItem(new PDFName(_color.Colorspace.Name));
            string            name      = resources.AddResources(ResourceType.ColorSpace, colorspace);
            IPDFPageOperation operation = new ColorSpaceForStroking(name);

            operation.WriteBytes(stream);
            operation = new ColorForStrokingEx(_color.ToArray(), _name);
            operation.WriteBytes(stream);
        }
Beispiel #25
0
        private void changeArray()
        {
            _array.Clear();
            double angle = _angle * Math.PI / 180;

            double[] arrayf = new double[8];

            arrayf[6] = _left + _width * Math.Cos(angle) - _height * Math.Sin(angle);
            arrayf[7] = _top + _width * Math.Sin(angle) + _height * Math.Cos(angle);
            arrayf[4] = _left - _height * Math.Sin(angle);
            arrayf[5] = _top + _height * Math.Cos(angle);
            arrayf[2] = _left + _width * Math.Cos(angle);
            arrayf[3] = _top + _width * Math.Sin(angle);
            arrayf[0] = _left;
            arrayf[1] = _top;

            if (_page != null)
            {
                for (int i = 0; i < 4; ++i)
                {
                    arrayf[i * 2]     = arrayf[i * 2] + _page.PageRect.Left;
                    arrayf[i * 2 + 1] = _page.PageRect.Bottom - arrayf[i * 2 + 1];
                }
            }

            for (int i = 0; i < 8; ++i)
            {
                _array.AddItem(new PDFNumber((float)arrayf[i]));
            }
        }
Beispiel #26
0
        private void loadCanvas()
        {
            IPDFObject contents = _dictionary["Contents"];

            if (contents is PDFArray)
            {
                addFirstq(contents as PDFArray);
                addLast(contents as PDFArray);
            }
            else if (contents is PDFDictionaryStream)
            {
                PDFArray arr = new PDFArray();
                addFirstq(arr);
                arr.AddItem(contents);
                addLast(arr);
                _dictionary.AddItem("Contents", arr);
            }
            else
            {
                PDFArray            arr = new PDFArray();
                PDFDictionaryStream ds  = new PDFDictionaryStream();
                MemoryStream        s   = ds.GetStream();
                s.WriteByte((byte)'q');
                s.WriteByte((byte)'\r');
                s.WriteByte((byte)'Q');
                arr.AddItem(ds);
                _dictionary.AddItem("Contents", arr);
                _canvas              = new Canvas(s, Resources, PageRect);
                _canvas.ChangeGroup += new ChangeGroupEventHandler(m_canvas_ChangeGroup);
            }
        }
Beispiel #27
0
        internal static PDFDictionary Copy(PDFDictionary dict)
        {
            PDFDictionary result = new PDFDictionary();

            string[] keys = { "Type", "W", "S" };
            for (int i = 0; i < keys.Length; ++i)
            {
                IPDFObject obj = dict[keys[i]];
                if (obj != null)
                {
                    result.AddItem(keys[i], obj.Clone());
                }
            }

            PDFArray dash = dict["D"] as PDFArray;

            if (dash != null)
            {
                PDFArray arr = new PDFArray();
                for (int i = 0; i < dash.Count; ++i)
                {
                    arr.AddItem(dash[i].Clone());
                }
                result.AddItem("D", arr);
            }

            return(result);
        }
Beispiel #28
0
        internal PDFArray ParseArray(int objNo, int genNo)
        {
            PDFArray arr = new PDFArray();
            int      b   = _stream.ReadByte();

            for (; ;)
            {
                if (IsEOL(b))
                {
                    SkipEOL();
                    b = _lastParsedByte;
                }

                if (!_usedLastParsedNumber)
                {
                    if (b == ']')
                    {
                        break;
                    }
                }

                IPDFObject obj = readObject(b, objNo, genNo);
                if (obj == null)
                {
                    return(null);
                }
                arr.AddItem(obj);
                b = _lastParsedByte;
            }

            _lastParsedByte = _stream.ReadByte();
            return(arr);
        }
Beispiel #29
0
        private IPDFObject createDescendantFonts()
        {
            PDFDictionary dict = new PDFDictionary();

            dict.AddItem("BaseFont", new PDFName(_trueTypeData.FontName));

            PDFDictionary CIDSystemInfo = new PDFDictionary();

            CIDSystemInfo.AddItem("Ordering", new PDFString(System.Text.Encoding.ASCII.GetBytes("Identity"), false));
            CIDSystemInfo.AddItem("Registry", new PDFString(System.Text.Encoding.ASCII.GetBytes("Adobe"), false));
            CIDSystemInfo.AddItem("Supplement", new PDFNumber(0));

            dict.AddItem("CIDSystemInfo", CIDSystemInfo);
            dict.AddItem("CIDToGIDMap", new PDFName("Identity"));
            dict.AddItem("DW", new PDFNumber(_trueTypeData.MissingWidth));
            dict.AddItem("FontDescriptor", createFontDescriptorDictionary());
            dict.AddItem("Type", new PDFName("Font"));
            dict.AddItem("Subtype", new PDFName("CIDFontType2"));

            dict.AddItem("W", createGlyfWidths());

            PDFArray arr = new PDFArray();

            arr.AddItem(dict);

            return(arr);
        }
Beispiel #30
0
        private void addWidths(Type1Parser parser)
        {
            List <KeyValuePair <ushort, string> > charset = parser.GetCharset();
            Dictionary <string, int> widths = parser.GetWidths();
            PDFArray w = new PDFArray();

            if (charset != null)
            {
                int i = 0;
                if (charset[0].Key == 0)
                {
                    ++i;
                }

                int tmp = 0;
                for (; i < charset.Count; ++i)
                {
                    if (!widths.TryGetValue(charset[i].Value, out tmp))
                    {
                        w.AddItem(new PDFNumber(0));
                    }
                    else
                    {
                        w.AddItem(new PDFNumber(tmp));
                    }
                }
            }
            else
            {
                int result = 0;
                for (byte i = 32; i < 255; ++i)
                {
                    char   c        = Encoding.GetChar(i);
                    string glyfName = GlyfNames.GetName(c);
                    if (!widths.TryGetValue(glyfName, out result))
                    {
                        w.AddItem(new PDFNumber(0));
                    }
                    else
                    {
                        w.AddItem(new PDFNumber(result));
                    }
                }
            }

            GetDictionary().AddItem("Widths", w);
        }