Closed swasher closed 4 months ago
Hi @swasher
Good question. You SHOULD be able to do this:
from fpdf import FPDF
from fpdf.drawing import DeviceCMYK
pdf = FPDF()
pdf.add_page()
pdf.set_font("Helvetica", size=40)
pdf.set_text_color(DeviceCMYK(.32, 0, .1, .59))
pdf.cell(text="Hello world!")
pdf.output("repro.pdf")
But currently, with fpdf2
version 2.7.9, you will get this error:
ValueError: too many values to unpack (expected 3)
I have just fixed that bug, and the fix will be included in the next version.
For now, you can simply do this instead:
from fpdf import FPDF
from fpdf.drawing import DeviceCMYK
pdf = FPDF()
pdf.add_page()
pdf.set_font("Helvetica", size=40)
pdf.text_color = DeviceCMYK(.32, 0, .1, .59)
pdf.cell(text="Hello world!")
pdf.output("repro.pdf")
Does this answer your question @swasher? 🙂
@allcontributors please add @Lucas-C for bug
@Lucas-C
I've put up a pull request to add @Lucas-C! :tada:
Does this answer your question @swasher? 🙂
Hi Lucas! Thank you for your support, now I can use CMYK color without any problem!)
Great! Closing this then 🙂
I want to use CMYK color space for object creation. But
FPDF.set_text_color()
method accept only RGB values:I found
DeviceCMYK
class indrawing.py
, but have no imagine how apply it toset_text_color
and similar functions.So, is there a way for assign CMYK color for object?