I have the next error.
I'm trying to create a PDF using iText, with an specific format. I opted to use tables for each section of the page, because the format that I need to do have tables. All right, I already did everything, I create the tables and adding it with the `doc.add(table)` method, this worked fine, but I needed to set the tables into an specific position. So I opted to use `table.writeSelectedRows()` method, and this worked fine. 

And here comes the error, this is my code:

```
table_SectionTwo.addCell(cell_White);
                table_SectionTwo.addCell(cell_White);
                table_SectionTwo.addCell(p);
                table_SectionTwo.addCell(cell_OrderDate);   
                table_SectionTwo.addCell(cell_CustomerOrderDate);
                table_SectionTwo.addCell(cell_OrderNumberSection);                                                              

    float[] columnWidths = new float[] {38f, 105f, 90f};
                    table_SectionTwo.setTotalWidth(columnWidths);
                    table_SectionTwo.setLockedWidth(true);
                    table_SectionTwo.completeRow();                 
                    table_SectionTwo.writeSelectedRows(0, -1, 260f, 770f, super.getPdfWriter().getDirectContent());                     
                    doc.add(table_SectionTwo);

```

As you can see, if I execute this code, this will add the same table 2 times

the problem is when I remove doc.add(table), I do this only for add one table into an specific position using `table.writeSelectedRows()`. This is how my code remains: 

```
table_SectionTwo.writeSelectedRows(0, -1, 260f, 770f, super.getPdfWriter().getDirectContent());                     
//super.addTable(table_SectionTwo);

```

I commented `doc.add(table)`.
And this should write only one table. But this doesn't work. When I do this throws: 

```
ExceptionConverter: java.io.IOException: The document has no pages.
    at com.itextpdf.text.pdf.PdfPages.writePageTree(PdfPages.java:113)
    at com.itextpdf.text.pdf.PdfWriter.close(PdfWriter.java:1217)
    at com.itextpdf.text.pdf.PdfDocument.close(PdfDocument.java:777)
    at com.itextpdf.text.Document.close(Document.java:398)
    at PDFConstructor.CloseDocument(PDFConstructor.java:85)
    at InvoicePDF.CloseDocument(InvoicePDF.java:58)
    at Demo.main(Demo.java:72)

```

The curious thing is when I comment the `doc.add(table)` this doesn't work, and when I comment the `table.writeSelectedRows()` the `doc.add(table)` works fine. 
This error occurs only when I have `doc.add(table)` commented and `table.writeSelectedRows()` uncommented.

Please help me..