Recently, you have to make a function of transferring PDF for our article. After comparing, I think PhantomJS is better to transform. How to use it now.
can be downloaded by official website: official website
or Wget can also:
wget -p / tmp / https://bitbucket.org/riya/phantomjs/downloads/partomjs-2.1.1-linux-x86_64.tar.bz2
// Unzip TAR XJF /TMP/PHANTOMJS-2.1.1-Linux-x86_64.tar.bz2 -c / usr / Local /// Rename MV /usR/local/phantomjs-2.1.1-linux-x86_64 / usr / local / phantomjs // established soft connection ln -s / usr / local / phantomjs / bin / phantomjs / usr / local / BIN / now can perform PhantomJS -Version at the terminal to see if the installation is successful
is now not enough, light phantomjs To transform, there will be some problems:
- 1: Chinese garbled
- yum -y install bitmap-fonts Bitmap-fonTS-CJK 2: The font thick is inconsistent
This is the reason why CentOS does not exist, and can be imported into the font.Installing Font Management Tools: Yum Install -y Fontconfig Mkfontscale
Access C: \ Windows \ FONTS, come out of the required font COPY. Then uploaded to / usr / share / fonts under the server
to perform the three commands of mkfontscale, mkfontdir, fc-cache -fv, and then restart the server (Reboot).
- Now, you can write code:
OK Now you can now deploy code to try it.
SummaryIt is a small-editor to introduce the PHANTOMJS to export HTML to PDF, I hope to help everyone. If you have any questions, please leave a message, Xiaobian will reply to everyone. Thank you very much for your support of Tumi Cloud Website!