Ejemplo n.º 1
0
        public PageInfo GetPreviousPage(int firstTokenID, string stopText)
        {
            string startText = string.Empty;
            var tokenLines = new List<TokenBlockBase>();
            int stopTokenID = firstTokenID;
            LineBuilder lineBuilder = CreateLineParser();
            foreach (int blockStartId in FindBlockTokenID(firstTokenID))
            {
                List<TokenBlockBase> linesInBlock = lineBuilder
                    .GetLines(_bookTokens, string.Empty, blockStartId, stopTokenID, stopText)
                    .ToList();

                EndTokenBlock(linesInBlock);

                InsertTokenBlocks(linesInBlock, tokenLines);

                // Remove all page breaks at the end
                TokenBlockBase pageBreak;
                while ((pageBreak = tokenLines.LastOrDefault()) != null && pageBreak is PageBreakBlock)
                {
                    tokenLines.RemoveAt(tokenLines.Count - 1);
                }

                if (RemovePageBreaks(tokenLines, ref stopTokenID, ref startText)) 
                    break;

                stopTokenID = blockStartId;
                stopText = string.Empty;
            }

            if (!tokenLines.Any())
                return null;

            PageInfo pageInfo = new PageBuilder(_pageSize, _images).GetPage(tokenLines);
            if (pageInfo == null)
                return null;

            pageInfo.StartText = startText;
            pageInfo.FirstTokenID = stopTokenID;
            return pageInfo;
        }
Ejemplo n.º 2
0
        public PageInfo GetPage(int firstTokenID, string lastText)
        {
            if (firstTokenID >= _bookTokens.Count)
                return null;

            LineBuilder lineBuilder = CreateLineParser();
            IEnumerable<TokenBlockBase> lines = lineBuilder.GetLines(_bookTokens, lastText, firstTokenID);
            var pageParser = new PageBuilder(_pageSize, _images);
            string startText = lastText;
            PageInfo pageInfo = pageParser.GetPage(lines);
            if (pageInfo == null)
                return null;

            pageInfo.StartText = startText;
            return pageInfo;
        }