PDF export disable trimming
PDF export disable trimming
kthorngren
Posts: 21,587Questions: 26Answers: 5,004
Is there a way to disable trimming with the PDF export?
I tried trim: false
under the PDF button definition and in exportOptions
. My goal is to keep the leading spaces in the text.
Kevin
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Looks like this is a pdfmake issue I'm afraid. If you load up their playground and just put some whitespace at the start of the paragraph, it is removed.
There is this issue about it in the pdfmake github tracker.
Looks like a UTF hack is the only way around it at the moment.
Allan
Thanks for the pointer. I tried a few different unicode spaces but haven't gotten it to work. If I can't get it to work I can remove the PDF option and just use Print then save to PDF.
Kevin
Somehow I stumbled across an answer that works for my case (Mac Preview). Not sure if it works with other PDF viewers. Found reference, on a MS SQL forum, to using
U+200C (zero-width non-joiner)
orU+2060 (Word Joiner)
as the leading white space character.Doing this with either of those seems to work:
data = data.replace( / /g, '\u200C' );
I tried
U+00A0 (non-breaking space)
and a few other variants which did not work.Thanks @allan for the reference to the unicode workaround.
Kevin