使用CodeIgniter生成PDF [英] Generating a PDF using CodeIgniter

查看:336
本文介绍了使用CodeIgniter生成PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 dompdf 从即时创建的html文件中创建一个pdf文件它的唯一目的是作为pdf生成器的输入,但我有麻烦这样做,我实现了代码在这个线程和一切工作正常(我可以输出一个简单的pdf)然而,当我尝试给它一个更具体的URL我得到这个错误:

I am using dompdf to create a pdf file out of an html file that gets created on-the-fly for the sole purpose of it serving as input for the pdf generator, however I am having trouble doing this, I implemented the code in this thread and everything works fine (I could output a simple pdf) however when I try to give it a more specific url I get this error:


遇到错误
加载请求的文件

An Error Was Encountered Unable to load the requested file

问题:

function printPDF(){

            //write_file() usa un helper (file)
            $this->load->library('table');
            $this->load->plugin('to_pdf');
             // page info here, db calls, etc.
             $query = $this->db->get('producto');
             $data['table'] = $this->table->generate($query);
             $path_url = base_url().'print/existencias.html';
             write_file($path_url, $data['table']);
             $html = $this->load->view($path_url, 'consulta', true);
             pdf_create($html, 'consulta');
        }


推荐答案

a pdf。
//创建控制器例如:

you should use tcpdf to create a pdf. //create controller for example :

public function create_pdf() 
    {
     $this->load->library("Pdf");
     $data['results'] = // your data
     $this->load->view('pdfview',$data);

    }


//pdfview is the page having tcpdf code and your pdf code.

这篇关于使用CodeIgniter生成PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆