首页 技术 正文
技术 2022年11月19日
0 收藏 652 点赞 2,374 浏览 1979 个字

salesforce默认的pdf页面只能设置Arial Unicode MS字体,而该字体默认的中文是日本字符,目前看来没办法设置成标准的中文字符,导致一些字看起来是不对的。如下图:(将确骨写)

salesforce 替代默认生成pdf页面方式

这样显然是不合适的,所以考虑替代VF的标准的方式。

1. 页面加载的时候使用window.print();直接打印页面,但这种方式很难加页码页首页尾。

2. 使用pdfmake js包来生成pdf, 基本可以满足需求。

1)页首

 header: function() {
return [ {
image: 'sampleImage.jpg',
width: 60,
right: 20,
absolutePosition: {x: 3, y: 3},
alignment: 'left',
style:'myImage'
},
{
canvas: [
{ type: 'line', x1: 20, y1: 35, x2: 595-20, y2: 35, lineWidth: 0.5 }
] } ];
}

salesforce 替代默认生成pdf页面方式

2)页尾

footer: function(pagenumber, pagecount) {
return [
{
canvas: [
{ type: 'line', x1: 20, y1: 0, x2: 595-20, y2: 0, lineWidth: 0.5 }
] },{
//margin: [40, 0],
text: pagenumber + ' of ' + pagecount,
alignment : 'center',
margin:[5,10,5,10]
},
{
text: 'text 1',
absolutePosition: {x:450, y:10}
}];
}

salesforce 替代默认生成pdf页面方式

3)正文

content: [
{ text: '标题', fontSize: 20, bold: false, alignment: 'center', style: ['lineSpacing', 'headingColor'] },
{ text: '编号:xxxxxxxxx', fontSize: 13, bold: false, alignment: 'right',margin : [ 0,40,0,40 ], style: ['lineSpacing', 'headingColor'] },
{ text: '甲方:123', fontSize: 13, bold: false, alignment: 'left', margin : [ 0,0,0,0 ], style: ['lineSpacing', 'headingColor'] },
{ text: '乙方:456', fontSize: 13, bold: false, alignment: 'left', margin : [ 0,0,0,20 ],style: ['lineSpacing', 'headingColor'] },
{
text: '副标题',
style: 'header',
alignment: 'center'
},
{
text: [
'\u200B\u200B\u200B\u200B\u200B\u200B\u200B《权力的游戏》第七季第5集“东海望”中,琼恩雪诺终于摸到了龙,这也预示着预言正在一步步成真,雪诺在驯龙高手的路上愈发走远,除了持续高能的剧情,剧外《权力的游戏》第七季的收视率也继续勇攀高峰,第五集创造了剧集开播七季以来最高的纪录。\n' ],
style: 'header',
bold: false
}, '一、场地与服务',
{
// for numbered lists set the ol key
ol: [
'《权力的游戏》第七季第5集“东海望”中,琼恩雪诺终于摸到了龙,这也预示着预言正在一步步成真,雪诺在驯龙高手的路上愈发走远,除了持续高能的剧情,剧外《权力的游戏》第七季的收视率也继续勇攀高峰,第五集创造了剧集开播七季以来最高的纪录。',
'《权力的游戏》第七季第5集“东海望”中,琼恩雪诺终于摸到了龙,这也预示着预言正在一步步成真,雪诺在驯龙高手的路上愈发走远,除了持续高能的剧情,剧外《权力的游戏》第七季的收视率也继续勇攀高峰,第五集创造了剧集开播七季以来最高的纪录。'
],
margin : [ 20,0,0,0 ]
}
,
{
table: {
headerRows: 1,
widths: [ '*', 'auto', 100, '*' ], body: [
[ 'First', 'Second', 'Third', 'The last one' ],
[ 'Value 1', 'Value 2', 'Value 3', 'Value 4' ],
[ { text: 'Bold value', bold: true }, 'Val 2', 'Val 3', 'Val 4' ]
]
}
}
]

salesforce 替代默认生成pdf页面方式

4)水印

watermark: {text: '仅供参考', color: 'blue', opacity: 0.3, bold: true, italics: false}

salesforce 替代默认生成pdf页面方式

可以在 http://pdfmake.org/playground.html 页面上进行测试。

如有需要相关资源,请发邮件联系我: chenxi365@qq.com

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,071
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,549
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,397
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,174
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,809
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,889