Hey again.

I have been trying to get a nested table to show in a document.  The idea is
for having multiple checkboxes in the nested table.

The idea is for a header to be set on the nested table with a bunch of
checkboxes, each below the other.

I'm not really seeing what I'm doing wrong.  If I put the table that is
supposed to be nested onto the document instead of the parent table it shows
just fine, including checkboxes and label.  And if I remove the CellEvent
building the checkbox from the nested table it also gets shown on the parent
table correctly with the header alone.

If I add the header to the nested table and the cell with the CellEvent
building the checkbox(es) to the parent table all of it gets shown.

But if I place all of them together as nested table, nothing of the nested
table gets shown.  I'll include a bunch of (spaghetti) code.

 public void setVakD() throws DocumentException, IOException {
        this.huidigVak="VakD";
        table = new PdfPTable(1);
        this.initA001Table();

        PdfPCell cell;
        Font titlefont = new Font(Font.COURIER,12,Font.BOLD);
        Paragraph paragraph = new Paragraph();
        Chunk chunk = new Chunk("VAK D: ADMINISTRATIEVE GEGEVENS\n" +
                "VAN DE PERSOON VOOR WIE DE AANVRAAG WORDT
INGEDIEND",titlefont);
        paragraph.add(chunk);
        cell = new PdfPCell(paragraph);
        table.addCell(cell);

        document.add(table);
        table = new PdfPTable(4);
        initA001Table();
        this.addTableInfo("Voor aanvullende inlichtingen kan de aanvrager of
de wettelijke vertegenwoordiger" +
                " gecontacteerd worden",4);
        this.addTextField("op telefoonnr.: ","");
        this.addTextField("van (uur):","");
        
        document.add(table);

        table = new PdfPTable(2); //table is a private instance variable
        this.addTableInfo("Met het oog op eventuele rechtstreekse stortingen
ten gunste van de aanvrager,",2);
        addTextField("Rekeningnummer:","");
        this.addTableInfo("Geniet de persoon voor wie de aanvraag wordt
ingediend een tegemoetkoming of vergoeding van een andere instantie?",2);
        this.addTableInfo("Zo ja, vak D1 invullen",1);
        this.addTableInfo("Zo niet, vak D2 invullen",1);

        document.add(table); 
        table = new PdfPTable(2);
        this.initA001Table();
        table.addCell(this.createVakD1());

        //writer.getDirectContent().stroke();
        document.add(table);


    }

    public PdfPTable createVakD1() throws DocumentException, IOException {
        PdfPTable D1Table = new PdfPTable(1);
        PdfPCell cell = new PdfPCell();
        cell.setBorder(0);
        Font titlefont = new Font(Font.COURIER,12,Font.BOLD);
        Phrase d1Title = new Phrase("VAK D1: VAN WELKE
INSTANTIE(S)?",titlefont);
        cell.addElement(d1Title);
        D1Table.addCell(cell);

        cell = new PdfPCell();

        cell.setCellEvent(new BoxEvent(writer,"R.V.A."));
        
        D1Table.addCell(cell); // If I add this cell to the parent table it
gets drawn.
                                  
        //document.add(D1Table); // If i uncomment this, the table gets
drawn as well.
               
        return D1Table;
    }

/*
This class is taken from this here forum, although slightly adjusted. 
Thanks for this ;-)
*/
public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[]
canvases)
        {


        float llx = position.getLeft()+12 ;
       float lly = position.getTop()-10 ;

        try
                {
                        RadioCheckField rf = new RadioCheckField(writer, new 
Rectangle(llx, lly,
llx + 10, lly + 10), name, "Yes");

                        rf.setCheckType(RadioCheckField.TYPE_CHECK);
                        rf.setBorderWidth(BaseField.BORDER_WIDTH_THIN);
                        rf.setBorderColor(Color.black);
                        rf.setBackgroundColor(Color.white);
                        rf.setChecked(false);
            rf.setAlignment(Element.ALIGN_LEFT);

            BaseFont bf = BaseFont.createFont(BaseFont.TIMES_ROMAN,
                        BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);

            PdfContentByte cb = writer.getDirectContent();
            cb.beginText();
            cb.setFontAndSize(bf,10);
            cb.showTextAligned(Element.ALIGN_LEFT,name,llx+15,lly,0);
            PdfFormField ff = rf.getCheckField();

            writer.addAnnotation(ff);
            cb.endText();

        }
                catch (Exception e)
                {
                        throw new ExceptionConverter(e);
                }
        }
}
-- 
View this message in context: 
http://www.nabble.com/PdfPTable-does-not-show-if-nested-tp18026311p18026311.html
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar

Reply via email to