dpw50696 2013-01-26 14:16
浏览 80
已采纳

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?

  • 写回答

1条回答 默认 最新

  • duan1982453 2013-04-21 08:49
    关注

    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));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度