/** * Splitting up the text onto pages. * @param text to be split * @return list of Pages. */ public List<Page> splitIntoPages(Text text) { return splitIntoPages(text, false); } /**
/** * Split up the text into lines and pages, that can be displayed. * @param text component that is to be split up. */ private void splitTextToPages(Text text) { final double width = getContentWidth(); final double heigh = contentHeight.doubleValue(); Font font = control.getNavigationLabelFont(); PageSplitter splitter = new PageSplitter(heigh, width, contentContainer.getSpacing(), calculateContentInitialHeigth(), font); splitter.setWordSplitter(new NonAlphaNumWordSplitter()); pages.addAll(splitter.splitIntoPages(text)); } private double getContentWidth() {
Paragraph p = new Paragraph(Joiner.on(' ').join(parts)); tmpText.addParagraph(p); List<Page> tmpPages = splitIntoPages(tmpText, true); if (tmpPages.size() > 1) { throw new IllegalStateException("Got a more than on page out of a single word.");