Search code examples
phpmpdf

Spot colors in mpdf


in mpdf (I use 8.1.4 with PHP 8.2) I can add spot color by code like this

$mpdf->AddSpotColor('Thru-cut', 10, 10, 10, 10); //name, c, m, y, k

But after that I can't see this spot colors ex. in Adobe Illustrator (it should appear in Swatches (Window -> Swatches)).

I checked and it's not a problem that mpdf generate pdf in version 1.4 %PDF-1.4. I mean other pdf's 1.4 generated from other programms works in AI.

I tried override ColorWritter writeSpotColors() with code from pdf but it still doesn't work. Has someone got similar problem, or maybe have solution?


Solution

  • So...

    I found the answer and it's simple.

    If you defined spot color via mpdf

    $mpdf->AddSpotColor('WHITE', 0, 66, 30, 13);

    Then you need to use it in code example to fill svg:

    <path fill="spot(WHITE, 100%)" ...

    This code snippet I found later can be usefull: https://github.com/mpdf/mpdf-examples/blob/development/example55_new_mPDF_v5-1_color_and_other_features.php