【问题标题】:Image not found when print document using jquery PrintThis使用 jquery PrintThis 打印文档时找不到图像
【发布时间】:2019-02-18 13:24:25
【问题描述】:

我正在使用 jqueryThis 插件打印网页。

我们要打印图像和文本,但是当我们点击打印按钮时,一切都很好,但在打印页面上仍然找不到图像。

我该如何解决这个问题?

<?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");?>

【问题讨论】:

  • 我认为堆栈溢出无法回答我
  • A.您是否尝试过debug: true 并检查了 printThis iframe 以查看是否有任何问题? B. 为图片尝试一个完全限定的 url

标签: jquery image printthis


【解决方案1】:

您应该在标签中添加完整的 url 例如http://domain/path/image.jpg

【讨论】:

    【解决方案2】:

    尝试等待片刻(例如 500 毫秒或 2000 毫秒)直到图像可以加载,使用:

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

    作为调用 printThis() 时的选项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-03
      • 1970-01-01
      • 1970-01-01
      • 2013-04-11
      相关资源
      最近更新 更多