[英]Export HTML DataTable in PDF
I have a simple HTML table with a dropdown filter, i want to export this table in PDF, and when i use the filter that changes the pdf too. 我有一个带有下拉过滤器的简单HTML表,我想将此表导出为PDF,并且当我使用也会更改pdf的过滤器时。 If someone can help me that will be good :)
如果有人可以帮助我,那会很好:)
Data table: https://jsfiddle.net/hk8mvyda/ 数据表: https : //jsfiddle.net/hk8mvyda/
<SCRIPT language="Javascript">
function filterText()
{
var rex = new RegExp($('#Position').val());
if(rex =="/All/"){clearFiltre()}else{
$('.content').hide();
$('.content').filter(function() {
return rex.test($(this).text());
}).show();
}
}
function clearFiltre()
{
$('.Position').val('');
$('.content').show();
}
</script>
PS: Sorry for my english PS:对不起,我的英语
The filter uses javascript. 过滤器使用javascript。 If you want to be able to render the html to a PDF it will need to be something PHP can access.
如果您希望能够将html呈现为PDF,则需要PHP可以访问。 Since javascript does the change on the clients browser, PHP can not access it unless you use a Http request to get the html.
由于javascript在客户端浏览器上进行了更改,因此除非使用Http请求获取html,否则PHP无法访问它。
Use file_get_contents(url)
to query the url and allow for a url variable to auto select the content of the dropdown. 使用
file_get_contents(url)
来查询url,并允许使用url变量来自动选择下拉菜单的内容。 This way PHP can obtain the rendered HTML after the javascript has done what it needs to do . 这样,PHP可以在javascript完成所需的操作后获取呈现的HTML。
http://php.net/manual/en/function.file-get-contents.php http://php.net/manual/en/function.file-get-contents.php
Check this both jquery plugin example it maybehelpful to you 检查这两个jQuery插件示例,这可能对您有帮助
https://w3lessons.info/2015/07/13/export-html-table-to-excel-csv-json-pdf-png-using-jquery/ https://w3lessons.info/2015/07/13/export-html-table-to-excel-csv-json-pdf-png-using-jquery/
https://www.phpflow.com/php/export-html-table-data-to-excel-csv-png-and-pdf-using-jquery-plugin/ https://www.phpflow.com/php/export-html-table-data-to-excel-csv-png-and-pdf-using-jquery-plugin/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.