pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

hyphenating text

Open Christian24 opened this issue 6 years ago • 4 comments

Hello,

A client asks me for hyphenating text in the pdf output. Looking at https://github.com/bpampuch/pdfmake/issues/264 it is currently not possible. I am thinking about implementing this if it is possible in a reasonable timeframe and you're happy to accept a pull request. My goal would be to offer a callback hyphenateWord(word) that the user can override with whatever functionality the user pleases. I do not want to add new dependencies or locale features to pdfmake.

I think my new code should be executed somewhere here: https://github.com/bpampuch/pdfmake/blob/c2cdd465e7f5146079e7f4a916e37d2d40567393/src/layoutBuilder.js#L679

Am I on the right path?

Christian24 avatar Oct 03 '18 07:10 Christian24

Issue https://github.com/bpampuch/pdfmake/issues/264 is about hiding text without breaking.

Now is supported by issue https://github.com/bpampuch/pdfmake/issues/204 "hard-wrapping" text words (if is word too long is breaked after max size) here: https://github.com/bpampuch/pdfmake/blob/c2cdd465e7f5146079e7f4a916e37d2d40567393/src/layoutBuilder.js#L678-L696

Text hyphenating according to some algorithm is too complicated to implementation. I do not know how it could be solved now.

liborm85 avatar Oct 05 '18 13:10 liborm85

How about offering a callback function like a suggested, so users can implement it themselves? If the callback function is undefined, the library would just fall back to the default behavior that is there now.

Christian24 avatar Oct 08 '18 08:10 Christian24

One nice way could be the support of softhyphens (html ­ symbol, utf8 U+00AD). This way the dev can supply pre tagged text to pdfmake and pdfmake does not need to rely on anything. If no soft hyphen is supplied, nothing changes. Currently, the softhyphen is interpreted as whitespace, therefore the line break is done correctly, but at the end of a line, the U+00AD needs to replaced by - or U+2011 (which might result in a moving of the word to the next line).

SandraK82 avatar Apr 19 '19 17:04 SandraK82

any progress on this?

luizbills avatar Jul 06 '23 19:07 luizbills