Пример #1
0
            public static void ExtractDocumentProperties()
            {
                RtfTree tree = new RtfTree();

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

                InfoGroup info = tree.GetInfoGroup();

                Console.WriteLine("Extracting document properties:");

                Console.WriteLine("Title: {0}", info.Title);
                Console.WriteLine("Author: {0}", info.Author);
                Console.WriteLine("Company: {0}", info.Company);
                Console.WriteLine("Comments: {0}", info.DocComment);
                Console.WriteLine("Created: {0}", info.CreationTime);
                Console.WriteLine("Revised: {0}", info.RevisionTime);

                Console.WriteLine("");
            }
Пример #2
0
        private void button7_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            //Se establecen las propiedades del cuadro de diálogo "Abrir"
            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.Filter           = "Archivos RTF (*.rtf)|*.rtf|Todos los archivos (*.*)|*.*";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;

            //Se muestra el cuadro de diálogo Abrir y se espera a que se seleccione un fichero RTF.
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                //Se crea un árbol RTF
                RtfTree arbol = new RtfTree();

                //Se carga el documento seleccionado (Este método parsea el documento y crea la estructura de árbol interna)
                arbol.LoadRtfFile(openFileDialog1.FileName);

                //Se obtiene la información del nodo "\info"
                InfoGroup info = arbol.GetInfoGroup();

                //Si existe el nodo de información del documento
                if (info != null)
                {
                    //Se muestran algunos datos del documento
                    txtArbol.Text += "Title: " + info.Title + "\r\n";
                    txtArbol.Text += "Subject: " + info.Subject + "\r\n";
                    txtArbol.Text += "Author: " + info.Author + "\r\n";
                    txtArbol.Text += "Company: " + info.Company + "\r\n";
                    txtArbol.Text += "Category: " + info.Category + "\r\n";
                    txtArbol.Text += "Keywords: " + info.Keywords + "\r\n";
                    txtArbol.Text += "Comments: " + info.DocComment + "\r\n";

                    txtArbol.Text += "Creation Date: " + info.CreationTime + "\r\n";
                    txtArbol.Text += "Revision Date: " + info.RevisionTime + "\r\n";

                    txtArbol.Text += "Number of Pages: " + info.NumberOfPages + "\r\n";
                    txtArbol.Text += "Number of Words: " + info.NumberOfWords + "\r\n";
                    txtArbol.Text += "Number of Chars: " + info.NumberOfChars + "\r\n";
                }
            }
        }
Пример #3
0
        public void InfoGroupTest()
        {
            InfoGroup infoGroup = tree.GetInfoGroup();

            Assert.That(infoGroup.Title, Is.EqualTo("Test NRtfTree Title"));
            Assert.That(infoGroup.Subject, Is.EqualTo("Test NRtfTree Subject"));
            Assert.That(infoGroup.Author, Is.EqualTo("Sgoliver (Author)"));
            Assert.That(infoGroup.Keywords, Is.EqualTo("test;nrtftree;sgoliver"));
            Assert.That(infoGroup.DocComment, Is.EqualTo("This is a test comment."));
            Assert.That(infoGroup.Operator, Is.EqualTo("None"));
            Assert.That(infoGroup.CreationTime, Is.EqualTo(new DateTime(2008, 5, 28, 18, 52, 00)));
            Assert.That(infoGroup.RevisionTime, Is.EqualTo(new DateTime(2009, 6, 29, 20, 23, 00)));
            Assert.That(infoGroup.Version, Is.EqualTo(6));
            Assert.That(infoGroup.EditingTime, Is.EqualTo(4));
            Assert.That(infoGroup.NumberOfPages, Is.EqualTo(1));
            Assert.That(infoGroup.NumberOfWords, Is.EqualTo(12));
            Assert.That(infoGroup.NumberOfChars, Is.EqualTo(59));
            Assert.That(infoGroup.Manager, Is.EqualTo("Sgoliver (Admin)"));
            Assert.That(infoGroup.Company, Is.EqualTo("www.sgoliver.net"));
            Assert.That(infoGroup.Category, Is.EqualTo("Demos (Category)"));
            Assert.That(infoGroup.InternalVersion, Is.EqualTo(24579));

            Assert.That(infoGroup.Comment, Is.EqualTo(""));
            Assert.That(infoGroup.HlinkBase, Is.EqualTo(""));
            Assert.That(infoGroup.Id, Is.EqualTo(-1));
            Assert.That(infoGroup.LastPrintTime, Is.EqualTo(DateTime.MinValue));
            Assert.That(infoGroup.BackupTime, Is.EqualTo(DateTime.MinValue));

            //StreamWriter sw = new StreamWriter("testdocs\\infogroup.txt");
            //sw.Write(infoGroup.ToString());
            //sw.Flush();
            //sw.Close();

            StreamReader sr         = new StreamReader("..\\..\\testdocs\\infogroup.txt");
            string       infoString = sr.ReadToEnd();

            sr.Close();

            Assert.That(infoGroup.ToString(), Is.EqualTo(infoString));
        }
Пример #4
0
            public static void ExtractDocumentProperties()
            {
                RtfTree tree = new RtfTree();
                tree.LoadRtfFile("..\\..\\testdocs\\test-doc.rtf");

                InfoGroup info = tree.GetInfoGroup();

                Console.WriteLine("Extracting document properties:");

                Console.WriteLine("Title: {0}", info.Title);
                Console.WriteLine("Author: {0}", info.Author);
                Console.WriteLine("Company: {0}", info.Company);
                Console.WriteLine("Comments: {0}", info.DocComment);
                Console.WriteLine("Created: {0}", info.CreationTime);
                Console.WriteLine("Revised: {0}", info.RevisionTime);

                Console.WriteLine("");
            }