PDF export disable trimming

PDF export disable trimming

kthorngrenkthorngren Posts: 21,117Questions: 26Answers: 4,916

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

Answers

  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin
    Answer ✓

    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

  • kthorngrenkthorngren Posts: 21,117Questions: 26Answers: 4,916
    edited April 2017

    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

  • kthorngrenkthorngren Posts: 21,117Questions: 26Answers: 4,916

    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) or U+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

This discussion has been closed.