pdfme.color

class pdfme.color.PDFColor(color, stroke=False)

Bases: object

Class that generates a PDF color string (with function str()) using the rules described in pdfme.color.parse_color().

Parameters
  • color (int, float, list, tuple, str, PDFColor) – The color specification.

  • stroke (bool, optional) – Whether this is a color for stroke(True) or for fill(False). Defaults to False.

pdfme.color.parse_color(color)

Function to parse color into a list representing a PDF color.

The scale of the colors is between 0 and 1, instead of 0 and 256, so all the numbers in color must be between 0 and 1.

color of type int or float represents a gray color between black (0) and white (1).

color of type list or tuple is a gray color if its length is 1, a rgb color if its length is 3, and a rgba color if its length is 4 (not yet supported).

color of type str can be a hex color of the form “#aabbcc”, the name of a color in the variable colors in file color.py, or a space separated list of numbers, that is parsed as an rgb color, like the one described before in the list color type.

Parameters

color (int, float, list, tuple, str) – The color specification.

Returns

list representing the PDF color.

Return type

list