Is it possible to change the color in stamp_text? #107
-
I want to cchange the color inside stamp_text for each line (for every \n) and just want to add my own style to the contents of the text. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Unfortunately not natively, no. While changing text colours is something that would be (relatively) easy to implement---modulo subtleties with colour spaces---implementing even "basic" styling is a lot less straightforward than it sounds. Rich text layout in PDF requires the PDF creation software to juggle multiple font resources, deal with paragraph layout, text shaping, etc. The general problem is a lot harder than in .docx/.odt/.html/.epub/.... Right now, pyHanko's appearance generation code only performs very primitive text layout: no word wrapping, use one single font, no frills. On the other hand, I did implement OTF font support with shaping performed through HarfBuzz. That said, the main reason for doing so was enabling support for CJK scripts and embedding font subsets, not fancy styling. Automatic paragraph layout is a tricky problem that's way beyond pyHanko's scope (it would add a lot of potentially hard-to-maintain code that has nothing to do with digital signing, basically). I am however willing to accept PRs for the following features:
If anyone out there wants to work on one or more of these: please open a discussion so we can discuss implementation strategies. So, what options do you have in the meantime?
|
Beta Was this translation helpful? Give feedback.
Unfortunately not natively, no. While changing text colours is something that would be (relatively) easy to implement---modulo subtleties with colour spaces---implementing even "basic" styling is a lot less straightforward than it sounds. Rich text layout in PDF requires the PDF creation software to juggle multiple font resources, deal with paragraph layout, text shaping, etc. The general problem is a lot harder than in .docx/.odt/.html/.epub/....
Right now, pyHanko's appearance generation code only performs very primitive text layout: no word wrapping, use one single font, no frills. On the other hand, I did implement OTF font support with shaping performed through HarfBuzz. That said, t…