zoukankan      html  css  js  c++  java
  • suse种运行wkhtmltopdf

    项目中的suse,而且没有网,安装wkhtmltopdf就比较麻烦,于是就准备了2种方案。

    • 在阿里云镜像安装成suse的,准备好rpm包

      iZbp145axkc98giot5b448Z:~ # zypper install --download-only xorg-x11-fonts*
      Retrieving repository 'SLES12-SP5-0' metadata ...............................................................................................[done]
      Building repository 'SLES12-SP5-0' cache ....................................................................................................[done]
      Retrieving repository 'SLES12-SP5-Updates-0' metadata .......................................................................................[done]
      Building repository 'SLES12-SP5-Updates-0' cache ............................................................................................[done]
      Loading repository data...
      Reading installed packages...
      Resolving package dependencies...
      
      The following 7 NEW packages are going to be installed:
        fonts-config ft2demos libfontenc1 mkfontdir mkfontscale xorg-x11-fonts xorg-x11-fonts-core
      
      The following 2 recommended packages were automatically selected:
        mkfontdir mkfontscale
      
      7 new packages to install.
      Overall download size: 32.0 MiB. Already cached: 0 B. Download only.
      Continue? [y/n/...? shows all options] (y): y
      Retrieving package ft2demos-2.6.3-7.15.1.x86_64                                                               (1/7), 111.6 KiB (587.4 KiB unpacked)
      Retrieving: ft2demos-2.6.3-7.15.1.x86_64.rpm ...................................................................................[done (13.8 KiB/s)]
      Retrieving package libfontenc1-1.1.2-3.56.x86_64                                                              (2/7),  14.9 KiB ( 29.9 KiB unpacked)
      Retrieving: libfontenc1-1.1.2-3.56.x86_64.rpm ...............................................................................................[done]
      Retrieving package mkfontscale-1.1.1-3.65.x86_64                                                              (3/7),  29.4 KiB ( 62.1 KiB unpacked)
      Retrieving: mkfontscale-1.1.1-3.65.x86_64.rpm ...............................................................................................[done]
      Retrieving package mkfontdir-1.0.7-8.9.x86_64                                                                 (4/7),  13.2 KiB ( 19.8 KiB unpacked)
      Retrieving: mkfontdir-1.0.7-8.9.x86_64.rpm ..................................................................................................[done]
      Retrieving package fonts-config-20180430-6.8.1.noarch                                                         (5/7),  51.0 KiB (279.3 KiB unpacked)
      Retrieving: fonts-config-20180430-6.8.1.noarch.rpm ..........................................................................................[done]
      Retrieving package xorg-x11-fonts-core-7.6-29.45.noarch                                                       (6/7),   9.1 MiB ( 10.4 MiB unpacked)
      Retrieving: xorg-x11-fonts-core-7.6-29.45.noarch.rpm ............................................................................[done (1.2 MiB/s)]
      Retrieving package xorg-x11-fonts-7.6-29.45.noarch                                                            (7/7),  22.6 MiB ( 30.3 MiB unpacked)
      Retrieving: xorg-x11-fonts-7.6-29.45.noarch.rpm .............................................................................................[done]
      iZbp145axkc98giot5b448Z:~ # cd /var/cache/zypp/packages/SLES12-SP5-0/
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0 # ll
      total 8
      drwxr-xr-x 2 root root 4096 Aug 24 22:22 noarch
      drwxr-xr-x 2 root root 4096 Aug 24 22:22 x86_64
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0 # cd noarch
      iZbp145axkc98giot5b448Z:~ # cd /var/cache/zypp/packages/SLES12-SP5-0/
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0 # ll
      total 8
      drwxr-xr-x 2 root root 4096 Aug 24 22:22 noarch
      drwxr-xr-x 2 root root 4096 Aug 24 22:22 x86_64
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0 # cd noarch
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0/noarch # ll
      total 32556
      -rw-r--r-- 1 root root    52275 Aug 24 22:22 fonts-config-20180430-6.8.1.noarch.rpm
      -rw-r--r-- 1 root root 23749989 Aug 24 22:22 xorg-x11-fonts-7.6-29.45.noarch.rpm
      -rw-r--r-- 1 root root  9529396 Aug 24 22:22 xorg-x11-fonts-core-7.6-29.45.noarch.rpm
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0/noarch # cd ..
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0 # ll
      total 8
      drwxr-xr-x 2 root root 4096 Aug 24 22:22 noarch
      drwxr-xr-x 2 root root 4096 Aug 24 22:22 x86_64
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0 # cd x86_64/
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0/x86_64 # ll
      total 176
      -rw-r--r-- 1 root root 114315 Aug 24 22:22 ft2demos-2.6.3-7.15.1.x86_64.rpm
      -rw-r--r-- 1 root root  15277 Aug 24 22:22 libfontenc1-1.1.2-3.56.x86_64.rpm
      -rw-r--r-- 1 root root  13501 Aug 24 22:22 mkfontdir-1.0.7-8.9.x86_64.rpm
      -rw-r--r-- 1 root root  30074 Aug 24 22:22 mkfontscale-1.1.1-3.65.x86_64.rpm
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0/x86_64 # rpm -ivh ft2demos-2.6.3-7.15.1.x86_64.rpm
      Preparing...                          ################################# [100%]
      Updating / installing...
         1:ft2demos-2.6.3-7.15.1            ################################# [100%]
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0/x86_64 # rpm -ivh libfontenc1-1.1.2-3.56.x86_64.rpm
      Preparing...                          ################################# [100%]
      Updating / installing...
         1:libfontenc1-1.1.2-3.56           ################################# [100%]
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0/x86_64 # rpm -ivh mkfontscale-1.1.1-3.65.x86_64.rpm
      Preparing...                          ################################# [100%]
      Updating / installing...
         1:mkfontscale-1.1.1-3.65           ################################# [100%]
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0/x86_64 # rpm -ivh mkfontdir-1.0.7-8.9.x86_64.rpm
      Preparing...                          ################################# [100%]
      Updating / installing...
         1:mkfontdir-1.0.7-8.9              ################################# [100%]
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0/x86_64 # cd ..
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0 # ll
      total 8
      drwxr-xr-x 2 root root 4096 Aug 24 22:22 noarch
      drwxr-xr-x 2 root root 4096 Aug 24 22:22 x86_64
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0 # cd noarch/
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0/noarch # ll
      total 32556
      -rw-r--r-- 1 root root    52275 Aug 24 22:22 fonts-config-20180430-6.8.1.noarch.rpm
      -rw-r--r-- 1 root root 23749989 Aug 24 22:22 xorg-x11-fonts-7.6-29.45.noarch.rpm
      -rw-r--r-- 1 root root  9529396 Aug 24 22:22 xorg-x11-fonts-core-7.6-29.45.noarch.rpm
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0/noarch # rpm -ivh fonts-config-20180430-6.8.1.noarch.rpm
      Preparing...                          ################################# [100%]
      Updating / installing...
         1:fonts-config-20180430-6.8.1      ################################# [100%]
      Updating /etc/sysconfig/fonts-config...
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0/noarch # rpm -ivh xorg-x11-fonts-7.6-29.45.noarch.rpm
      error: Failed dependencies:
              xorg-x11-fonts-core is needed by xorg-x11-fonts-7.6-29.45.noarch
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0/noarch # rpm -ivh xorg-x11-fonts-core-7.6-29.45.noarch.rpm
      Preparing...                          ################################# [100%]
      Updating / installing...
         1:xorg-x11-fonts-core-7.6-29.45    ################################# [100%]
      iZbp145axkc98giot5b448Z:/var/cache/zypp/packages/SLES12-SP5-0/noarch # rpm -ivh xorg-x11-fonts-7.6-29.45.noarch.rpm
      Preparing...                          ################################# [100%]
      Updating / installing...
         1:xorg-x11-fonts-7.6-29.45         warning: /usr/share/fonts/truetype/fonts.dir saved as /usr/share/fonts/truetype/fonts.dir.rpmorig
      warning: /usr/share/fonts/truetype/fonts.scale saved as /usr/share/fonts/truetype/fonts.scale.rpmorig
      ################################# [100%]
      iZbp145axkc98giot5b448Z:~ # rpm -ivh wkhtmltox-0.12.6-1.opensuse.leap15.x86_64.rpm
      Preparing...                          ################################# [100%]
      Updating / installing...
         1:wkhtmltox-1:0.12.6-1.opensuse.lea################################# [100%]
      iZbp145axkc98giot5b448Z:~ # wkhtmltopdf
      wkhtmltopdf: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
      iZbp145axkc98giot5b448Z:~ # zypper install --download-only libopenssl*
      Loading repository data...
      Reading installed packages...
      'libopenssl1_0_0' providing 'libopenssl*' is already installed.
      No update candidate for 'libopenssl1_0_0-1.0.2p-3.14.1.x86_64'. The highest available version is already installed.
      Resolving package dependencies...
      
      The following 78 NEW packages are going to be installed:
        cryptconfig-32bit cups-libs-32bit device-mapper-32bit glibc-32bit krb5-32bit libHX28-32bit libacl1-32bit libargon2-1-32bit libattr1-32bit
        libaudit1-32bit libavahi-client3-32bit libavahi-common3-32bit libblkid1-32bit libcap2-32bit libcom_err2-32bit libcrack2-32bit
        libcryptmount0-32bit libcryptsetup12-32bit libdbus-1-3-32bit libdcerpc-binding0-32bit libdcerpc0-32bit libfam0-gamin-32bit libgcc_s1-32bit
        libgcrypt20-32bit libglib-2_0-0-32bit libgpg-error0-32bit libjson-c2-32bit libkeyutils1-32bit libldap-2_4-2-32bit libldb1-32bit liblzma5-32bit
        libmount1-32bit libndr-krb5pac0-32bit libndr-nbt0-32bit libndr-standard0-32bit libndr0-32bit libnetapi0-32bit libnscd1-32bit
        libopenssl-1_0_0-devel libopenssl-devel libopenssl1_0_0-32bit libopenssl1_0_0-hmac libopenssl1_0_0-hmac-32bit libopenssl1_1 libopenssl1_1-32bit
        libpcre1-32bit libpopt0-32bit libsamba-credentials0-32bit libsamba-errors0-32bit libsamba-hostconfig0-32bit libsamba-passdb0-32bit
        libsamba-util0-32bit libsamdb0-32bit libsasl2-3-32bit libseccomp2-32bit libselinux1-32bit libsepol1-32bit libsmbconf0-32bit libsmbldap2-32bit
        libstdc++6-32bit libsystemd0-32bit libtalloc2-32bit libtdb1-32bit libtevent-util0-32bit libtevent0-32bit libudev1-32bit libuuid1-32bit
        libverto1-32bit libwbclient0-32bit libxml2-2-32bit libz1-32bit opie-32bit pam-32bit pam_mount-32bit samba-client-32bit samba-libs-32bit
        systemd-32bit zlib-devel
      
      
      

      这样准备了差不多85个rpm包

    • 第二种就是做一个centos的容器,然后去执行

      [root@test ~]# cat Dockerfile
      FROM centos
      MAINTAINER wgr<wang.gr@topcheer.com>
      
      RUN yum -y install fontconfig
      RUN mkdir -p /usr/share/fonts/chinese
      COPY *.TT* /usr/share/fonts/chinese/
      RUN yum -y install ttmkfdir
      RUN fc-cache
      RUN yum -y install libssl*
      RUN yum install -y libpng15*
      RUN yum -y install xorg-x11-fonts-75dpi.noarch
      RUN yum -y install xorg-x11-fonts-Type1.noarch
      RUN yum  -y install libjpeg
      RUN yum -y install libXrender
      RUN yum -y install libXext
      RUN mkdir -p  /app/pdf
      RUN yum -y install openssl*
      ENV MYPATH /app/pdf
      WORKDIR $MYPATH
      COPY wkhtmltox-0.12.6-1.centos7.x86_64.rpm $MYPATH
      RUN rpm -ivh wkhtmltox-0.12.6-1.centos7.x86_64.rpm
      VOLUME ["/app/pdf"]
      
      
      EXPOSE 80
      CMD /bin/bash
      [root@test ~]#
      [root@test ~]# docker images
      REPOSITORY                                      TAG                 IMAGE ID            CREATED             SIZE
      wkhtmltopdf                                     v1.0                bcd7d3f4ed91        2 hours ago         794MB
      minio/minio                                     latest              cfa3d828d9da        11 days ago         61.9MB
      centos                                          latest              0d120b6ccaa8        13 days ago         215MB
      nacos/nacos-server                              latest              ef8e53226440        2 weeks ago         914MB
      qbanxiaoli/fastdfs                              latest              87fb9d2c4b8b        3 weeks ago         664MB
      influxdb                                        1.8.0               95750833bc56        2 months ago        304MB
      chronograf                                      1.8                 b507b55579c8        3 months ago        194MB
      nacos/nacos-mysql                               5.7                 72037eccf264        5 months ago        373MB
      grafana/grafana                                 6.5.2               7a40c3c56100        8 months ago        228MB
      docker.elastic.co/elasticsearch/elasticsearch   6.8.5               4f90d9a6692f        9 months ago        866MB
      skywalking/ui                                   latest              e92cfedfe6ba        19 months ago       266MB
      skywalking/oap                                  latest              f5602f687459        19 months ago       266MB
      quay.io/coreos/flannel                          v0.11.0-amd64       ff281650a721        19 months ago       52.6MB
      elasticsearch                                   6.4.0               1ac676545731        2 years ago         791MB
      [root@test ~]# docker run -it bcd7d3f4ed91  wkhtmltopdf http://www.baidu.com test.pdf
      Loading pages (1/6)
      Counting pages (2/6)
      Resolving links (4/6)
      Loading headers and footers (5/6)
      Printing pages (6/6)
      Done
      [root@test ~]# cd /app/pdf
      [root@test pdf]# ll
      total 56
      -rw-r--r-- 1 root root 54840 Aug 24 09:39 test.pdf
      [root@test pdf]#
      
      
  • 相关阅读:
    类型转换
    with语句用法
    微软工具下载网址
    第2章信息系统服务管理
    声明变量
    管理机中录入485总表的操作方法
    任务 uitableview uiscrollview uiresponder
    如何去掉UITableViewController中的分隔线setSeparatorStyle
    NSRunLoop 概述和原理
    使用 Notifications
  • 原文地址:https://www.cnblogs.com/dalianpai/p/13557090.html
Copyright © 2011-2022 走看看