I'm receiving data from a text area in a form and writing it to my PDF. Unfortunately if the text area contains a lot of text it all writes to only the one line and anything that doesn't fit is cut off. Is there a simple way of having Hummus wrap the long string onto a new line if it reaches the end of the page?
Right now I'm just using .writeText -
.writeText(
myLongString,
50, 645
)
I looked for this option too. But I think library doesn't support it (I gave up). You should implement it yourself.
Biggest problem that you will face with is to determine where to split text. You can take a look at Measuring Text for that. If you can choose that splitting points, then printing those lines will be relatively easy (just print every line as separate texts).
Thank you vedat-keklik. I'll look into that!
As a note, In another project I once implemented line breaking with BIDI text.
I'll provide a pointer here to where in the code this starts happening:
https://github.com/galkahana/hummusrenderrer/blob/master/hummusrenderer.js#L639
This worked for me thanks to @joer14
https://gist.github.com/joer14/1e063753a6bae7996184b458cf12d8f8#file-pdf-form-fill-js-L167
Most helpful comment
As a note, In another project I once implemented line breaking with BIDI text.
I'll provide a pointer here to where in the code this starts happening:
https://github.com/galkahana/hummusrenderrer/blob/master/hummusrenderer.js#L639