gpt4 book ai didi

php - 使用dompdf将javascript生成的内容添加到pdf中

转载 作者:行者123 更新时间:2023-12-02 04:46:11 24 4
gpt4 key购买 nike

我正在使用完整的日历Java脚本库生成事件日历。我想将此日历 View 转换为 PDF。我正在使用 codeigniter 框架。并使用 dompdf 库进行 PDF 转换。

$html = $this->load->view('pdf_html', $data,true);    
require_once("dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
if ($stream) {
$dompdf->stream($filename.".pdf");
} else {
return $dompdf->output();
}

查看文件

<script type="text/javascript">
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: '',
center: 'title'
},
editable: false,
selectable: false,
weekends: false,
month: <?php echo $selected_month; ?>
});
$(".fc-button-prev").css('display', 'none');
$(".fc-button-next").css('display', 'none');
$(".fc-button-today").css('display', 'none');
$(".fc-day-header").css('padding-top', '10px');
$(".fc-day-header").css('padding-bottom', '10px');
$(".fc-day-header").css('background-color', '#FFB848');
$(".fc-event-container").css('top', '10px');
$(".fc-event").css('border-radius', '4px !important');
$(".fc-event").css('margin-bottom', '3px');
$(".fc-event").css('border', '2px solid #ccc');


});
</script>
<div id='calendar' style="widyh:100%;background-color: #f5f5f5;margin-top:15px;margin-bottom:15px;"></div>

最佳答案

为什么不使用 HTML 转 PDF。这是下载它的方法。 http://html2pdf.fr/en/default

很简单,你只需要把你的

div id='calendar' style="widyh:100%;background-color: #f5f5f5;margin-top:15px;margin-bottom:15px;"></div>

page 内的标签标签(此标签将在此 HTML2PDF 中使用)。

即使是标准 CSS 也适用于 HTML2PDF。

关于php - 使用dompdf将javascript生成的内容添加到pdf中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23954291/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com