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

Option to define wrapmode="CHAR" within a template #1159

Closed
carlhiggs opened this issue May 8, 2024 · 3 comments · Fixed by #1176
Closed

Option to define wrapmode="CHAR" within a template #1159

carlhiggs opened this issue May 8, 2024 · 3 comments · Fixed by #1176

Comments

@carlhiggs
Copy link

carlhiggs commented May 8, 2024

Please explain your intent
I am using fpdf2 to produce reports using verified translations in multiple languages, using the template features to define the report layout. One of my collaborators validating our Japanese language report advised that inappropriate line breaks were occurring. Investigating this, I see that is because there are not spaces in this language, and wrapping should be by character not word.

I see there is functionality to optionally support word wrapping based on character instead of word when using the non-template approach to pdf construction with multicell() or write() using the option wrapmode="CHAR" (as per fpdf2 documentation). However, I don't believe this is configurable when using a template to define the PDF layout, or if it is I don't believe this is documented.

Describe the solution you'd like
Allowing the option to set wrapmode="CHAR" within a template, or providing guidance on how to achieve this effect would be greatly appreciated and very useful. This could be another parameter, e.g. like 'align' or 'rotate'. It need only be used for the relevant text formatting types, and have a default of 'word' but option to set otherwise (i.e. to 'CHAR', for scripts like Chinese and Japanese, etc).

I'm hopeful this could be relatively straightforward to implement, given the existing technical functionality to do this (which is great, thank you!).

@gmischler
Copy link
Collaborator

Welcome to fpdf2, @carlhiggs !

Yes, this is one of the many limitations that currently plague our template system (as evicenced eg. by #1119).
One of the reasons for that is the CSV input file format, which makes it rather annoying to have many different fields or even different record types in the first place. I think we should find a more structured replacement for that rather soon. JSON might be a candidate, or maybe even the ini file format would be good enough.

But for the time being, adding arguments to records that are only accessible through literal dict definitions is perfectly acceptable.
If you feel up to it, a PR would be very welcome.

@carlhiggs
Copy link
Author

Hi @gmischler thanks for getting back to me and the pointers for how this could be addressed --- I'll have a look later this week to see if this is something I can figure out; if I can make some progress, I'll make a PR. Its a great project, and if I am able to make a contribution, would love to.

@Lucas-C
Copy link
Member

Lucas-C commented May 13, 2024

I'll have a look later this week to see if this is something I can figure out; if I can make some progress, I'll make a PR. Its a great project, and if I am able to make a contribution, would love to.

Great! Thank you for considering a contribution to fpdf2 👍
A good starting point for contributing should be this documentation page: https://py-pdf.github.io/fpdf2/Development.html
Feel free to ask any question if you face problems during the process!

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

Successfully merging a pull request may close this issue.

3 participants