support in non latin fonts in centos - pdf

I'm trying to enable export html to pdf in my language (Hebrew).
The html and export work fine on my local machine (Mac).
I'm using https://github.com/wkhtmltopdf/
On the remote machine(Centos7)
The html works with the Hebrew fonts but the export to pdf outputs this
I've tried following:
 1.
<head>
<meta name="pdfkit-page-size" content="Legal"/>
<link rel="stylesheet" href="/static/webapp/plugins/manual/pdf.css">
<meta charset="UTF-8">
</head>
sudo yum install curl cabextract xorg-x11-font-utils fontconfig
sudo yum install liberation-sans-fonts
sudo yum install dejavu-lgc-sans-fonts (from: https://gist.github.com/drakakisgeo/7591660)
None worked.
The output of locale
[my_user#ip-172-31-34-70 ~]$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
Any suggestions?

The answer is that the remote server didn't have the right fonts.
I have also solved this by just copying Arial.ttf from my local mac in /Library/Fonts
scp -i "$STAGING_CERT_PATH" Arial.ttf root#"$STAGING_IP":/usr/share/fonts/local/
to my remote server to /usr/share/fonts/local (created the local dir myself).
then fc-cache -v to update and it worked

try this one yum install cjkuni-uming-fonts

Related

run index.html on npm

I am complete beginner so I apologize in advance.
I have installed npm with these scripts in terminal
1.curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
2.nvm install node
then I set it to run like this
http-server -a localhost
Starting up http-server, serving ./public
Available on:
http://localhost:8081
an I have an index. html in my documents that I would like to display. I have tried to just state the whole path in the browser so like http://localhost:8081/Documents/testServer/index.html
But that doesn't work
You must install the tools inside the folder that contains index.html file as below
First : Open the folder that contain index.html
Second : Install Tools
1.curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
2.nvm install node
Third : Open the live server at :
http://localhost:8081/Documents/testServer/index.html

pandoc: xelatex not found. xelatex is needed for pdf output

I have just upgraded my Macbook Pro OS to El Capitan (v10.11.4).
My attempt to export a Markdown file (created using Sublime Text 2, v2.0.2, build 2221) to pdf using pandoc is now failing, and I receive the following error:
pandoc: xelatex not found. xelatex is needed for pdf output
My output command is as follows:
pandoc doc1.md -o doc1.pdf --toc -V geometry:margin=1in --variable fontsize=10pt --variable fontfamily=utopia --variable linkcolor=blue --latex-engine=xelatex -f markdown-implicit_figures -s
Above command worked like a charm prior to installing El Capitan.
FYI - in searching for questions here I have not found one that gives a suitable answer.
For my case, add one line into ~/.bashrc solved the error:
export PATH=/Library/TeX/texbin:$PATH
Of course, the environment variable should be activated in the current term:
$ . ~/.bashrc
then run: $ make
the error disappears.
El Capitan's security features disable and remove the old symlink /usr/texbin. If you have MacTeX 2015, they should've been installed in /Library/TeX/texbin as well. You'll have to update the PATH your using to launch pandoc to include that folder. If you have a pre-2015 distribution of MacTeX, there are instructions here.
Linux Ubuntu instructions:
Tested on Ubuntu 18.04:
If you see this error on Linux Ubuntu:
pandoc: xelatex not found. xelatex is needed for pdf output
Then you need to install the texlive-xetex package like this:
sudo apt update
sudo apt install texlive-xetex
That solves it! Source where I learned this: TEX: XeLatex under Ubuntu.
In my particular case, I was trying to run this make_book.sh script to generate book.pdf, so I needed to do all of the following:
sudo apt update
sudo apt install pandoc
pip3 install MarkdownPP
sudo apt install texlive-xetex
cd path/to/repo
cd systemd-by-example
./make_book.sh
# You'll now have "book.pdf" inside directory "systemd-by-example"!
References:
https://github.com/jreese/markdown-pp - instructions to install MarkdownPP
https://tex.stackexchange.com/a/179811/168682 - instructions to install texlive-xetex

phantomjs screenshot font missing, boxes rendered instead

I am using PhantomJs 1.8.1 on Centos 6.3 to for automated ui tests. When a test fails, screenshots are saved to the file system.
My problem is that even though the screenshots are saved, they do not contain readable fonts.
So if the website reads like this:
Hello, World!
the screenshot of the site will look like this:
So, instead of the actual letters, it renders and saves little boxes.
The system is centos 6.3.
Freetype and Fontconfig are also installed.
How could i go about fixing this?
Thx!
I had the same problem.
Installing the urw-fonts package solved it for me:
yum install urw-fonts
I had a similar problem with Japanese fonts. (PhantomJS 1.9.1, Redhat on Amazon EC2)
English characters showed up fine, but Japanese characters were rendered as boxes.
How I fixed it:
1) Installed the (Japanese) IPA fonts (Mincho and Gothic) using yum install.
(Use yum list to check the exact package names.)
2) The IPA .ttf files were installed to:
/usr/share/fonts/IPA-Gothic/
/usr/share/fonts/IPA-Mincho/
3) Move the two downloaded .ttf files to this directory: (Create it)
/usr/share/fonts/ipa/
4) Make a backup of /etc/fonts/fonts.conf
5) Edit the original /etc/fonts/fonts.conf and fill it with this:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>/usr/share/fonts/ipa</dir>
<cachedir>/var/cache/fontconfig</cachedir>
<cachedir>~/.fontconfig</cachedir>
<alias>
<family>serif</family>
<prefer>
<family>IPAP Mincho</family>
</prefer>
</alias>
<alias>
<family>sans serif</family>
<prefer>
<family>IPAP Gothic</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>IPA Gothic</family>
</prefer>
</alias>
</fontconfig>
6) Refresh your font cache with fc-cache -vf
7) Enjoy your new working fonts.
Gotchas:
If you're getting no characters (blank space), your font cache is probably out of date.
Try fc-cache -vf to regenerate it.
There's a fix for Japanese/Chinese/Korean characters in the 1.9.1 release. Not sure if it makes a difference, but probably worth upgrading from 1.9.0.
For Chinese font, I had it solved by the following steps:
sudo apt-get install language-pack-zh-hans
sudo apt-get install ttf-arphic-uming
sudo apt-get install ttf-dejavu ttf-wqy-microhei
sudo fc-cache -f -v
OS is Ubuntu 12.04 LTS
I have the same problem on amazon ec2
I fix it by this:
yum install cjkuni-ukai-fonts
Also you can try instaling dependencies - FontConfig & FreeType
yum install fontconfig
yum install freetype*
You can run the script with command line parameters:
phanthomjs --output-encoding=cp866 [params] [filename]
I faced same issue with Arabic fonts. This is what i did.
yum groupinstall 'Arabic Support'.
Installing Arabic Support solved it for me.
Try this for Chinese.
yum install bitmap-fonts bitmap-fonts-cjk
leave the /etc/fonts/fonts.conf file alone. the example above is making only Japanese work
yum install -y ipa-gothic-fonts.noarch ipa-mincho-fonts.noarch cjkuni-ukai-fonts.noarch bitmap-fonts bitmap-fonts-cjk urw-fonts fontconfig freetype*
yum groupinstall -y 'Korean Support' 'Chinese Support' 'Japanese Support' 'Kannada Support' 'Hindi Support' 'Arabic Support'
fc-cache -vf
Add a style section to your HTML section Something like this:
<style type="text/css">
#font-face
{
font-family:MyFont;
src: url('MyFont.ttf') format('truetype');
}
#barcodefont
{
font-family:MyFont;
font-size: 42px;
color:black;
}
</style>
Then to use the font in the main HTML code do this:
<div id="MyFont">Your text using MyFont</div>
For this to work, your HTML file and your MyFont.ttf file both have to be in the PhantomJS directory that you are doing the conversion.

problem with host- imagick

I have a problem with this module.
In my local server i open my php.ini and i have the module imagick in the list.
Now i changed the site to a webserver, but in php.ini, the module is not showed.
I talked with the company that have the web server, and the answer is: "the module is installed and show me this:"
root#dime38 [~]# convert
Version: ImageMagick 6.2.8 08/25/10 Q16 file:/usr/share/ImageMagick-6.2.8/doc/index.html
but when i use this code:
<?php
$image = new Imagick();
$image->newImage(100, 100, new ImagickPixel('red'));
$image->setImageFormat('png');
header('Content-type: image/png');
echo $image;
?>
i simple receive this:
Fatal error: Class 'Imagick' not found in /home/empreg0l/public_html/modulo.php on line 3
But the same code works in my local host.
What is the problem? (Probably, the extension is commented in the php.ini? or exists any problem in the code?)
thanks
There is a difference between the ImageMagick binary (which can be called through the convert command) and the IMagick PHP extension. Even if the binary is installed, it doesn't mean the PHP extension is.
Your provider would have to explicitly activate that in their server's PHP.
If they won't do that, you'll have to recreate the IMagick commands as command line options and call it through exec().
To install imagick for php:
apt-get install php5-imagick
Use get_loaded_extensions to confirm you have the imagick PHP extension installed.
var_dump(get_loaded_extensions());
apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget https://pecl.php.net/get/imagick-3.4.0.tgz
tar xvzf imagick-3.4.0.tgz
cd imagick-3.4.0
phpize
./configure
make install
rm -rf /tmp/imagick-3.4.0*
echo extension=imagick.so >> /etc/php/7.0/cli/php.ini
echo extension=imagick.so >> /etc/php/7.0/fpm/php.ini
From Install Imagick 3.4.0 on PHP 7.0

How to install wkhtmltopdf on a linux based (shared hosting) web server

I have tried in all ways to get wkhtmltopdf installed on our web server but unfortunately it is not getting installed. I cannot access user/bin folder as stated in a tutorial on installation.
On the server in public_html folder there is a sub folder _vti_bin, I copied the file wkhtmltopdf-i386 from wkhtmltopdf-0.9.1-static-i386, but I am not able to execute it.
How to install wkhtmltopdf on (shared hosting) web server and get it working?
I've managed to successfully install wkhtmltopdf-amd64 on my shared hosting account without root access.
Here's what i did:
Downloaded the relevant static binary v0.10.0 from here: http://code.google.com/p/wkhtmltopdf/downloads/list
EDIT: The above has moved to here
via ssh on my shared host typed the following:
$ wget {relavant url to binary from link above}
$ tar -xvf {filename of above wget'd file}
you'll then have the binary on your host and will be able to run it regardless of if its in the /usr/bin/ folder or not. (or at least i was able to)
To test:
$ ./wkhtmltopdf-amd64 http://www.example.com example.pdf
Note remember that if you're in the folder in which the executable is, you should probably preface it with ./ just to be sure.
Worked for me anyway
If you have sudo access...
Ubuntu 14.04 / 15.04 / 18.04:
sudo apt-get install wkhtmltopdf
# or
sudo apt install wkhtmltopdf
Others
Look at the other answers.
If its ubuntu then go ahead with this, already tested.:--
first, installing dependencies
sudo aptitude install openssl build-essential xorg libssl-dev
for 64bits OS
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2
mv wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf
chmod +x /usr/local/bin/wkhtmltopdf
for 32bits OS
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-i386.tar.bz2
tar xvjf wkhtmltopdf-0.9.9-static-i386.tar.bz2
mv wkhtmltopdf-i386 /usr/local/bin/wkhtmltopdf
chmod +x /usr/local/bin/wkhtmltopdf
Debian 8 Jessie
This works
sudo apt-get install wkhtmltopdf
Chances are that without full access to this server (due to being a hosted account) you are going to have problems. I would go so far as to say that I think it is a fruitless endeavor--they have to lock servers down in hosted environments for good reason.
Call your hosting company and make the request to them to install it, but don't expect a good response--they typically won't install very custom items for single users unless there is a really good reason (bug fixes for example).
Lastly, depending on how familiar you are with server administration and what you are paying for server hosting now consider something like http://www.slicehost.com. $20 a month will get you a low grade web server (256 ram) and you can install anything you want. However, if you are running multiple sites or have heavy load the cost will go up as you need larger servers.
GL!
Latest update for CentOS:
sudo yum install -y libpng libjpeg openssl icu libX11 libXext libXrender xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar -xvf wkhtmltox-0.12.4_linux-generic-amd64.tar
sudo mv wkhtmltox/bin/* /usr/local/bin/
check installation success: wkhtmltopdf -V
rm -rf wkhtmltox
rm -f wkhtmltox-0.12.4_linux-generic-amd64.tar
Place the wkhtmltopdf executable on the server and chmod it +x.
Create an executable shell script wrap.sh containing:
#!/bin/sh
export HOME="$PWD"
export LD_LIBRARY_PATH="$PWD/lib/"
exec $# 2>/dev/null
#exec $# 2>&1 # debug mode
Download needed shared objects for that architecture and place them an a folder named "lib":
lib/libfontconfig.so.1
lib/libfontconfig.so.1.3.0
lib/libfreetype.so.6
lib/libfreetype.so.6.3.18
lib/libX11.so.6 lib/libX11.so.6.2.0
lib/libXau.so.6 lib/libXau.so.6.0.0
lib/libxcb.so.1 lib/libxcb.so.1.0.0
lib/libxcb-xlib.so.0
lib/libxcb-xlib.so.0.0.0
lib/libXdmcp.so.6
lib/libXdmcp.so.6.0.0
lib/libXext.so.6 lib/libXext.so.6.4.0
(some of them are symlinks)
… and you're ready to go:
./wrap.sh ./wkhtmltopdf-amd64 --page-size A4 --disable-internal-links --disable-external-links "http://www.example.site/" out.pdf
If you experience font problems like squares for all the characters, define TrueType fonts explicitly:
#font-face {
font-family:Trebuchet MS;
font-style:normal;
font-weight:normal;
src:url("http://www.yourserver.tld/fonts/Trebuchet_MS.ttf");
format(TrueType);
}
List of stable versions wkhtmltopdf: http://wkhtmltopdf.org/downloads.html
Installing wkhtmltopdf on Debian 8.2 (jessie) x64:
sudo apt-get install xfonts-75dpi
sudo apt-get install xfonts-base
sudo wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-jessie-amd64.deb
sudo dpkg -i wkhtmltox-0.12.2.1_linux-jessie-amd64.deb
Shared hosting no ssh or shell access?
Here is how i did it;
Visit https://wkhtmltopdf.org/downloads.html and download the appropriate stable release for Linux. For my case I chose 32-bit
which is wkhtmltox-0.12.4_linux-generic-i386.tar.xz
Unzip to a folder on your local drive.
Upload the folder to public_html (or whichever location fits your need) using an FTP program just like any other file(s)
Change the binary paths in snappy.php file to point the appropriate files in the folder you just uploaded.
Bingo! there you have it. You should be able to generate PDF files.
A few things have changed since the top answers were added. They used to work out for me, but not quite anymore, so I have been hacking around for a bit and came up with the following solution for Ubuntu 16.04. For Ubuntu 14.04, see the comment at the bottom of the answer. Apologies if this doesn't work for shared hosting, but it seems like this is the goto answer for wkhtmltopdf installation instructions in general.
# Install dependencies
apt-get install libfontconfig \
zlib1g \
libfreetype6 \
libxrender1 \
libxext6 \
libx11-6
# TEMPORARY FIX! SEE: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3001
apt-get install libssl1.0.0=1.0.2g-1ubuntu4.8
apt-get install libssl-dev=1.0.2g-1ubuntu4.8
# Download, extract and move binary in place
curl -L -o wkhtmltopdf.tar.xz https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar -xf wkhtmltopdf.tar.xz
mv wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
chmod +x /usr/local/bin/wkhtmltopdf
Test it out:
wkhtmltopdf http://www.google.com google.pdf
You should now have a file named google.pdf in the current working directory.
This approach downloads the binary from the website, meaning that you can use the latest version instead of relying on package managers to be updated.
Note that as of today, my solution includes a temporary fix to this bug. I realize that the solution is really not great, but hopefully it can be removed soon. Be sure to check the status of the linked GitHub issue to see if the fix is still necessary when you read this answer!
For Ubuntu 14.04, you will need to downgrade to a different version of libssl. You can find the versions here. Anyways, be sure to consider the implications of downgrading libssl before doing so on any production server.
I hope this helps someone!
After trying, below command work for me
cd ~
yum install -y xorg-x11-fonts-75dpi xorg-x11-fonts-Type1 openssl git-core fontconfig
wget https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
mv wkhtmltox/bin/wkhtmlto* /usr/bin
Version 12.5 of wkhtmltopdf only lists DEB files on their download page now. Being a mac user and not knowing much linux or what DEB files were I couldn't use the solutions posted.
This page helped me get past the knew twist of downloading a DEB file: http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/
Basically what I did was:
Downloaded from https://wkhtmltopdf.org/downloads.html
Unzipped the DEB file.
Unzipped data.tar.xz
Uploaded the binary in the unzipped 'usr' folder from step 3 (usr/local/bin/wkhtmltopdf)
Then I found out that the 'exec' function was disabled on my host. So make sure you can specifically run 'exec' if you're using PHP to run this. "Can I run the wkhtmltopdf binary" isn't specific enough. My fault.