ExceptionConverter: java.io.IOException: в документе нет страниц. Я использую iText

когда я выполняю приведенный ниже код

File f = new File("c:/sample.pdf");
PdfWriter.getInstance(document, new FileOutputStream(f));
document.open();
System.out.println("opening the document..");
PdfPTable headerTable=new PdfPTable(9);
PdfPCell cellValue = new PdfPCell(new Paragraph("Header 1"));
cellValue.setColspan(1);
headerTable.addCell(cellValue);
cellValue = new PdfPCell(new Paragraph("Header 2"));
headerTable.addCell(cellValue);
cellValue = new PdfPCell(new Paragraph("Header 3"));
headerTable.addCell(cellValue);
cellValue = new PdfPCell(new Paragraph("Header 4"));
headerTable.addCell(cellValue);

PdfPTable subHeaderTable = new PdfPTable(3);
PdfPCell subHeadingCell = new PdfPCell(new Paragraph("Header 5"));
subHeadingCell.setColspan(3);
subHeaderTable.addCell(subHeadingCell);
subHeaderTable.addCell("Sub heading 1");
subHeaderTable.addCell("Sub heading 2"); 
subHeaderTable.addCell("Sub heading 3");

headerTable.addCell(subHeaderTable);

document.add(headerTable);
document.close();

, я получаю исключение ниже. помогите пожалуйста

ExceptionConverter: java.io.IOException: The document has no pages.
    at com.lowagie.text.pdf.PdfPages.writePageTree(Unknown Source)
    at com.lowagie.text.pdf.PdfWriter.close(Unknown Source)
    at com.lowagie.text.pdf.PdfDocument.close(Unknown Source)
    at com.lowagie.text.Document.close(Unknown Source)

ПОЖАЛУЙСТА, ПОМОГИТЕ ДРУЗЬЯМ. ЗАРАНЕЕ СПАСИБО

6
задан alexblum 25 July 2011 в 12:57
поделиться