dongxun3777 2019-05-07 07:16
浏览 109

如何修复“TCPDF错误:图像文件丢失或不正确”

I use tcpdf with php to generate a pdf file. It can display text correctly. However, when I tried to display an image, I got this error message: "TCPDF error: Missing or incorrect image file: [URL]". [URL] is the link of the image I wanted to display. When I tried to open [URL] in a browser, the image could show up normally.

I have tried to fix this by using CURL, but it made the program unresponsive. I have also tried to use @getimagesize without success.

$rep = new FrontReport(_("ASSET REGISTRATION VIEW"), "Asset Registration View", user_pagesize(), 9, $orientation);

    $rep->SetHeaderType('HeaderAssetRegView');
    $rep->Font();
    $rep->Info($params, $cols, null, $aligns);
    $rep->NewPage();

    $result = get_asset_registration_details($asset_type_name, $year, $month, $emp_id);
    $rep->row = 710;
    while ($myrow2=db_fetch($result)) {
        $asset_type_name_detail = $myrow2['asset_type_name'];
        $asset_id_detail = $myrow2['asset_id'];
        $reg_date_detail = $myrow2['trx_date'];
        $emp_id_detail = $myrow2['emp_id'];
        $emp_name_detail = $myrow2['employee_name'];
        $project_code_detail = $myrow2['project_code'];
        $img_root = 'https://myserver.com/ci-rest/uploads/';
        $img_detail = $myrow2["file_path"];
        $img_link = $img_root . $img_detail;

        $no++;
        $rep->TextCol(0, 1, $no, -2);
        $rep->TextCol(1, 1, 'Asset Type Name', -2);
        $rep->TextColLines(2, 1, ': ' . $asset_type_name_detail, -2);
        $rep->TextCol(1, 2, 'Asset ID', -2);
        $rep->TextColLines(2, 2, ': ' . $asset_id_detail, -2);
        $rep->TextCol(1, 3, 'Reg Date', -2);
        $rep->TextColLines(2, 3, ': ' . $reg_date_detail, -2);
        $rep->TextCol(1, 4, 'Employee ID', -2);
        $rep->TextColLines(2, 4, ': ' . $emp_id_detail, -2);
        $rep->TextCol(1, 5, 'Employee Name', -2);
        $rep->TextColLines(2, 5, ': ' . $emp_name_detail, -2);
        $rep->TextCol(1, 6, 'Project Code', -2);
        $rep->TextColLines(2, 6, ': ' . $project_code_detail, -2);

        $rep->AddImage($img_link, 300, $rep->row, 80, 80);

        $rep->NewLine();
    }

    $rep->End();

I expect the output will show images, not an error message.

Any help would be very appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)
    • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。