doujie7346 2014-08-18 11:33
浏览 110
已采纳

使用dompdf和CodeIgniter生成pdf文件

I have a problem with generation pdf using CodeIgniter and dompdf, My code is:

public function generateTitlePage($name = '', $surname='', $number='', $village='')
{
    $this->load->library('dompdf_gen');
    $dompdf = new DOMPDF();
    $html = <<<HTML
        <html>
        <body>
            <h1>Hello:$name</h1><br />
            <h1>Hello:$surname</h1><br />
            <h1>Hello:$number</h1><br />
            <h1>Hello:$village</h1>
        </body>
        </html>
  HTML;
    $dompdf->load_html($html);
    $dompdf->render();
    $dompdf->stream("welcome.pdf");
}

The resultat for this function is

Hello: Name Surname number village
Hello:
Hello:
Hello:

But I need to separate this:

Hello:Name
Hello:Surname
Hello:number
Hello:village

Help me please. The function is called:

 <a href="<?=base_url()."dosar/generateTitlePage($d[name]$d[surname]$d[number]$d[village])" ?>" class="btn btn-primary btn-sm marg-top-10">Generate</a>
  • 写回答

1条回答 默认 最新

  • douya1061 2014-08-18 11:58
    关注

    The way you are generating your url is not correct you need to understand the routing first like

    example.com/class/function/id/
    
    • example.com this is your domain
    • class this your controller name
    • function this your function name which reside in above mentioned controller
    • id this will be your 1st parameter which will be to your above mentioned function and same as you can pass as many parameters like
    example.com/class/function/parameter1/parameter2/parameter3/
    

    for your pdf url you can write your anchor as below

    <a href="<?=base_url().'dosar/generateTitlePage/'. $d[name] .'/'. $d[surname] .'/'. $d[number] .'/'. $d[village])' ?>" class="btn btn-primary btn-sm marg-top-10">Generate</a>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?