HTML2PDF - Generated PDF isn't true CMYK black (0,0,0,100%)

1.6k views Asked by At

I'm using HTML2PDF to generate a PDF from text from a textarea-input and an image uploaded by the user. I'm using a style-block to set up the CSS, which works great, the resulting PDF looks exactly like I want.

However, the PDF is supposed to go straight to print without any additional converting whatsoever. And here comes my problem:

When I'm inspecting the PDF the text and black border of the PDF is NOT CMYK 0% 0% 0% 100% but instead some weird stuff like CMYK 22% 46% 17% 94% which means it's not supposed to be printed because each letter would be printed 4 times (at least that's what I'm told, I don't know anything about print, I just know it has to be 0 0 0 100%~)

EDIT: To avoid confusion: This will be mostly black text on white background with a black border, think of classifieds, ads from a print magazine. Images added to the classified will not need to be 100% black.

Some of the code I'm using

<?php echo "
        <style>
        .contentwrapper {
            position: relative;
        }
        .contentpdf {
            border: 1mm;
            border-style: solid;
            border-color: #000000;
            padding: 1mm;
            position: absolute;
            word-wrap: break-word;
            word-break: break-all;
            text-align: justify;
            height: 50mm;
            width: 100mm;
            line-height: 2.5mm;
            color: #000000;
            font-family: 'Arial';
        }
        h1 {
            font-size: 3.5mm;
            line-height: 5mm;
            margin: 0 0;
            margin-top: 0mm;
            margin-bottom: 0mm;
            padding: 0 0;
            color: #000000;
            font-family: 'Arial';
        }
        p {
            font-size: 2.5mm;
            margin: 0 0;
            margin-bottom: 0.5mm;
            margin-top: 0.5mm;
            padding: 0 0;
            color: #000000;
            font-family: 'Arial';
        }
        b, strong {
            word-break: break-all;
            word-wrap: break-word;
        }
        </style>
    <page format='" . $width . "x" . $height ."' orientation='" . $orientation ."' backcolor='#FFFFFF'>
     <div class='contentwrapper'>
      <div class='contentpdf'>
        " . $html  ."
      </div>
     </div>
    </page>";
$content = ob_get_clean();

$html2pdf = new HTML2PDF('L', 'A4', 'de', false, 'UTF-8', array(0,0,0,0));

$html2pdf->setDefaultFont('Arial');

$html2pdf->WriteHTML($content);

$file = "output.pdf";
$html2pdf->Output($file, "F"); ?>

Basically, I don't have the slightest clue why the PDF is those weird values and not CMYK 0 0 0 100%

Any help is appreciated.

1

There are 1 answers

0
mch On BEST ANSWER

You have a problem! Using HTML2PDF, there is no way of creating a true CMYK document, which is required for your purpose. Color conversion will never achieve the (subjective) result you wish for and always mix 70% cyan, 40% red or something like this.

I would instead let the print department take care of automating / integrating the data into their print product, or if that is not possible write a script for Photoshop which creates a true CMYK document and adds layers with text and images to it.

Or as a third option, maybe it's possible to submit the content of the document without any border, and let the printers add a solid 100%-black border.

The reasons "why" this is so difficult are quite complex (additive vs. subtractive color, color spaces, practical considerations like "solid black spots look bad in raster images" etc.) and you can spend some turns at any university dealing with them. A lucrative field by the way if you find a perfect solution.