This topic is locked
[SOLVED]

 Passing a table from php to pdfmake in custom button

10/13/2020 11:37:42 AM
PHPRunner General questions
mbintex author

Hi,
probably I am doing something really dumb, I don´t know.
Trying to build a PDF with pdfmake from scratch via a custom button.
I am passing some data from SERVER to CLIENT AFTER with result().
One result variable contains this:

{layout: 'lightHorizontalLines',

table: {widths: ['*', '*', 100],

headerRows: 1,

body: [

['Umlageart', 'Berechnung', {text: 'Anteil', alignment: 'right'}],

['Quadratmeter',{text:'(71,00 QM * 365 Tage) / (314,00 Gesamt-QM * 365 Gesamt-Tage)'},

{text: '22,61%', alignment: 'right'}],

['Einheiten',{text:'(1 Einheit * 365 Tage) / (5 Gesamt-Einheiten * 365 Gesamt-Tage)'},{text:

'20,00%', alignment: 'right'}],

['Personen',{text:'(1,00 Personen * 365 Tage) / (7,00 Gesamt-Personen * 365 GesamtTage)'},{text: '14,29%', alignment: 'right'}],]

}}


This renders on the pdfmake.js playground perfectly.
But as soon as I try to incorporate this via my result variable in the document definition by

var umlagefaktoren=result['umlagefaktoren'];
var dd={
header: {

columns: [

{ text: htmlToPdfMake(result['kopf']), style: 'documentHeaderCenter' },

]

},
footer: {

columns: [

{ text: htmlToPdfMake(result['fuss']), style: 'documentFooterCenter' },

]

},
content: [
//Anschriftfeld

{

columns: [

{

text: htmlToPdfMake(result['absender']),

style:'absenderzeile'

},

{

text: ''



},

]

},

...
{

text: 'Umlagefaktoren',

style: 'betreff'

},

umlagefaktoren,

'\n\n',

{

text: htmlToPdfMake(result['gruss'])

}

],
...
};


the table data is not rendered as a table in the resulting PDF, but as plain text.
How would I get a table from this?

mbintex author 10/14/2020

following this https://stackoverflow.com/questions/1086404/string-to-object-in-js
and rushing my string through an "eval" with



var string=result['umlagefaktoren'];

eval('var umlagefaktoren='+string);


I get the table rendered :-)