Due to popular demand from customers, we have recently added support for adding content made with device-dependent CMYK colors in pdfHTML 4.0.4 by using CSS syntax. We did this by allowing users to define colors using the
device-cmyk() function, which is a feature from the CSS Color Module Level 4.
How it works
To create a PDF document with CMYK colors using pdfHTML you'll need to define colors in your CSS with the
device-cmyk() function, as shown in the example HTML below:
Be aware, this is still an experimental feature in CSS. When you've defined the colors in this way, your browser likely won't show these colors since the CSS feature hasn't yet been implemented in most current browsers.
To allow pdfHTML to use to this CSS feature you'll need to add a method call to your iText code to enable processing. This feature is not supported out of the box since
device-cmyk() only exists in CSS working drafts. Instead, we've added the
CssDeclarationValidationMaster#setValidator static method (Java/.NET) specifically to handle this and potentially other new CSS features we might add support for in the future. For this feature, you will need to add a new CssDeviceCmykAwareValidator to the static method to enable processing.
The minimal iText code required to make this feature work would look like this for Java:
And for C# it would be the following:
The result of this HTML and iText code produces a PDF with device-dependent CMYK colors that can be used in a printing workflow, for example.