Description
In the static functions TCPDF_STATIC::formatPageNumber and TCPDF_STATIC::formatTOCPageNumber, the thousands separator is currently hard-coded as a dot (.):
public static function formatPageNumber($num) {
return number_format((float)$num, 0, '', '.');
}
public static function formatTOCPageNumber($num) {
return number_format((float)$num, 0, '', '.');
}
However, number formatting conventions vary by country or user preference.
For example:
- Many locales use a comma (
,) as the thousands separator
- Some locales use a space (
)
- Some users may not want any separator at all
Since TCPDF is used globally, having a fixed separator limits customization and forces developers to manually override or modify the library.
Proposed Enhancement
Introduce a configurable thousands separator that can be set at runtime, for example via:
- A new private static property in
TCPDF_STATIC
- A new constant or class setting
- A setter method such as
TCPDF_STATIC::setThousandsSeparator($separator)
This value should be used internally by:
TCPDF_STATIC::formatPageNumber
TCPDF_STATIC::formatTOCPageNumber
- Any other related formatting routines
Why This Matters
- Allows localization and internationalization of generated PDFs
- Avoids the need to patch or fork TCPDF just to change number formatting
- Enhances flexibility for developers generating documents with custom formatting requirements
Suggested Code Adjustment
Example idea (not final):
private static $thousands_separator = '.';
public static function setThousandsSeparator($separator) {
self::$thousands_separator = $separator;
}
public static function formatPageNumber($num) {
return number_format((float)$num, 0, '', self::$thousands_separator);
}
Description
In the static functions
TCPDF_STATIC::formatPageNumberandTCPDF_STATIC::formatTOCPageNumber, the thousands separator is currently hard-coded as a dot (.):However, number formatting conventions vary by country or user preference.
For example:
,) as the thousands separator)Since TCPDF is used globally, having a fixed separator limits customization and forces developers to manually override or modify the library.
Proposed Enhancement
Introduce a configurable thousands separator that can be set at runtime, for example via:
TCPDF_STATICTCPDF_STATIC::setThousandsSeparator($separator)This value should be used internally by:
TCPDF_STATIC::formatPageNumberTCPDF_STATIC::formatTOCPageNumberWhy This Matters
Suggested Code Adjustment
Example idea (not final):