Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap the text and display it next line if the text is too long than the size of original textbox #25

Open
haris-92 opened this issue Dec 4, 2018 · 4 comments

Comments

@haris-92
Copy link

haris-92 commented Dec 4, 2018

error
Hi

I have a scenario where my text is larger than the text box in the PDF, it is cutting off the text and only displaying the text which fits with in it .It is not wrapping and displaying in next line.could you please help me on this.

@galkahana
Copy link
Owner

you'll have to split the text.
you can use this to help you measure text:
https://github.com/galkahana/HummusJS/wiki/Show-text#measuring-text

@haris-92
Copy link
Author

haris-92 commented Dec 5, 2018

hi gal,

thanks for the quick response.can you please let me know the function to split the text and append the text.we have tried using the Quote but it din't give any results.

so we also tried adding \n between the texts,even it didnt give any results.when we focus on the field it adjusts and wraps to multiple lines.

@galkahana
Copy link
Owner

there's no command to split the text, you just put substrings of the text every time, per the measurements.
there's no \n in pdf, you move the position to a lower position.
you provide both x and y position to ctx.writeText() so you can use that.
to compute line height i like to use the height of 'd' in a font (which is a semi official way of doing that).

i once wrote something to compose text in a box. it includes bidi support and differet styles, and might be too much to read for what you need, but here it is if it helps:

https://github.com/galkahana/hummusrenderrer/blob/master/hummusrenderer.js#L479

@joer14
Copy link

joer14 commented Sep 11, 2019

If anyone else is looking for support for multiple lines, I hacked together a little solution in this gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants