Hi,
This is a sample code for the problem am facing with itext, where anything
following a table that overflows into the next page, always begins on a new
page.
Could you please suggest any modifications that may help overcome this.
import com.lowagie.text.Cell;
import com.lowagie.text.Chapter;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Header;
import com.lowagie.text.HeaderFooter;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Section;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.PdfWriter;
import java.awt.Color;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class trial {
public static void main(String[] args) throws IOException,
DocumentException{
Document document = new Document(PageSize.A4,50,50,50,50);
try {
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("D:\\SplitTable.pdf"));
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (DocumentException ex) {
ex.printStackTrace();
}
document.open();
Paragraph title1 = new Paragraph("Chapter 1",
FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new
Color(0, 0, 255)));
Chapter chapter1 = new Chapter(title1, 1);
chapter1.setNumberDepth(0);
Paragraph title11 = new Paragraph("This is Section 1 in Chapter 1",
FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD, new Color(255, 0,
0)));
Section section1 = chapter1.addSection(title11);
Paragraph someSectionText = new Paragraph("This text comes as part
of section 1 of chapter 1.");
section1.add(someSectionText);
Table t = new Table(3,2);
t.setBorderColor(new Color(220, 255, 100));
t.setPadding(5);
t.setSpacing(5);
t.setBorderWidth(1);
Cell c1 = new Cell("header1");
c1.setHeader(true);
t.addCell(c1);
c1 = new Cell("Header2");
t.addCell(c1);
c1 = new Cell("Header3");
t.addCell(c1);
t.endHeaders();
section1.add(t);
t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");
t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");t.addCell("1.1");
t.addCell("1.2");
t.addCell("1.3");
someSectionText = new Paragraph("Data following split table");
section1.add(someSectionText);
document.add(chapter1);
document.close();
}
}
Thanks,
Deepti
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions