简体   繁体   中英

add content generated by javascript into pdf using dompdf

i am generating event calendar using full calendar java script library. i want to convert this calendar view into PDF. i am using codeigniter framework. and for PDF conversion using dompdf library.

$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();
    }    

view file

<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>            

why dont you use HTML to PDF. here is the to download it. http://html2pdf.fr/en/default

Its pretty simple you just need to put your

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

tag inside the page tag(this tag is going to use in this HTML2PDF).

Even standard CSS also work with HTML2PDF.

我不确定,但是尝试设置此选项:

$dompdf->set_option( 'isJavascriptEnabled' , true );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM