Use pdfMake with data input in Angular 2 / TypeScript
<p>I'm trying to create PDF from data input in an Angular 2 project. To do this, I integrated <a href="https://github.com/bpampuch/pdfmake" rel="nofollow">pdfMake</a>. Creating static PDF works just fine, but the moment I try to print out some values, it goes wrong. </p>

<p>Please have a look at this plunker: <a href="https://plnkr.co/edit/7tPFTAjKWwaRp1IbT0Tg?p=preview" rel="nofollow">https://plnkr.co/edit/7tPFTAjKWwaRp1IbT0Tg?p=preview</a></p>

<p>I manage to put an object into my buildPdf function and it gets loged to the console. But when I try to add one of my object values to the pdfMake docdefinition, I'm getting the error message: </p>

<blockquote>
  <p>ORIGINAL EXCEPTION: TypeError: Cannot read property 'firstName' of undefined </p>
</blockquote>

<pre><code>var docDefinition = {
    content: [{
        text: 'My name is: ' + pdfContent.firstName  + ' ' + pdfContent.lastName + '.'
    }]
}
</code></pre>

<p>I tried to rule out a typing issue by rewriting my buildPdf.js in typescript, which looked something like this: </p>

<pre><code>var buildPdf: (value: {firstName: string, lastName: string}) =&gt; any =
function(value: {firstName: string, lastName: string}): any {
    let docDefinition:any = {
        content: [{
            text: 'This is a test.'
        }]
    }
    console.log(value);
    return docDefinition;
}
</code></pre>

<p>The result stayed the same, though.</p>

<p>Why am I able to console.log the object but not to access its properties? What have I missed? </p>