我正在使用 pdfmake ,一个很好的 pdf 打印库,用于在我的 angularjs SPA 中生成 pdf。当我只使用文本时一切正常。 pdf 正确显示所有文本。但是当我尝试显示图像时它对我不起作用。没有错误,没有空的 pdf,只是什么也没有发生。也没有404。
这是我现在正在尝试的代码,
var dd = {
content: [
{
image: 'picture13438908025659.jpg'
},
{
text: 'Patient\'s Detail', fontSize: 18, bold: true
},
{
columns: [
{
text: 'Patient\'s ID: ' + $scope.prescription.Patient[0].id, bold: false
},
{
text: 'Name: ' + $scope.prescription.Patient[0].name, bold: false
},
{
text: 'Age: ' + $scope.prescription.Patient[0].age, bold: false
},
{
text: 'Contact: ' + $scope.prescription.Patient[0].contact, bold: false
}
]
},
{
text: 'Address: ' + $scope.prescription.Patient[0].address, bold: false
}
]
}
最佳答案
很简单,
1) 将您的图像转换为 base64 here
2) 复制你的 base64 代码并替换成 ,
image : 'base64', // use your base64 instead image.jpg
3) 完成。此方法是如果您的图片无法通过链接工作,则使用 base64 代替
关于javascript - 使用pdfmake在angularjs中生成pdf时图像不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28647253/