pdfjs
pdfjs copied to clipboard
Text rotation / transform
Hi Markus and thanks for this library.
I would love a text or cell option to rotate text in a cell to a certain angle. Often when creating PDF reports, there is limited space and headers take up alot of space when the column only has a number. Making a rotate property would be of a great help.
I would be happy to assist and make a pull request if you could point me in the right direction.
Hi Bergur,
sorry for getting back so late. This definitely sounds like a reasonable feature to have! Unfortunately really hard to achieve with the approach I've chosen for pdfjs. pdfjs basically uses a greedy-algorithm (making decisions based on what is best at each step without looking far into the future, or even testing and comparing different variations) to decide where to place words (and when to do line breaks, etc.).
This works well for horizontal text, but makes rotated/transformed text a lot harder. As a first step, it would be useful to come up with an approach of how to calculate where each word goes in a rotated/transformed scenario, before I'd be able to point out some starting points in the code.
I guess the problem is defined by something like:
- We have a cell with a given
width
(height is variable) - We have a set of words (that makes out the text content of the cell)
- We have a function to measure the
height
andwidth
of each word (and its style) - How to evenly distribute the words in the cell?