doushou7169 2016-02-19 04:22
浏览 53
已采纳

将列表视图数据导出到Pdf

I am using Clist View to show data such list top post on facebook. Now there is a download option . I want to download Clist view data in pdf format . I search on google but i don't find and best example. What should i do to download data of clist view in pdf format.

List view widget:

$this->widget('zii.widgets.CListView', array(
                            'dataProvider' => $data_top_posts,
                            'id' => 'tbl-top-posts',
                            'itemView' => '_top_posts',
                            'template' => '{items}',
                            'beforeAjaxUpdate' => 'js:function(id, data){
                                    $("#" + id + " .items span.empty").html("Loading... Please wait.");
                                }',
                            'afterAjaxUpdate' => 'js:function(){
                                      setProgressBar("#tbl-top-posts");
                                      }',
                            'viewData' => array(
                                'id' => 'tbl-top-posts',),
                        ));
  • 写回答

1条回答 默认 最新

  • dttphb59319 2016-02-19 06:37
    关注

    There is no build-in function for such thing. But you can make that:

    1. Use HTML template to print out your view and than pass that content to TCPDF

    Example

    $pdf->AddPage();
    
    $html = $this->renderPartial('view', ['params'], true);
    
    // output the HTML content
    $pdf->writeHTML($html, true, 0, true, 0);
    $pdf->lastPage();
    $pdf->Output('example_021.pdf', 'I');
    
    1. Make image from current view and pass that image to TCPDF.

    Example

    html2canvas(document.getElementById('area')).then(function(canvas) {
        var data = canvas.toDataURL();
    
        $.ajax({
            url: 'savePDF.php',
            type: 'post',
            data: {imageSrc: data}
        });
    });
    

    You can use any other HTML to PDF tool, not only TCPDF.


    Resources:
    TCPDF, DomPDF
    Html2Canvas

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的