问题描述
我正在使用 CouchCMS 和 pfdmake。
我有一个使用通过 couchcms 生成的自定义路由的列表视图。
<cms:pages masterpage="data.PHP" paginate="1" limit="50" orderby='publish_date' custom_field="status_fifty!='No'" show_future_entries='1' >
<!-- List generation logic here -->
</cms:pages>
$("button#pdf").click(function() {
$.ajax({
type: "GET",url: "<cms:show k_site_link />pdf-generate-ajax.PHP",data: {
id: $(this).attr("data-id")
},success: function(data){
// alert(dd);
var blob = new Blob([data]);
window.open(URL.createObjectURL(blob));
},error: function (XMLHttpRequest,textStatus,errorThrown)
{
alert('Error occurred while opening fax template'
+ getAjaxErrorString(textStatus,errorThrown));
}
// success: function(data){
// var blob = new Blob([data]);
// window.open(URL.createObjectURL(blob));
// }
});
})
ajax 运行成功,但 pdf 为空白。
async function generatePDF() {
var str = "Calling,Street View.";
var res = str.toupperCase();
var imageWidth = 476.224;
// var imageHeight = 210.4725;
var imageHeight= 280.63;
var dd = {
pageSize: 'A4',pageMargins: [ 40,40,40 ],footer: function(page) {
{
return {
columns: [
{
text: '* KINDLY NOTE BUILDING NUMBER AND UNIT RANGES CONFIRMED BY ' + res,style: 'footerComment',alignment: 'center'
}
]
};
}
},content: [
{
table: {
widths: ['*'],body: [
[
{
style: 'header',text: 'Still Water Apartments2'
}
],[
{
style: 'address',text: '5901 Leopard St; Corpus Christi; TX 78409,210-248-9443',}
],[
''
],[
{
image: await this.getBase64ImageFromURL(
"http://localhost/CTO/USGeoTagging/couch/uploads/attachments/ab9422df6cb6f0f5d215e89c916d7219.png"
),width: imageWidth,height: imageHeight,alignment: 'center'
}
],[
{
style: 'mapfrom',text: 'Map From:'
}
],[
{
style: 'mapfromUrl',text: 'https://www.gxcpl.com/asdfasd',link: 'https://www.gxcpl.com/asdfasd'
}
],[
{
table: {
widths: ['45%','55%'],body: [
[
'APARTMENT DETAILS','BUILDING NUMBER & UNIT RANGES *'
]
]
},layout: 'noBorders'
}
],[
{
table: {
widths: ['20%','25%','50%'],body: [
[
{
style: 'contentTextBold',text:'DELIVERY PARKING\nLEASING OFFICE\nMAIL ROOM\nDIRECTIONALITY\nNO. OF ENTRANCES\nACCESS TYPE\nGATE\nGATE TYPE\nGATE (L)\n\nLOADING DOCK'
},{
style: 'contentTextnormal',text:': Yes,Building wise\n: Yes\n: No\n: 0\n: 1\n: Blank\n: No\n: Blank\n: Locked Gate,used in case of Emergency\n: No'
},{
table: {
body: [
[
{
text: 'Building #',style: 'contentTextBold'
},{
text: 'Unit #',style: 'contentTextBold'
}
],[
{
text: 'BLDG #1',style: 'contentTextnormal'
},{
text: '1-10',style: 'contentTextnormal'
}
]
],alignment: 'center'
},}
]
]
},layout: 'noBorders'
}
]
]
},layout: 'noBorders'
}
],styles: {
header: {
fontSize: 16,bold: 'true'
},address: {
fontSize: 10,mapfrom: {
fontSize: 6,mapfromUrl: {
fontSize: 6,color: 'blue'
},contentTextBold: {
fontSize: 9,bold: true
},contentTextnormal: {
fontSize: 9
},footerComment: {
fontSize: 5
}
},defaultStyle: {
alignment: 'justify'
}
}
pdfMake.createPdf(dd).open();
}
如何才能显示 pdf 内容? 该 blob 已生成并显示在新选项卡中,但它是空白的。
问候
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)