我试图在新窗口中打开pdf文件并在打开窗口后打开打印对话框,但是打开打印对话框的print()方法被跨域阻止,因为conslole向我返回此错误DOMException :阻止了来源为“ http://localhost:4200”的框架访问跨域框架。我该如何解决这个问题?
ip_list = []
server_list = []
while True:
try:
server = (input('> '))
if server == 'q':
break
ip_addr = socket.gethostbyname(server)
ip_list.append(ip_addr)
server_list.append(server)
except socket.gaierror:
print(server, 'can\'t find server/ip', '\n')
print(ip_list)
print(server_list)
print() {
var myWindow = window.open('https://mediasb.shiftinc.com/booking_pdfs/QALNHF.pdf', 'Booking', 'width=600,height=600');
myWindow.print();
myWindow.focus();
}
答案 0 :(得分:1)
以角度:-
this.http.get('https://mediasb.shiftinc.com/booking_pdfs/QALNHF.pdf', {responseType: 'blob'}).subscribe((res) => {
let url = window.URL.createObjectURL(res);
var myWindow = window.open(url, 'Booking', 'width=600,height=600');
myWindow.print();
myWindow.focus();
});