/** * An example using MultiColumnText with irregular columns. */ @Test public void main() throws Exception { Document document = new Document(); OutputStream out = PdfTestBase.getOutputStream("multicolumnsimple.pdf"); PdfWriter.getInstance(document, out); document.open(); MultiColumnText mct = new MultiColumnText(); // set up 3 even columns with 10pt space between mct.addRegularColumns(document.left(), document.right(), 10f, 3); // Write some iText poems for (int i = 0; i < 30; i++) { mct.addElement(new Paragraph(String.valueOf(i + 1))); mct.addElement(newPara(randomWord(noun), Element.ALIGN_CENTER, Font.BOLDITALIC)); for (int j = 0; j < 4; j++) { mct.addElement(newPara(poemLine(), Element.ALIGN_LEFT, Font.NORMAL)); } mct.addElement(newPara(randomWord(adverb), Element.ALIGN_LEFT, Font.NORMAL)); mct.addElement(newPara("\n\n", Element.ALIGN_LEFT, Font.NORMAL)); } document.add(mct); document.close(); }
/** * An example using MultiColumnText with irregular columns. */ @Test public void main() throws Exception { Document document = new Document(); OutputStream out = PdfTestBase.getOutputStream("multicolumnR2L.pdf"); PdfWriter.getInstance(document, out); document.open(); MultiColumnText mct = new MultiColumnText(); mct.setColumnsRightToLeft(true); // set up 3 even columns with 10pt space between mct.addRegularColumns(document.left(), document.right(), 10f, 3); // Write some iText poems for (int i = 0; i < 30; i++) { mct.addElement(new Paragraph(String.valueOf(i + 1))); mct.addElement(newPara(randomWord(noun), Element.ALIGN_CENTER, Font.BOLDITALIC)); for (int j = 0; j < 4; j++) { mct.addElement(newPara(poemLine(), Element.ALIGN_LEFT, Font.NORMAL)); } mct.addElement(newPara(randomWord(adverb), Element.ALIGN_LEFT, Font.NORMAL)); mct.addElement(newPara("\n\n", Element.ALIGN_LEFT, Font.NORMAL)); } document.add(mct); document.close(); }