TCPDF Printer Registration Icons

I have a PHP script that makes a PDF from dynamic data. I need to put printer labels on the page I was trying to achieve like this:

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 label (in the middle of the vertex) the way I want. (looks like the standard license plate that Acrobat uses) But it doesn't draw the outer circle on others. See example

Any ideas?

+3


source to share


1 answer


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 license plate are white. So, for subsequent labels, the ellipse is drawn with white lines and white fill.



If you explicitly set the linestyle parameter on the first ellipse, it will draw an outer circle for all of your elevations.

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

      

+1


source







All Articles