Pdfmake: Adding image to a table cell with a rowSpan ?

Created on 16 Nov 2014  路  1Comment  路  Source: bpampuch/pdfmake

I try to add an image to a cell with rowSpan, but it always return "TypeError: Cannot read property 'replace' of undefined", here is the doc definition :

{
    table: {
        headerRows: 0,
        widths: [132, 132, '*'],
        body: [
            [
                { 
                    text: 'Text One', 
                    alignment: 'center', 
                    bold:true, 
                    fillColor:'#efefef' 
                },
                { 
                    text: 'Text Two', 
                    alignment: 'center', 
                    bold:true, 
                    fillColor:'#efefef' 
                },
                { 
                    rowSpan: 4, 
                    text:[
                        {
                            image: // a long dataURI string,
                            alignment: 'center',
                            width: 120,
                            margin: [0, 20, 0, 20]
                        },
                        {
                            text: 'This is a long text in a spanned rows',
                            alignment: 'center',
                            fontSize: 9
                        }
                    ]
                }
            ],
            ['\n \n \n \n \n \n', '\n \n \n \n \n \n', {}],
            ['Name: ', 'Name: ', {}],
            ['Date: ', 'Date: ', {}]
        ]
    }
}

Is there anything wrong? Or adding an image to cell with a rowSpan / colSpan is still not supported?

Thanks...

Most helpful comment

Issue fixed, after I replaced the 'text' node with 'stack' node inside the rowSpan. Here are the final doc definition that works :

{
    table: {
        headerRows: 0,
        widths: [132, 132, '*'],
        body: [
            [
                { 
                    text: 'Text One', 
                    alignment: 'center', 
                    bold:true, 
                    fillColor:'#efefef' 
                },
                { 
                    text: 'Text Two', 
                    alignment: 'center', 
                    bold:true, 
                    fillColor:'#efefef' 
                },
                { 
                    rowSpan: 4, 
                    stack:[
                        {
                            image: // a long dataURI string,
                            alignment: 'center',
                            width: 120,
                            margin: [0, 20, 0, 20]
                        },
                        {
                            text: 'This is a long text in a spanned rows',
                            alignment: 'center',
                            fontSize: 9
                        }
                    ]
                }
            ],
            ['\n \n \n \n \n \n', '\n \n \n \n \n \n', {}],
            ['Name: ', 'Name: ', {}],
            ['Date: ', 'Date: ', {}]
        ]
    }
}

>All comments

Issue fixed, after I replaced the 'text' node with 'stack' node inside the rowSpan. Here are the final doc definition that works :

{
    table: {
        headerRows: 0,
        widths: [132, 132, '*'],
        body: [
            [
                { 
                    text: 'Text One', 
                    alignment: 'center', 
                    bold:true, 
                    fillColor:'#efefef' 
                },
                { 
                    text: 'Text Two', 
                    alignment: 'center', 
                    bold:true, 
                    fillColor:'#efefef' 
                },
                { 
                    rowSpan: 4, 
                    stack:[
                        {
                            image: // a long dataURI string,
                            alignment: 'center',
                            width: 120,
                            margin: [0, 20, 0, 20]
                        },
                        {
                            text: 'This is a long text in a spanned rows',
                            alignment: 'center',
                            fontSize: 9
                        }
                    ]
                }
            ],
            ['\n \n \n \n \n \n', '\n \n \n \n \n \n', {}],
            ['Name: ', 'Name: ', {}],
            ['Date: ', 'Date: ', {}]
        ]
    }
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dmatesic picture dmatesic  路  3Comments

imoum007 picture imoum007  路  3Comments

m-brudi picture m-brudi  路  3Comments

davidyeiser picture davidyeiser  路  3Comments

Christian24 picture Christian24  路  3Comments