bpampuch / pdfmake

Client/server side PDF printing in pure JavaScript
http://pdfmake.org
Other
11.62k stars 2.04k forks source link

Spaces trimmed after new line #606

Closed imiegab closed 7 years ago

imiegab commented 8 years ago

Hi,

For some reason, spaces seams to be trimed after a new line. I'm trying to write code samples in pdf. I can't find a way to show a correct indentaton :

var dd = {
    content: [
        {
            text: 'if(foo){\n    console.log(foo);\n    console.log(bar);\n}'
        }
    ]
}

Result :

if(foo){ console.log(foo); console.log(bar); }

I tried to replace it with \t characters, got a weird behavior :

var dd = {
    content: [
        {
            text: 'if(foo){\n\t\tconsole.log(foo);\n\t\tconsole.log(bar);\n}'
        }
    ]
}

Result :

if(foo){   console.log(foo); console.log(bar); }

When the line starts with another character, there is no problem :

var dd = {
    content: [
        {
            text: 'if(foo){\n.    console.log(foo);\n.    console.log(bar);\n}'
        }
    ]
}

Result :

if(foo){ .  console.log(foo); .  console.log(bar); }

Is that a normal behavior? Am I doing something wrong? How can I get it right?

liborm85 commented 7 years ago

duplicate: https://github.com/bpampuch/pdfmake/issues/558