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

标签 php fullcalendar dompdf

我正在使用完整的日历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/

相关文章:

php - 使用查询字符串有什么危险?

php - 如何仅删除页面的自动段落格式,而不是帖子(WordPress)

fullcalendar - 在全日历中调整天高度?

ruby-on-rails - 如何在 Ruby on Rails 应用程序中开始使用 fullcalendar-rails gem?

php - fopen(/vendor/dompdf/dompdf/lib/fonts/glyphicons-halflings-normal_c47afe5539ba1b2094563d54dce2def7.ufm) : failed to open stream: Permission denied

dompdf 字体系列问题

PHP fatal error : Class 'DOMPDF' not found on line 30

javascript - 在 $.ajax 中使用 "POST"方法传递数据时出现 500 Internal Server Error

php - 如何为新闻站点动态生成 "read more"链接

jquery - Ajax 帖子的成功部分在完整日历代码中不起作用