Problem with image printing using ngx-print

倖福魔咒の 提交于 2019-12-11 05:48:22

问题


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.


回答1:


you have to use absolute path , Not relative path

ie your path should be for example

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

to know the difference between relative and absolute path check this link

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

let x = window.location.origin;



来源:https://stackoverflow.com/questions/56694343/problem-with-image-printing-using-ngx-print

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!