Help us understand the problem. What is going on with this article?

AWSでExcelからPDF変換を行う

More than 1 year has passed since last update.

Excelの見た目のままPDFを作成するために、libreconvを使用してExcelからPDFへconvertをしてみた

環境

  • Amazon Linux
  • Ruby 2.3.0
  • Ruby on Rails 5.0.1

AWSにLibreOfficeをインストールする

$ sudo wget http://ftp.yz.yamagata-u.ac.jp/pub/tdf/libreoffice/stable/5.3.3/rpm/x86_64/LibreOffice_5.3.3_Linux_x86-64_rpm.tar.gz
$ tar xvzf LibreOffice_5.3.3_Linux_x86-64_rpm.tar.gz
$ cd LibreOffice_5.3.3.2_Linux_x86-64_rpm/
$ cd RPMS/
$ sudo yum install *.rpm
$ sudo yum install dbus-glib

gemのインストール

Gemfileに下記を追加
gem 'libreconv'

実装

  require 'libreconv'

  def convert_pdf
    Libreconv.convert('public/sample.xlsx', 'public/sample.pdf')
  end

出力されるpdfはxlsxで指定した印刷イメージで作成されるようだが、指定のフォントがない場合は、多少印刷イメージがずれることがある。
印刷イメージがずれる場合は適宜フォントをインストールする必要がある。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away