IEnumerable<Page> Layout(Lines root) { var pagedDocument = new List<Page>(); var currentPage = Page.First(); var currentPageNumer = 1; foreach (var line in from lines in root.FitTo(pageHeight, pageHeight) from line in lines select line) { if (line.Top >= TopOfNextPage(currentPageNumer)) { pagedDocument.Add(currentPage); currentPage = currentPage.Next(); currentPageNumer++; } currentPage.Add(line, TopOfPage(currentPageNumer)); } pagedDocument.Add(currentPage); return pagedDocument; }