---
title: "wkhtmltopdf を CentOS 7 にインストールする方法"
description: "HTMLからPDFを作成する便利なコマンドラインツール wkhtmltopdf を CentOS 7 にインストールする手順を解説します。"
url: "https://laox.com/ja/9mcv"
lang: "ja"
category: "CentOS"
tags: ["wkhtmltopdf","CentOS 7"]
published: "2020-08-05T05:25:20+00:00"
updated: "2020-08-05T05:25:20+00:00"
---

# wkhtmltopdf を CentOS 7 にインストールする方法

CentOS

HTMLからPDFを作成する便利なコマンドラインツール wkhtmltopdf を CentOS 7 にインストールする手順を解説します。

先ず、念の為に CentOS プラットフォームのアーキテクチャを確認しておきましょう。

```
$ arch
x86_64
```

上記のように arch コマンドを実行して「x86_64」と表示されたならば、このサーバはインテル系CPUの 64bit OS 上で動いているという事になります。

次に wkhtmltopdf の最新パッケージ（2020年6月11日 バージョン 0.12.6）をダウンロードします。あくまでも下記は x86_64 専用のパッケージなので、アーキテクチャが x86_64 でない場合は別のURLになるので注意してください。

```
$ wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.centos7.x86_64.rpm
```

このパッケージを展開する前に、必須フォント xorg-x11-fonts-75dpi と xorg-x11-fonts-Type1 をインストールしておきます。このインストールは yum でOKです。

```
$ sudo yum install xorg-x11-fonts-75dpi
$ sudo yum install xorg-x11-fonts-Type1
```

これで wkhtmltox を展開できるようになったので、下記実行します。

```
$ sudo rpm -Uvh wkhtmltox-0.12.6-1.centos7.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:wkhtmltox-1:0.12.6-1.centos7     ################################# [100%]
```

以上でセットアップが完了です。バージョンを確認してみましょう。

```
$ wkhtmltopdf -V
wkhtmltopdf 0.12.6 (with patched qt)
```

0.12.6 と出たならば正常にインストールされています。
早速、PDFを作成してみましょう。

```
$ wkhtmltopdf https://google.co.jp out.pdf
```

Googleのトップページが out.pdf というファイルにPDF出力されていますね。
エンジョイ！
