FIX #40005: Correct text truncation for PDFs (now correct when MAIN_DISABLE_TRUNC is on) - #40126
FIX #40005: Correct text truncation for PDFs (now correct when MAIN_DISABLE_TRUNC is on)#40126mdeweerd wants to merge 4 commits into
Conversation
|
OK to backport ? |
|
The approach is right, measuring against real PDF width instead of counting characters, and making it independent of MAIN_DISABLE_TRUNC solves the masking concern I raised on the issue. Two problems with the IBAN call sites though, both from the signature change. The two signatures do not line up: and the call was converted positionally: Traced through your own mapping code, that resolves to: So the ellipsis becomes the literal text "UTF-8", and the trailing 1, which was $nodot in the old call, is silently dropped. With ellipsis_pos 0 the ellipsis is blanked, so it may not surface visually, but the argument is still wrong and would bite if the position ever changed. Second and more important, 6 no longer means the same thing. In dol_trunc it was six characters, in pdfTruncateText it is six user units of width, so millimetres. Six millimetres fits roughly two characters at a normal font size, not six, so the masked IBAN gets shorter than intended. Worth checking on a generated invoice. Affected sites, all three the same pattern: Those three are the masking case rather than layout, and they are the ones I flagged on #40005: they exist to print only the start of a bank account number on a customer-facing invoice. Getting the width wrong there shows fewer characters, which is harmless, but the argument shift is worth fixing regardless so the next person reading it is not misled. Everything else in the diff, the Project title and RefCustomer conversions, looks right to me since those are genuine layout truncations against a MultiCell width. |
440c92b to
e60f0f9
Compare
This looks a structural change that may have a lot of side effect, so it is a change not elligible for backport on past stable versions. |
e60f0f9 to
3b9abe9
Compare
4676842 to
478ae1b
Compare
…MAIN_DISABLE_TRUNC is on) # FIX Dolibarr#40005: Correct text truncation for PDFs (incorrect when MAIN_DISABLE_TRUNC is on) This commit replaces all instances of dol_trunc with the new pdfTruncateText method in various PDF generation modules. This is required to cope with `MAIN_DISABLE_TRUNC=1` which converts dol_trunc to a no-op because of CSS based truncation. PDF does not rely on CSS.
# Fix: Remove UTF-8 encoding parameter in pdfTruncateText calls The changes remove the UTF-8 encoding parameter from pdfTruncateText calls in the following files: - htdocs/core/modules/action/doc/pdf_standard_actions.class.php - htdocs/core/modules/facture/doc/pdf_octopus.modules.php - htdocs/core/modules/facture/doc/pdf_sponge.modules.php This parameter is not needed after changing dol_substr to pdfTruncateText. Highlighted by @pixodeo.
The pdfTruncateText method has been moved from CommonDocGenerator class to pdf.lib.php and renamed to pdf_truncate_text.
478ae1b to
95dda86
Compare
FIX #40005: Correct text truncation for PDFs (now correct when MAIN_DISABLE_TRUNC is on)
This commit replaces all instances of dol_trunc with the new pdfTruncateText method in various PDF generation modules.
This is required to cope with
MAIN_DISABLE_TRUNC=1which converts dol_trunc to a no-op because of CSS based truncation. PDF does not rely on CSS.