Exemplo n.º 1
0
        private bool Append(BookTokenIterator bookTokens, string lastText, int stopTokenID, string stopText, ref bool firstText)
        {
            TokenBase token = bookTokens.Current;

            var pageBreakToken = token as NewPageToken;

            if (pageBreakToken != null)
            {
                AppendToLine(pageBreakToken);
            }

            var imageToken = token as PictureToken;

            if (imageToken != null)
            {
                AppendToLine(imageToken);
            }

            var openTagToken = token as TagOpenToken;

            if (openTagToken != null)
            {
                AppendToLine(openTagToken);
            }

            var closeTagToken = token as TagCloseToken;

            if (closeTagToken != null)
            {
                AppendToLine(closeTagToken);
            }

            var textSeparatorToken = token as WhitespaceToken;

            if (textSeparatorToken != null)
            {
                AppendSeparator();
            }

            var textToken = token as TextToken;

            if (textToken != null && AppendTextToken(textToken, lastText, stopTokenID, stopText, ref firstText) ||
                stopTokenID >= 0 && token.ID >= stopTokenID)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
 public BookBuilder(
     BookTokenIterator bookTokens,
     IEnumerable <BookImage> images,
     IList <double> headerSizes,
     IFontHelper helper,
     Size pageSize,
     double textSize,
     bool hyphenation,
     bool useCssFontSize)
 {
     _bookTokens     = bookTokens;
     _images         = images;
     _headerSizes    = headerSizes;
     _helper         = helper;
     _pageSize       = pageSize;
     _textSize       = textSize;
     _hyphenation    = hyphenation;
     _useCssFontSize = useCssFontSize;
 }
Exemplo n.º 3
0
        public IEnumerable <TokenBlockBase> GetLines(BookTokenIterator bookTokens, string lastText, int firstTokenID,
                                                     int stopTokenID = -1, string stopText = null)
        {
            _firstTokenID = firstTokenID;

            _tree        = bookTokens.BuildTree(_firstTokenID);
            _lastOpenTag = _tree.Peek();
            _fontSize    = GetCurrentFontSize();
            _separator   = false;
            bool firstText = true;

            _marginLeft = _marginRight = 0.0;

            foreach (TagOpenToken openTagToken in _tree.Reverse())
            {
                EnterMargin(openTagToken.TextProperties);
            }

            if (string.IsNullOrEmpty(stopText) && stopTokenID > 0)
            {
                --stopTokenID;
            }

            while (bookTokens.MoveNext())
            {
                foreach (TokenBlockBase baseTokenLine in OutputLines(false))
                {
                    yield return(baseTokenLine);
                }

                if (!Append(bookTokens, lastText, stopTokenID, stopText, ref firstText))
                {
                    break;
                }
            }
            foreach (TokenBlockBase baseTokenLine in OutputLines(true))
            {
                yield return(baseTokenLine);
            }
        }