LoginSignup
16
15

More than 5 years have passed since last update.

スキャンしたPDFデータから製本する手順

Last updated at Posted at 2016-05-09

前提

mupdf-tools pdftk pdfjam imagemagick がインストールされている前提です.

手順別

2ページ1組になっているものを1ページ単位に分割する

Before
|     ¦     | |     ¦     |
|  1  ¦  2  | |  3  ¦  4  | 
|     ¦     | |     ¦     |
After
|     | |     | |     | |     |
|  1  | |  2  | |  3  | |  4  |
|     | |     | |     | |     |
Command
mutool poster -x 2 in.pdf out.pdf

表紙用・裏表紙用に白紙を加える
4の倍数ページになるように調整する

Before
|     | |     | |     | |     |
|  1  | |  2  | |  3  | |  4  | 
|     | |     | |     | |     |
After
|     |
| - 1 |
|     |

|     | |     | |     | |     | 
|  1  | |  2  | |  3  | |  4  | 
|     | |     | |     | |     | 

|     | |     | |     |
| + 1 | | + 2 | | + 3 |
|     | |     | |     |
Command
convert xc:none -page A5 /tmp/blank.pdf
N=$(pdftk in.pdf dump_data | grep NumberOfPages | awk '{print $2}')
N=$(( (4 - (N + 2) % 4) % 4 + 1 ))
pdftk A=/tmp/blank.pdf B=in.pdf cat $(
    printf 'A1 B1-end '
    printf 'A1 %.0s' {1..$N}
) output out.pdf
rm /tmp/blank.pdf
  • 必ずブランクページのサイズは他のページに合わせる.ここではA4を2分割する例と仮定して,A5に設定している.
  • もしページサイズにばらつきがある場合,何らかの手段でページサイズを統一しておく.

ページサイズにばらつきがある場合の対処法

GhostScriptを使う

gsコマンドのインストールが必要です.

gs -sOutputFile=out.pdf -sDEVICE=pdfwrite -sPAPERSIZE=a4 -dPDFFitPage -dNOPAUSE -dBATCH in.pdf

プリンタユーティリティのPDF出力機能を使う

Macだとこういうのありますよね.

スクリーンショット 2016-05-17 20.51.34.png

両面印刷・中とじ用に並び替えて2ページ1組に結合する

Before
|     | |     | |     | |     |
| - 1 | |  1  | |  2  | |  3  |
|     | |     | |     | |     |

|     | |     | |     | |     |
|  4  | | + 1 | | + 2 | | + 3 | 
|     | |     | |     | |     |
After
|     ¦     | |     ¦     |
| + 3 ¦ - 1 | |  1  ¦ + 2 |
|     ¦     | |     ¦     |

|     ¦     | |     ¦     |
| + 1 ¦  2  | |  3  ¦  4  | 
|     ¦     | |     ¦     |
Command (長辺とじ印刷の場合)
pdfbook in.pdf --outfile out.pdf
Command (短辺とじ印刷の場合)
pdfbook --short-edge in.pdf --outfile out.pdf

一気に実行

Before
|     ¦     | |     ¦     | 
|  1  ¦  2  | |  3  ¦  4  |
|     ¦     | |     ¦     |
After
|     ¦     | |     ¦     |
| + 3 ¦ - 1 | |  1  ¦ + 2 |
|     ¦     | |     ¦     |

|     ¦     | |     ¦     |
| + 1 ¦  2  | |  3  ¦  4  | 
|     ¦     | |     ¦     |
Command (長辺とじ印刷の場合)
convert xc:none -page A5 /tmp/blank.pdf
mutool poster -x 2 in.pdf /tmp/tmp-0.pdf
N=$(pdftk /tmp/tmp-0.pdf dump_data | grep NumberOfPages | awk '{print $2}')
N=$(( (4 - (N + 2) % 4) % 4 + 1 ))
pdftk A=/tmp/blank.pdf B=/tmp/tmp-0.pdf cat $(
    printf 'A1 B1-end '
    printf 'A1 %.0s' {1..$N}
) output /tmp/tmp-1.pdf
pdfbook /tmp/tmp-1.pdf --outfile out.pdf
rm /tmp/blank.pdf /tmp/tmp-*.pdf
Command (短辺とじ印刷の場合)
convert xc:none -page A5 /tmp/blank.pdf
mutool poster -x 2 in.pdf /tmp/tmp-0.pdf
N=$(pdftk /tmp/tmp-0.pdf dump_data | grep NumberOfPages | awk '{print $2}')
N=$(( (4 - (N + 2) % 4) % 4 + 1 ))
pdftk A=/tmp/blank.pdf B=/tmp/tmp-0.pdf cat $(
    printf 'A1 B1-end '
    printf 'A1 %.0s' {1..$N}
) output /tmp/tmp-1.pdf
pdfbook --short-edge /tmp/tmp-1.pdf --outfile out.pdf
rm /tmp/blank.pdf /tmp/tmp-*.pdf
16
15
1

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
16
15