Exemplo n.º 1
0
        public void visit(TDocument doc)
        {
            document.AddAuthor("Rajesh Khanna");
            document.AddCreator("iTextSharp Library");
            document.AddKeywords("Design Patterns Architecture");
            document.AddSubject("Book on .NET Design Patterns");
            document.Open();
            column_count = doc.ColumnCount;
            document.AddTitle(doc.Title);

            for (int x = 0; x < doc.DocumentElements.Count; x++)
            {
                try
                {
                    doc.DocumentElements[x].accept(this);
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine(ex.Message);
                }
            }
            document.Add(this.table_temp);
            document.Close();
            writer.Close();
            fs.Close();
        }
Exemplo n.º 2
0
        public void visit(TDocument doc)
        {
            document = new StringBuilder("<HTML><head>\n");
            document.Append("<title>");
            if (doc.Title != null)
            {
                document.Append(doc.Title);
            }
            document.Append("</title></head>\n\n<body ");
            string color = doc.BackgroundColor;

            if (color != null)
            {
                document.Append("BGCOLOR =\"" + color + "\"");
            }
            string textColor = doc.TextColor;

            if (textColor != null)
            {
                document.Append("TEXT =\"" + textColor + "\"");
            }
            string vlink = doc.Vlink;

            if (vlink != null)
            {
                document.Append("VLINK =\"" + vlink + "\"");
            }
            string linkColor = doc.LinkColor;

            if (linkColor != null)
            {
                document.Append("LINK =\"" + linkColor + "\"");
            }

            string alink = doc.Alink;

            if (alink != null)
            {
                document.Append("ALINK =\"" + alink + "\"");
            }
            document.Append(">\n");



            ///// Iterate through all objects in CHTMLObjects
            for (int x = 0; x < doc.DocumentElements.Count; x++)
            {
                try
                {
                    ((TDocumentElement)doc.DocumentElements[x]).accept(this);
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine(ex.Message);
                }
            }
            document.Append("\n</body>\n</HTML>\n");
            string html_content = document.ToString();
            // string rs = ds.toHTML();
            FileStream   fs = new FileStream(this.file_name, FileMode.Create);
            StreamWriter st = new StreamWriter(fs);

            st.Write(html_content);
            st.Close();
        }