html多个图片转换为pdf文件,把多张图片快速合并成一个pdf文件

08 September 2020

把多张图片快速合并成一个pdf文件

img2pdf方案

安装img2pdf,参考:https://gitlab.mister-muffin.de/josch/img2pdf;

建意把源码下下来,在源码目录下直接使用pip3 install .安装,安装好后使用以下命令即可把多张图片转成一个pdf。

img2pdf *.png *.jpg -o out.pdf

使用万能的 imagemagick

使用brew安装好 imagemagick

brew install imagemagick

如果安装失败,使用sudo chown -R $(whoami) $(brew --prefix)/*,或者:

sudo mkdir /usr/local/Frameworks

sudo chown $USER /usr/local/Frameworks

转成pdf

convert *.jpg output.pdf

convert -quality 60 *.jpg output.pdf

如果是window,可以使用 cygwin 安装 imagemagick 。

把PDF导出成一张张image/html/text

pdftopng ./aaa.pdf ./aaa # 导出成png图片

pdftohtml ./aaa.pdf ./aaa # 导出html并放到生成的aaa目录下

pdftotext ./aaa.pdf ./text # 导出html并放到生成的aaa目录下

如果是要把html生成为pdf

使用wkhtmltopdf是一个不错的选择,官方地址:https://wkhtmltopdf.org/

wkhtmltopdf http://localhost/aaaa.html $HOME/doc_pdf/check.pdf

其他

imagemagick安装好后,可能会有以下环境变量设置的提示:

==> glib

Bash completion has been installed to:

/usr/local/etc/bash_completion.d

==> docbook

To use the DocBook package in your XML toolchain,

you need to add the following to your ~/.bashrc:

export XML_CATALOG_FILES="/usr/local/etc/xml/catalog"

==> gnu-getopt

gnu-getopt is keg-only, which means it was not symlinked into /usr/local,

because macOS already provides this software and installing another version in

parallel can cause all kinds of trouble.

If you need to have gnu-getopt first in your PATH run:

echo 'export PATH="/usr/local/opt/gnu-getopt/bin:$PATH"' >> ~/.zshrc

Bash completion has been installed to:

/usr/local/opt/gnu-getopt/etc/bash_completion.d

==> libtool

In order to prevent conflicts with Apple's own libtool we have prepended a "g"

so, you have instead: glibtool and glibtoolize.

==> guile

Guile libraries can now be installed here:

Source files: /usr/local/share/guile/site/3.0

Compiled files: /usr/local/lib/guile/3.0/site-ccache

Extensions: /usr/local/lib/guile/3.0/extensions

Add the following to your .bashrc or equivalent:

export GUILE_LOAD_PATH="/usr/local/share/guile/site/3.0"

export GUILE_LOAD_COMPILED_PATH="/usr/local/lib/guile/3.0/site-ccache"

export GUILE_SYSTEM_EXTENSIONS_PATH="/usr/local/lib/guile/3.0/extensions"

==> unbound

To have launchd start unbound now and restart at startup:

sudo brew services start unbound

==> gnutls

If you are going to use the Guile bindings you will need to add the following

to your .bashrc or equivalent in order for Guile to find the TLS certificates

database:

export GUILE_TLS_CERTIFICATE_DIRECTORY=/usr/local/etc/gnutls/

==> icu4c

icu4c is keg-only, which means it was not symlinked into /usr/local,

because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c first in your PATH run:

echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc

echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc

For compilers to find icu4c you may need to set:

export LDFLAGS="-L/usr/local/opt/icu4c/lib"

export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set:

export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值