Image not found when print document using jquery PrintThis

1.6k views Asked by At

I'm print a web page using the jqueryThis plugin.

We are going to print the image and text, but when we are click print button, everything is fine, but still the image is not found on the print page.

How can I solve this problem?

enter image description here

<?php include("header.php");?>
<br /><br /> 
<li><a href="" onClick="return print_student()" >Print</a></li>
<div class="container " id="print_this" style=" color:black; ">
    <div class="container">
        <img src='images/as.jpg' width='50' height='50' />
    </div> 
    <div class="container">Mohsin Mushtaq</div> 
</div>
<script type="text/javascript">
function print_student(){
    $('#print_this').printThis({
        debug: false,
        printContainer:false,
        importCSS: true,
        loadCSS: "http://localhost/erp/css/bootstrap.min.css", 
        canvas: true, 
        base: true,            
        formValues: true,          
    });
    return false;
}
</script>
<?php include("footer.php");?>
2

There are 2 answers

0
Hillary Gabriel On BEST ANSWER

You should add full url within the tag example http://domain/path/image.jpg

0
Hicham O'Sfh On

try waiting a moment (500ms or 2000ms for example) until the image can load, using :

 $('#divToPrint').printThis({
        printDelay: 2000, // waiting 2 secondes
        importCSS: true,
        importStyle: true,
        loadCSS: true,
        canvas: true
    });

as option while calling printThis().