3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

コマンドラインで テキストファイルを PDF に変換

Last updated at Posted at 2020-10-01

テキストファイルをPDFに変換する方法です。
Ubuntu 23.10 で確認しました。

必要なコマンドのインストール

sudo apt install nkf
sudo apt install e2ps
sudo apt install ghostscript

入力ファイル: UTF-8 で書かれた file_a.txt
出力ファイル: file_a.pdf

nkf -e file_a.txt > file_a_euc.txt
#
e2ps -p -nh file_a_euc.txt | ps2pdfwr - > file_a.pdf

一旦、EUC_JP に変換しています。

確認したバージョン

$ nkf --version
Network Kanji Filter Version 2.1.5 (2018-12-15) 
Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa).
Copyright (C) 1996-2018, The nkf Project.

$ e2ps --version
e2ps's version is 4.34 (08/21/2002).
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?