1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PDFのページ番号を編集する

Posted at

書籍をスキャンして作った PDF ファイルで,目次や前書きなどのページ番号の表記を変更し,元の書籍のページ番号と PDF ビューアーでのページ番号を揃える方法.

修正前の PDF ファイルは,Canon DR-C225W を使って Mac でスキャンしたものを想定しています.qpdf を使います.

たとえば,PDF の 1 枚目から 4 枚目のページ番号を i から iV までにして,5 枚目のページ番号を 1 にしたい時.

qpdf —pdf 元ファイル.pdf 作業ファイル.qdf

で,作業ファイルを作る.適当なテキストエディタで編集.viあたりがいいんじゃないかな.emacsだと重いかも.

%% Original object ID: 2 0
1 0 obj
<<
  /Pages 3 0 R
  /Type /Catalog
>>
endobj

のような感じのところ,要するに /Pages の記述があるところに /PageLabels の記述を追加


%% Original object ID: 2 0
1 0 obj
<<
  /Pages 3 0 R
  /PageLabels << /Nums [
      0 << /S /r >>
      4 << /S /D >>
    ] >>
  /Type /Catalog
>>
endobj

とする.ちなみにインデントは適当です.

0 << /S /r >> のところがページ番号の書式の設定で,数字 0 が PDF の何枚目か,<< /S /r >> が小文字のローマ数字,<< /S /D >> とするとアラビア数字を表すようです.詳しくは W3C の PDF17: Specifying consistent page numbering for PDF documents を見ればよさそうです.

fix-pdf < 作業ファイル.qdf > 最終ファイル.pdf

でpdfに戻す

参考:https://superuser.com/questions/232553/how-to-change-internal-page-numbers-in-the-meta-data-of-a-pdf

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?