Pdfmake: Leading Space Auto-Strip

Created on 14 Apr 2016  路  4Comments  路  Source: bpampuch/pdfmake

It appears as though there is no way to prevent pdfmake from striping leading whitespace from a paragraph. Why does it do this? There are many cases where I would want leading whitespace. For example, paragraph indents. Or code snippets.

I would like to put this into my pdf:

{
    "sample": {
        "json": "nested"
    }
}

However, because pdfmake auto-strips leading whitespace, it ends up looking like crap:

{
"sample": {
"json": "nested"
}
}

Am I just missing something?

feature request

Most helpful comment

I was able to hack around the issue with invisible unicode characters, but it's not the best solution IMO:

var str = JSON.stringify({sample: "json"}, undefined, 4);
    str = str.replace(/ /g, '\u200B'); //Replace all spaces with invisible unicode

All 4 comments

I also am having this issue.

I was able to hack around the issue with invisible unicode characters, but it's not the best solution IMO:

var str = JSON.stringify({sample: "json"}, undefined, 4);
    str = str.replace(/ /g, '\u200B'); //Replace all spaces with invisible unicode

I was also looking into that. Thanks!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

m-brudi picture m-brudi  路  3Comments

SummerSonnet picture SummerSonnet  路  3Comments

jokris1 picture jokris1  路  3Comments

Christian24 picture Christian24  路  3Comments

dmatesic picture dmatesic  路  3Comments