在篝火代码点火器中添加用于将表格打印到打印机的按钮


Add button to print table to printer in bonfire codeigniter

我是代码点火器和篝火的新手,对此我很不熟悉,但我想知道如何添加按钮将我的表格打印到打印机或pdf文件中。我尝试使用window.print(),它可以工作,但它没有加载css或表的样式。我知道我必须在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'),它根本不起作用,有人能帮我吗?

为此,您必须在Bonfire中的head中加载js,您可以添加您的js
路径:-public''themes''default''header.php

这是您需要添加js的文件。

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

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