Exemplo n.º 1
0
        public void ObjectBinData()
        {
            RtfTree tree = new RtfTree();
            tree.LoadRtfFile("..\\..\\testdocs\\testdoc3.rtf");

            RtfTreeNode node = tree.MainGroup.SelectSingleNode("object").ParentNode;

            ObjectNode objNode = new ObjectNode(node);

            BinaryWriter bw = new BinaryWriter(new FileStream("..\\..\\testdocs\\objbindata-result.dat", FileMode.Create));
            foreach (byte b in objNode.GetByteData())
                bw.Write(b);
            bw.Close();

            FileStream fs1 = new FileStream("..\\..\\testdocs\\objbindata-result.dat", FileMode.Open);
            FileStream fs2 = new FileStream("..\\..\\testdocs\\objbindata.dat", FileMode.Open);

            Assert.That(fs1, Is.EqualTo(fs2));
        }
Exemplo n.º 2
0
            private static void ExtractObjects()
            {
                RtfTree tree = new RtfTree();

                tree.LoadRtfFile("..\\..\\testdocs\\test-doc.rtf");

                //Busca el primer nodo de tipo objeto.
                RtfNodeCollection objects = tree.RootNode.SelectGroups("object");

                Console.WriteLine("Extracting objects...");

                int i = 1;

                foreach (RtfTreeNode node in objects)
                {
                    //Se crea un nodo RTF especializado en imágenes
                    ObjectNode objectNode = new ObjectNode(node);

                    Console.WriteLine("Found new object:");
                    Console.WriteLine("Object type: " + objectNode.ObjectType);
                    Console.WriteLine("Object class: " + objectNode.ObjectClass);

                    byte[] data = objectNode.GetByteData();

                    FileStream   binaryFile = new FileStream("..\\..\\testdocs\\object" + i + ".xls", FileMode.Create, FileAccess.ReadWrite);
                    BinaryWriter bw         = new BinaryWriter(binaryFile);

                    for (int j = 38; j < data.Length; j++)
                    {
                        bw.Write(data[j]);
                    }
                    bw.Flush();
                    bw.Close();

                    Console.WriteLine("File 'object" + i + ".xls' created.");

                    i++;
                }

                Console.WriteLine("");
            }
Exemplo n.º 3
0
        public void ObjectBinData()
        {
            RtfTree tree = new RtfTree();

            tree.LoadRtfFile("..\\..\\testdocs\\testdoc3.rtf");

            RtfTreeNode node = tree.MainGroup.SelectSingleNode("object").ParentNode;

            ObjectNode objNode = new ObjectNode(node);

            BinaryWriter bw = new BinaryWriter(new FileStream("..\\..\\testdocs\\objbindata-result.dat", FileMode.Create));

            foreach (byte b in objNode.GetByteData())
            {
                bw.Write(b);
            }
            bw.Close();

            FileStream fs1 = new FileStream("..\\..\\testdocs\\objbindata-result.dat", FileMode.Open);
            FileStream fs2 = new FileStream("..\\..\\testdocs\\objbindata.dat", FileMode.Open);

            Assert.That(fs1, Is.EqualTo(fs2));
        }
Exemplo n.º 4
0
            private static void ExtractObjects()
            {
                RtfTree tree = new RtfTree();
                tree.LoadRtfFile("..\\..\\testdocs\\test-doc.rtf");

                //Busca el primer nodo de tipo objeto.
                RtfNodeCollection objects = tree.RootNode.SelectGroups("object");

                Console.WriteLine("Extracting objects...");

                int i = 1;
                foreach (RtfTreeNode node in objects)
                {
                    //Se crea un nodo RTF especializado en imágenes
                    ObjectNode objectNode = new ObjectNode(node);

                    Console.WriteLine("Found new object:");
                    Console.WriteLine("Object type: " + objectNode.ObjectType);
                    Console.WriteLine("Object class: " + objectNode.ObjectClass);

                    byte[] data = objectNode.GetByteData();

                    FileStream binaryFile = new FileStream("..\\..\\testdocs\\object" + i + ".xls", FileMode.Create, FileAccess.ReadWrite);
                    BinaryWriter bw = new BinaryWriter(binaryFile);

                    for (int j = 38; j < data.Length; j++)
                    {
                        bw.Write(data[j]);
                    }
                    bw.Flush();
                    bw.Close();

                    Console.WriteLine("File 'object" + i + ".xls' created.");

                    i++;
                }

                Console.WriteLine("");
            }