|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10436 pdf_setcolor optional parameters not optional
Submitted: 2001-04-21 22:30 UTC Modified: 2001-08-19 04:29 UTC
From: graeme at inetix dot com dot au Assigned:
Status: Closed Package: PDF related
PHP Version: 4.0 Latest CVS (15/04/2001) OS: Linux x86
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: graeme at inetix dot com dot au
New email:
PHP Version: OS:


 [2001-04-21 22:30 UTC] graeme at inetix dot com dot au
In pdf_setcolor() which is part of pdflib-4.0 and in the CVS of PHP, pdf_setcolor() can take a number of paramters depending on the type of color space you choose.
This can be either rgb, gray, pattern, spotcolor or cmyk.

Depending on what colorspace you choose, the paramters c1, c2, c3 and c4 are either optional or compulsory. For example, if you choose a colorspace of 'rgb' then you only need to specify c1, c2 and c3. A colorspace of 'cmyk' requires all four and a colorspace of 'gray', 'spotcolor' or 'pattern' merely requires one.

Currently though, you must specify all 4 values with the non-used ones being ignored. If you do not specify the ignored paramters then the function terminates the script with an error.

For example
pdf_setcolor($pdf, "stroke", "rgb", 0.5, 0.5, 0.5);
should be correct because you only need to specify the reg, green and blue components. In reality the function must be used as
pdf_setcolor($pdf, "stroke", "rgb", 0.5, 0.5, 0.5, 0.0);
with the fourth paramter being ignored.

The problem is more pronounced when you specify a pattern or gray color
pdf_setcolor($pdf, "fill", "pattern", $pattern);
is what it would logically be, but the function requires
pdf_setcolor($pdf, "fill", "pattern", $pattern, 0.0, 0.0, 0.0);

which IMHO is just confusing and makes the function harder to understand in the long run.
Can the function be changed to make the optional paramters truly optional? A simple switch/case statement in the function for the colorspace should suffice.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-19 04:29 UTC]
This is fixed in CVS. Try the latest snapshot:

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 03:01:30 2024 UTC