设为首页 收藏本站
查看: 895|回复: 0

[经验分享] odoo(open erp) wkhtmltox打印不显示中文

[复制链接]

尚未签到

发表于 2017-11-19 21:07:53 | 显示全部楼层 |阅读模式
  wkhtmltox 是一个开源的将网页内容转换成PDF的软件包,常嵌套在网页页面里边做打印功能。
  以微软雅黑字体为例(其他的宋体、黑体等点阵字体都一样的),我们的雅黑字体文件是:Yahei.ttf(放在自己的主目录下)(在widows目录的Fonts目录下找需要的字体)
由于我是双系统,我直接从Win7中复制了 msyh.ttf和msyhbd.ttf 到Ubuntu下;
  windows系统,字体文件的目录一般在:C:\Windows\Fonts



1在/usr/share/fonts/下新建文件夹 如:winFonts目录,准备把从windows下拷贝过来的字体都放在这个目录里,这里就是把雅黑字体Yahei.ttf 放进来
sudo mkdir -p /usr/share/fonts/winFonts


2然后将字体文件拷贝到此文件夹下
sudo cp /home/username(用户名)/fonts/Yahei.ttf /usr/share/fonts/winFonts/


3然后,改变权限:
sudo chmod 644 /usr/share/fonts/winFonts/Yahei.ttf

(改成755也没问题的,但起码要444,修改雅黑字体文件的权限为644,即当前用户读写,当前组用户只读,其他用户只读)


4开始安装:




root@hellojesson:/usr/share/fonts/winFonts# chown root msyh*
root@hellojesson:/usr/share/fonts/winFonts# ls -l
total 35524
-rwxrwxr-x 1 root root 21767952 Oct 21 04:53 msyh.ttf
-rwxrwxr-x 1 root root 14602860 Oct 21 04:52 msyhbd.ttf
root@hellojesson:/usr/share/fonts/winFonts#
root@hellojesson:/usr/share/fonts/winFonts#
root@hellojesson:/usr/share/fonts/winFonts#
root@hellojesson:/usr/share/fonts/winFonts#
root@hellojesson:/usr/share/fonts/winFonts# mkfontscale
root@hellojesson:/usr/share/fonts/winFonts# mkfontdir
root@hellojesson:/usr/share/fonts/winFonts# ls
fonts.dir  fonts.scale    msyh.ttf  msyhbd.ttf
root@hellojesson:/usr/share/fonts/winFonts# fc-cache -fv
/usr/share/fonts: caching, new cache contents: 0 fonts, 4 dirs
/usr/share/fonts/X11: caching, new cache contents: 0 fonts, 4 dirs
/usr/share/fonts/X11/75dpi: caching, new cache contents: 358 fonts, 0 dirs
/usr/share/fonts/X11/encodings: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/X11/encodings/large: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/X11/misc: caching, new cache contents: 59 fonts, 0 dirs
/usr/share/fonts/X11/util: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/truetype: caching, new cache contents: 0 fonts, 2 dirs
/usr/share/fonts/truetype/dejavu: caching, new cache contents: 6 fonts, 0 dirs
/usr/share/fonts/truetype/liberation: caching, new cache contents: 16 fonts, 0 dirs
/usr/share/fonts/type1: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/type1/gsfonts: caching, new cache contents: 35 fonts, 0 dirs
/usr/share/fonts/winFonts: caching, new cache contents: 2 fonts, 0 dirs
/usr/X11R6/lib/X11/fonts: skipping, no such directory
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/root/.local/share/fonts: skipping, no such directory
/root/.fonts: skipping, no such directory
/usr/share/fonts: caching, new cache contents: 0 fonts, 4 dirs
/usr/X11R6/lib/X11/fonts: skipping, no such directory
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/root/.local/share/fonts: skipping, no such directory
/root/.fonts: skipping, no such directory
/var/cache/fontconfig: cleaning cache directory
/root/.cache/fontconfig: not cleaning non-existent cache directory
/root/.fontconfig: not cleaning non-existent cache directory
fc-cache: succeeded 


cd /usr/share/fonts/winFonts/
sudo mkfontscale (创建雅黑字体的fonts.scale文件,它用来控制字体旋转缩放)
sudo mkfontdir (创建雅黑字体的fonts.dir文件,它用来控制字体粗斜体产生)
sudo fc-cache -fv (建立字体缓存信息,也就是让系统认识认识雅黑)



5 尝试打印相关网页页面:终端命令行执行

wkhtmltopdf https://www.baidu.com/ baidu.pdf

wkhtmltopdf https://www.taobao.com/ taobao.pdf





参考:

http://huqiji.iteye.com/blog/2278225

http://blog.csdn.net/shenshen123jun/article/details/17334857

http://blog.csdn.net/vmboys/article/details/54581369

http://www.laozuo.org/9998.html

http://www.cnblogs.com/kfx2007/p/5926467.html

http://wiki.ubuntu.org.cn/%E5%AD%97%E4%BD%93

http://blog.163.com/bjcclzw@126/blog/static/129968414201281124457883/

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-408663-1-1.html 上篇帖子: Ubuntu下基于Anaconda的Tensorflow安装 下篇帖子: ubuntu在vmware下使用问题
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表