使用ngx-print进行图像打印时出现问题 [英] Problem with image printing using ngx-print

查看:164
本文介绍了使用ngx-print进行图像打印时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法使用ngx-print打印图像.我不确定在这里我做错了什么.

Image is not getting printed with ngx-print. I am not sure what am I doing wrong here.

HTML

<button  type="button" printTitle="PrintVoucher" [useExistingCss]="true" 
                                        printSectionId="printVoucher" ngxPrint>
                                        Print </button>


<div row id="printVoucher" >
 <img  src="assets/images/logo.png">
</div>

但是图像在屏幕上可见,但在打印预览部分中不可见.

However the image is visible on the screen , but not visible in the print preview section.

推荐答案

您必须使用绝对路径,而不是相对路径

you have to use absolute path , Not relative path

例如,您的路径应为

" http://localhost:3000/assets/images/print-logo. png " 不是"print-logo.png"

"http://localhost:3000/assets/images/print-logo.png" not "print-logo.png"

要了解相对路径和绝对路径之间的区别,请检查此链接

例如,获取您当前的基本网址(" http://localhost:3000 ),您可以使用

to get your current base Url for example ("http://localhost:3000") you can use

让x = window.location.origin;

let x = window.location.origin;

这篇关于使用ngx-print进行图像打印时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆