boazsegev / combine_pdf

A Pure ruby library to merge PDF files, number pages and maybe more...
MIT License
733 stars 154 forks source link

Most RGB colors don't work #198

Closed chumakoff closed 3 years ago

chumakoff commented 3 years ago

When I set RGB color for a font or a box using options such as :font_color and :box_color, in most cases white color is shown instead. Only some limited amount of colors is properly displayed in PDF.

For example, if I set font color font_color: [0, 0, 255] (blue) it is shown correctly. But when I set this value font_color: [35, 72, 192] it shows white instead.

boazsegev commented 3 years ago

Hi @chumakoff ,

I understand your confusion as most RGB interfaces limit you to a 24bit color range where each color is in the 8 bit value range (0-255).

However, PDFs allow for floating point precision (which your display probably won't implement anyway). This means that the colors are in the range of 0-1, including all the infinite numbers in between.

You might find helpful examples in the README as well as the textbox method documentation where [0.5, 0.5, 0.5] is used for the color gray.

Good luck.