在篝火codeigniter中添加按钮将打印表打印到打印机

时间:2016-08-08 02:51:59

标签: javascript php css printing

我是codeigniter和篝火的新手,我非常喜欢这个,但我想知道如何添加按钮将我的表打印到打印机或pdf文件。我尝试使用window.print(),但它没有加载css或table的样式。我知道我必须在javascript中加载css文件,然后我使用这段代码:

function printContent(id){
str=document.getElementById(id).innerHTML
newwin=window.open('','printwin','left=100,top=100,width=400,height=400')
newwin.document.write('<HTML>\n<HEAD>\n')
newwin.document.write('<TITLE>Print Page</TITLE>\n')
newwin.document.write('<script>\n')
newwin.document.write('function chkstate(){\n')
newwin.document.write('if(document.readyState=="complete"){\n')
newwin.document.write('window.close()\n')
newwin.document.write('}\n')
newwin.document.write('else{\n')
newwin.document.write('setTimeout("chkstate()",2000)\n')
newwin.document.write('}\n')
newwin.document.write('}\n')
newwin.document.write('function print_win(){\n')
newwin.document.write('window.print();\n')
newwin.document.write('chkstate();\n')
newwin.document.write('}\n')
newwin.document.write('<\/script>\n')
newwin.document.write('</HEAD>\n')
newwin.document.write('<BODY onload="print_win()">\n')
newwin.document.write(str)
newwin.document.write('</BODY>\n')
newwin.document.write('</HTML>\n')
newwin.document.close()
}

但是我不知道篝火存放在哪里我们必须包含他们的css文件,我尝试包括这个newwin.document.write('<?php echo Assets::css; ?>\n'),它根本不起作用,有人可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

为此你必须在篝火中加载你的js你可以添加你的js
路径:-public \主题\默认\的header.php

以下是您需要添加js的文件。

Assets::add_js('bootstrap.min.js','your_js_file');

如果您遇到任何问题,请告诉我。