2010-02-25
dvipdfmxのパーミッション設定
dvipdfmx という, dvi ファイルを pdf ファイルに変換するコマンドがあります.
% dvipdfmx foo.dvi
とやるだけで foo.pdf を生成してくれるので便利です.
このコマンドで pdf ファイルのパーミッションの設定(印刷禁止とか編集禁止とか)を設定する方法を調べました.
結論から言うと, こういう風にオプションをつけると, 閲覧以外(印刷や編集など)が全て禁止された pdf ファイルを作ることができます.
% dvipdfmx -S -P 0x0008 foo.dvi
-Pオプション
-P (permission) オプションとその引数でフラグを与えて, pdf ファイルの権限を操作します. 上記の 0x008 は閲覧以外全て禁止という意味です. 他には例えばこんな設定フラグがあります.
- 0x0004:印刷のみ許可.
- 0x0008:閲覧以外禁止.
- 0x0010:テキスト, グラフィックのコピーは許可. 印刷は禁止.
- 0x003C:すべて許可(デフォルト)
他のフラグは dvipdfmx.cfg というファイルに説明が載っています. ただし英語で, 読んでみても意味を取るのが難しかったです.
%% Permission flag for PDF encryption: Revision will be 3 if the key size
%% is greater than 40 bits.
%%
%% 0x0004 (Revision 2) Print the document.
%% (Revision 3) Print the document (possibly not at the highest quality
%% level, depending on whether bit 12[0x0800] is also set).
%% 0x0008 Modify the contents of the document by operations other than those
%% controlled by bits 6[0x0020], 9[0x0100], and 11[0x0400].
%% 0x0010 (Revision 2) Copy or otherwise extract text and graphics from the
%% document, including extracting text and graphics (in support of
%% accessibility to disabled users or for other purposes).
%% (Revision 3) Copy or otherwise extract text and grphics from the
%% document by operations other than that controlled by bit 10[0x0200].
%% 0x0020 Add or modify text annotations, fill in interactive form fields,
%% and, if bit 4[0x0008] is also set, create or modify interactive
%% form fields (including signature fields).
%%
%% (Revision 3 only)
%% 0x0100 Fill in existing interactive form fields (including signature
%% fields), even if bit 6 is clear.
%% 0x0200 Extract text and graphics (in support of accessibility to disabled
%% users or for other purposes).
%% 0x0400 Assemble the document (insert, rotate, or delete pages and create
%% bookmarks or thumbnail images), even if bit 4 is clear.
%% 0x0800 Print the document to a representation from which a faithful digital
%% copy of the PDF content could be generated. When this bit is clear
%% (and bit 3 is set), printing is limited to a low-level representation
%% of the appearance, possibly of degraded quality.
http://project.ktug.or.kr/dvipdfmx/data/dvipdfmx.cfg
dvipdfmx.cfg
dvipdfmx.cfg は dvipdfmx の設定ファイルです. コマンドのオプションが省略された時のデフォルトの値がここで設定されています. 上記の 0x003C というデフォルト値もこのファイルの中で指定されています.
デフォルト値の設定と共に各オプションの説明も載っているので, ドキュメントとしても使えます.
ファイルの場所は, $TEXMF/dvipdfmx/dvipdfmx.cfg にあるらしいです. 手元の Mac OSX では /usr/local/texlive/2008/texmf/dvipdfmx/dvipdfmx.cfg に, CentOS5.2 では /usr/local/teTeX/share/texmf/dvipdfm/config/dvipdfmx.cfg にありました.
-Sオプション
-S オプションは dvipdfmx のセキュリティの設定を有効にするためのフラグです. 今回のパーミッションの設定もこの -S オプションを前につけないと有効になりません.
%%
%% PDF Security (Encryption) Setting
%%
%% Those options won't take effects unless you use flag 'S'.
%%
%% Key bits for PDF encryption (40 - 128)
http://project.ktug.or.kr/dvipdfmx/data/dvipdfmx.cfg
-S オプションをつけるとオーナーパスワードとユーザーパスワードの2つをプロンプトから聞かれます. これを設定すると pdf ファイルにパスワードを付加できますし, パスワードが必要なければ何も入力せずにリターンを押せばOKです.
参考
- 55 http://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CDMQFjAA&url=http://d.hatena.ne.jp/cou929_la/20100225/1267073048&ei=twRmT83tMsXLmAXwooG2CA&usg=AFQjCNEGqdE_sPiLvMx-YCMRePdszEko1w&sig2=hE0V96SCp6FGA7EP7EX68Q
- 54 https://www.google.co.jp/
- 38 http://www.google.co.jp/url?sa=t&rct=j&q=dvipdfmx.cfg&source=web&cd=2&ved=0CCQQFjAB&url=http://d.hatena.ne.jp/cou929_la/20100225/1267073048&ei=9fykTqeWEK6VmQW705yoDw&usg=AFQjCNEGqdE_sPiLvMx-YCMRePdszEko1w
- 18 http://www.google.co.jp/search?q=dvipdfmx.cfg&ie=utf-8&oe=utf-8&aq=t&rls=org.gentoo:en-US:unofficial&client=firefox-a
- 16 http://www.google.co.jp/search?sourceid=chrome&ie=UTF-8&q=dvipdfmx+パスワード
- 14 http://www.google.co.jp/search?sourceid=navclient&hl=ja&ie=UTF-8&rlz=1T4GFRE_jaJP361JP361&q=dvipdfmx+設定
- 14 http://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=0CHkQFjAC&url=http://d.hatena.ne.jp/cou929_la/20100225/1267073048&ei=UkKqT6zQNo6diAeGwfnAAw&usg=AFQjCNEGqdE_sPiLvMx-YCMRePdszEko1w&sig2=c40OXzp1hqhHNYDlw5X4dA
- 13 http://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cts=1331520697805&ved=0CDkQFjAB&url=http://d.hatena.ne.jp/cou929_la/20100225/1267073048&ei=r2RdT-TyDpCimQW9lryYDw&usg=AFQjCNEGqdE_sPiLvMx-YCMRePdszEko1w
- 11 http://ohtsuka.cocolog-nifty.com/blog/2012/02/dvipdfmxpdf-79b.html
- 10 http://www.google.co.jp/search?q=dvipdfmx+オプション&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ja:official&hl=ja&client=firefox-a
