我正在使用一个名为pdfmake的jquery插件。我能够创建我的要求的整个pdf,但当我请求浏览器打开pdf文件时,问题就出现了。浏览器没有打开pdf,而是说popup被阻止了。单击并选择允许此站点的弹出窗口后,它将打开pdf。我的剧本:
<script>
var docDefinition = {
content: [
{ text: 'BirdVision Invoice', style: 'header' },
{ text: 'Bill To', style: 'anotherStyle' },
{ text: '<?php echo $row->client_name; ?>', margin: [ 5, 0, 0, 0 ] },
{ text: '[Company Name]', margin: [ 5, 0, 0, 0 ] },
{ text: '[Street]', margin: [ 5, 0, 0, 0 ] },
{ text: '[POST/ORT]', margin: [ 5, 0, 0, 0 ] },
{ text: '[Phone/Email]', margin: [ 5, 0, 0, 0 ] },
{ text: 'Bill For', style: [ 'header', 'anotherStyle' ] },
{ text: 'Total :', alignment: 'right', margin: [ 5, 50, 100, 10], fontSize: 22, bold: true},
{ text: 'If you have any questions feel free to contact us!! ', alignment: 'center', margin: [ 0, 500, 0, 0]},
],
styles: {
header: {
fontSize: 22,
bold: true
},
anotherStyle: {
margin: [ 5, 50, 10, 10 ],
fontSize: 15,
bold: true,
italic: true,
alignment: 'left',
}
}
};
pdfMake.createPdf(docDefinition).open();
</script>
答案 0 :(得分:0)
我明白了,对不起这个问题的含糊之处。由于我的系统生成自动请求,浏览器阻止打开pdf。所以,我创建了一个按钮,让人工互动如下:
<button class = "btn btn-default" onclick="pdfMake.createPdf(docDefinition).open()"> Open PDF </button>
现在没有来自任何浏览器的弹出窗口阻止消息。