This tutorial is intended for the PHP programmer who needs to incorporate PDF generation in a script without using external libraries such as PDFlib (often unavailable due to licensing restrictions or lack of funds). This tutorial is the second of two parts, and builds on what was covered in the first part. Therefore, if you have not yet gone through Part 1, you are advised to do so (or at least read through it), before going through this tutorial (Part 2). Apart from what was dealt with in Part 1, no knowledge of PDF file structure is required to understand this tutorial, as all references are explained.
Selecting 'rgb' and passing three color components gives us full color, represented by 3 separate 3-decimal-place numbers, followed by the letters 'rg'. So, for example: '0.800 0.400 0.200 rg' = purple-ish color. eg. setFillColor('rgb', 0.8, 0.4, 0.2)
A second, very similar function sets the drawing color:
Note that the only difference between these two functions is the lowercase/uppercase syntax. 'g', 'rg', and 'k' specify fill color, while 'G', 'RG', and 'K', specify draw color.
That's it! Calling either of these two functions will set the colors for any subsequent text or drawing output to your PDF document, and preserve that setting between pages.