示例#1
0
        public void ReadFile(String aFileName, BookInfo bookInfo)
        {
            Gutenberg.TextFormatter gbFormatter = new TextFormatter();

            Document   doc;
            FileStream stream = File.OpenRead(aFileName);

            try
            {
                doc = gbFormatter.ProcessTextBook(stream);
            }
            finally
            {
                stream.Close();
            }

            if (!string.IsNullOrEmpty(doc.Author))
            {
                bookInfo.Author = doc.Author;
            }
            if (!string.IsNullOrEmpty(doc.Title))
            {
                bookInfo.Title = doc.Title;
            }

            foreach (Chapter chapter in doc.Chapters)
            {
                TextBlockBuilder pageBlock = new TextBlockBuilder(m_Book);

                bool bPrintedPara = false;
                foreach (Paragraph para in chapter.Paragraphs)
                {
                    if (bPrintedPara)
                    {
                        pageBlock.Append(TagId.EOL);
                        pageBlock.Append(TagId.EOL);
                    }

                    foreach (char c in para.Text)
                    {
                        pageBlock.AppendChar(c);
                    }

                    bPrintedPara = true;
                }

                m_Book.AddTextPage(pageBlock.CreateLegacyTextObject());
            }
        }
示例#2
0
        public void ReadFile(String aFileName)
        {
            // Load text for book
            m_TextBuffer = File.ReadAllBytes(aFileName);

            while (true)
            {
                LegacyBBeBObject text = getNextPage();
                if (text == null)
                {
                    // All done
                    break;
                }
                m_Book.AddTextPage(text);
            }
        }