Reputation: 157
I would like to put a specific color to a svg that i insert in a PDF thanks to TCPDF
this color will allow a printer to cut automatically I know i would have to use spotcolors.
as here: https://tcpdf.org/examples/example_037/
the SetFillSpotColor function works perfectly for text or a rectangle but when I use ImageSVG this has no effect
i add name CutContour directly in svg, example :
<path fill="CutContour" d="M271.44,849.229c-1.254,0.174-2.604,0.489-3,0.701...
but not works too.
example my code PHP:
$pdf->AddSpotColor('CutContour', 0, 0, 0, 100);
$pdf->ImageSVG( $filename_svg , 0, 0, $largeurmm, $hauteurmm, 'CutContour', false, false, 0, false);
I can't find a solution, can you help me?
Upvotes: 0
Views: 784
Reputation: 4029
I'm guessing you can't get away with using cutcontour
as the spot color name, correct? The ImageSVG parser appears to force the color name to lowercase, which means it doesn't match against the CutContour
name when it goes to look for it in the TCPDF instance's list of added spot colors.
If that guess is correct, try adding the color to the predefined list in the TCPDF_COLORS
class (see spotcolor static property), either by editing include/tcpdf_colors.php
or adding a line like this to your script.
TCPDF_COLORS::$spotcolor['cutcontour'] = array( 0, 0, 0, 100, 'CutContour');
$pdf->AddSpotColor('CutContour', 0, 0, 0, 100);
This way, when it goes to look for the lowercase name, it'll find a match and return the proper spot color array. (Note: Tested in TCPDF 6.2.17)
Upvotes: 1