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

Undefined array key "None" in tcpdf_colors.php #761

Open
KasparAas opened this issue Nov 12, 2024 · 0 comments
Open

Undefined array key "None" in tcpdf_colors.php #761

KasparAas opened this issue Nov 12, 2024 · 0 comments

Comments

@KasparAas
Copy link

KasparAas commented Nov 12, 2024

Description:
I’ve encountered a warning in tcpdf_colors.php at line 260 when providing an incorrect css attribute "border: 0 #ffffff none;". The warning arises from a case where a specified spot color does not exist or incorrect:
return $spotc[self::$spotcolor[$color][4]];

Issue:
When an undefined color key is accessed, PHP displays a warning: Undefined array key "None". This can happen if the spot color is not set or does not exist in the $spotc array. This will lead to another error if we still continue generating a pdf: "TCPDF ERROR: Some data has already been output, can't send PDF file"

Proposed Solution:
To handle this situation more effectively, I suggest either throwing an appropriate exception to clearly indicate the missing color or using false as a fallback value, which would prevent warnings and ensure smoother handling:
return $spotc[self::$spotcolor[$color][4]] ?? false;

This adjustment would provide more reliable behavior in cases where a color key is undefined.

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

No branches or pull requests

1 participant