I'm using wkhtml2pdf to generate pdf against HTML provided. In my HTML page I'm including moment.js and using it's functions to convert dates.
Dates are properly converted on html page but after wkhtml2pdf processing, chnaged date is not shown.
Call to wkhtml2pdf is as:
$html_in_string = $this->load->view('phr_print', $phr_print_response, true);
// Create PDF object.
$pdf = new WKPDF();
// Set PDF's HTML
$pdf->set_html($html_in_string);
// Convert HTML to PDF
$pdf->render();
// Output PDF. The file name is suggested to the browser.
$pdf->output(WKPDF::$PDF_EMBEDDED, 'phr_print.pdf');
Below script is inside phr_print.php file along with other code.
<script type="text/javascript">
$(document).ready(function(){
$(".format-date").each(function(el){
var timestamp = $(this).data('timestamp');
if( jQuery.trim(timestamp) != "" ){
timestamp = timestamp * 1000;
var format = $(this).data('format') ;
format = jQuery.trim(format)==""?"MM/DD/YYYY":format;
var datetime = moment( timestamp ).format( format );
$(this).html( datetime ) ;
}
});
});
</script>
moment.js version is 2.0.0 and wkhtmltopdf version is 0.9.9.
Any help in regard is highly appreciated.