
if table exceeds the maximum width of the page how to manage it

package com.geek.tutorial.itext.table;
import java.io.FileOutputStream;
import com.lowagie.text.pdf.PdfPTable; import com.lowagie.text.pdf.PdfPCell; import com.lowagie.text.pdf.PdfWriter; import com.lowagie.text.Document; import com.lowagie.text.Paragraph;
public class SimplePDFTable {
public SimplePDFTable() throws Exception{
Document document = new Document();
PdfWriter.getInstance(document,
new FileOutputStream("SimplePDFTable.pdf"));
document.open();
PdfPTable table = new PdfPTable(2); // Code 1
// Code 2
table.addCell("1");
table.addCell("2");
// Code 3
table.addCell("3");
table.addCell("4");
// Code 4
table.addCell("5");
table.addCell("6");
// Code 5
document.add(table);
document.close();
}
public static void main(String[] args) {
try{
SimplePDFTable pdfTable = new SimplePDFTable();
}catch(Exception e){
System.out.println(e);
}
}
}

package com.geek.tutorial.itext.table;
import java.io.FileOutputStream;
import com.lowagie.text.pdf.PdfPTable; import com.lowagie.text.pdf.PdfPCell; import com.lowagie.text.pdf.PdfWriter; import com.lowagie.text.Document; import com.lowagie.text.Paragraph;
public class SimplePDFTable {
public SimplePDFTable() throws Exception{
Document document = new Document();
PdfWriter.getInstance(document,
new FileOutputStream("SimplePDFTable.pdf"));
document.open();
PdfPTable table = new PdfPTable(2);
table.addCell("1");
table.addCell("2");
table.addCell("3");
table.addCell("4");
table.addCell("5");
table.addCell("6");
document.add(table);
document.close();
}
public static void main(String[] args) {
try{
SimplePDFTable pdfTable = new SimplePDFTable();
}catch(Exception e){
System.out.println(e);
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.