Post

WKHTMLTOPDF 설치 방법(소스 컴파일)

WKHTMLTOPDF 설치 방법(소스 컴파일)

저장소 등록

CentOS의 설치에 필요한 라이브러리를 가지고 있는 외부의 저장소를 추가한다.

  1. CentOS 5.x

    1
    
    $ rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
    
  2. CentOS 6.x

    1
    
    $ rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-6.noarch.rpm
    

저장소 정보 갱신

추가한 저장소의 정보를 검색하기 위해서 저장소들의 정보를 갱신한다.

1
$ yum update

WKHTMLtoPDF 소스파일 다운로드

QT 라이브러리를 활용한 WKHTMLtoPDF 실행 파일 생성 소스는 사전에 미리 다운로드 받아서 올리는 것이 좋음

1
2
$ git clone git://github.com/antialize/wkhtmltopdf.git wkhtmltopdf
$ git clone git://gitorious.org/+wkhtml2pdf/qt/wkhtmltopdf-qt.git wkhtmltopdf-qt

실행을 위한 소스 접근권한 설정

권한은 다운로드 받은 소스가 위치한 곳에서 실행을 한다.

1
2
$ chmod -R 777 wkhtmltopdf
$ chmod -R 777 wkhtmltopdf-qt

컴파일 툴 설치

WKHTMLtoPDF 실행 파일을 컴파일 하기 위한 툴을 설치한다.

1
2
$ yum groupinstall "Development Tools"
$ yum install openssl-devel libXrender-devel libXext-devel libXft-devel

소스 컴파일

다운로드 받은 소스 파일을 컴파일한다.

  1. STEP 1

    중간에 질문이 나오면 *YES*를 입력해준다.

    1
    2
    
    $ cd wkhtmltopdf-qt 
    $ ./configure -nomake tools,examples,demos,docs,translations -opensource -prefix "../wkqt"
    
  2. STEP 2

    1
    
    $ make -j3 && make install
    
  3. STEP 3

    1
    2
    
    $ cd ../wkhtmltopdf
    $ ../wkqt/bin/qmake
    
  4. STEP 4

    1
    
    $ make & make install
    

x64버젼(64bit)인 경우에는 LIB에 대한 소스를 복사해준다.

1
$ cp /lib/libwkhtmltox.so* /usr/lib64/

실행방법

컴파일 완료 후에 사용하는 방법

  • Remote HTML file to PDF

    1
    
    $ wkhtmltopdf "http://www.google.com" newfile.pdf
    
  • Local HTML file to PDF

    1
    
    $ wkhtmltodpf local.html newfile.pdf
    
  • Extended HELP

    1
    
    $ wkhtmltopdf -H
    

참고자료

  1. WKHTMLtoPDF HOMEPAGE
  2. WKHTMLtoPDF 사용방법
  3. WKHTMLtoIMAGE 사용방법
This post is licensed under CC BY 4.0 by the author.