Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TCPDF drawing printer registration marks

Tags:

php

tcpdf

I have a PHP script that makes a pdf from dynamic data. I need to put printer marks on the page that I tried to achieve this way:

function drawPrinterMarks($obj, $pageWidth, $pageHeight){
    $registrationMarks=array(
        array($pageWidth/2, 5),
        array($pageWidth/2, $pageHeight-5),
        array(5, $pageHeight/2),
        array($pageWidth-5, $pageHeight/2)
    );

    $regLineStyle=array('width'=>0.07, 'color'=>array(100,100,100,100));
    $whiteLineStyle=array('width'=>0.07, 'color'=>array(0,0,0,0));

    foreach($registrationMarks as $rM){
        $obj->Ellipse($rM[0], $rM[1], 2, 0, 0, 0, 360, '', '', array(0,0,0,0));
        $obj->Ellipse($rM[0], $rM[1], 1, 0, 0, 0, 360, 'F', '', array(100,100,100,100));
        $obj->Line($rM[0]-2.5, $rM[1], $rM[0]+2.5, $rM[1], $regLineStyle);
        $obj->Line($rM[0], $rM[1]-2.5, $rM[0], $rM[1]+2.5, $regLineStyle);
        $obj->Line($rM[0]-1, $rM[1], $rM[0]+1,$rM[1], $whiteLineStyle);
        $obj->Line($rM[0], $rM[1]-1, $rM[0], $rM[1]+1, $whiteLineStyle);
    }
}

It draws the first mark (at the middle of the top) the way I want. (looks like the standard registration mark that Acrobat uses) But it doesn't draw the outer circle at the others. See the example

Any ideas?

like image 745
petIQe Avatar asked Aug 09 '26 19:08

petIQe


1 Answers

Here, you tell TCPDF to draw an ellipse with the current line style:

$obj->Ellipse($rM[0], $rM[1], 2, 0, 0, 0, 360, '', '', array(0,0,0,0));

But the last lines drawn for each registration mark are white. So for the subsequent marks the ellipse is drawn with white lines and white fill.

If you explicitly set the linestyle parameter on the first ellipse, it'll draw the outside circle for all your marks.

$obj->Ellipse($rM[0], $rM[1], 2, 0, 0, 0, 360, '', $regLineStyle, array(0,0,0,0));
like image 159
EPB Avatar answered Aug 12 '26 11:08

EPB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!