$ sudo /usr/local/Adobe/Acrobat7.0/Browser/install_browser_plugin Password: acroread 用ブラウザプラグインをインストールします。 Adobe Reader 7.0 のインストール先ディレクトリを入力してください [/usr/local/Adobe/Acrobat7.0] 1. グローバルインストールを実行 2. ユーザ指定インストールを実行 (Mozilla/Firefox/Netscape) 選択してください [1/2] 1 ブラウザのインストール先ディレクトリを入力してください - /usr/lib/mozilla-1.7.8 インストールは正常に終了しました。追加されたファイル /usr/lib/mozilla-1.7.8/plugins/nppdf.so 他のブラウザをインストールしますか? [y/n] n
$ pdftk 1.pdf 2.pdf cat output results.pdf
$ pdftk A=1.pdf B=2.pdf cat A2 B1-2 output results.pdf $ pdftk A=tanimura-form1.pdf B=tanimura-form1-1ja.pdf \ C=tanimura-form1-en.pdf cat A1-2 C A6 B output tanimura-form1-20061018.pdf
$ pdftk tmp.pdf burst
これで、pg_0001.pdf形式に分割,メタデータファイルdoc_data.txtも出力。 ファイル名を指定するときには、
$ pdftk tmp.pdf burst output ./split/page_%02d.pdf
権限パスワード、文書を開くパスワード、印刷のみ許可
$ pdftk hoge.pdf output fuga.pdf owner_pw owner user_pw user allow printing
投稿規定に全てのフォントを埋め込むこととある場合は、フォントを埋め込み します。dvipdfmxでフォントを埋め込むには、-fオプションでmapファイルを 指定します。
dvipdfmx -f hiraginox.map
Timesなどの欧文フォントの場合は dvipdfm_dl14.map を使うみたい。
オプション無しで普通にpdfに変換すると、
$ pdffonts sample.pdf name type emb sub uni object ID ------------------------------------ ------------ --- --- --- --------- Ryumin-Light-Identity-H CID Type 0 no no no 5 0 GothicBBB-Medium-Identity-H CID Type 0 no no no 7 0 BHGBXW+CMR6 Type 1C yes yes no 8 0 QEDOBI+CMR9 Type 1C yes yes no 9 0 TSYLIX+CMBX9 Type 1C yes yes no 10 0 TJUIHP+CMMI9 Type 1C yes yes no 11 0 DFQNOL+CMSY6 Type 1C yes yes no 12 0 SRUASR+CMSY9 Type 1C yes yes no 13 0 ZIXCYZ+CMMI6 Type 1C yes yes no 14 0 KSRJDZ+CMR5 Type 1C yes yes no 15 0 IYLCIS+CMR7 Type 1C yes yes no 16 0 SLXKBN+TeX-cmex9 Type 1C yes yes no 20 0 XVERXX+CMTI7 Type 1C yes yes no 21 0 IWHIBG+CMBX7 Type 1C yes yes no 22 0 HNYYYD+CMR12 Type 1C yes yes no 49 0となり、CMフォントは埋め込まれているみたいだけど、日本語フォントが埋め 込まれていない。
マップファイルの書き方
rml H :0:lxmincho.ttc gbm H :0:lxgothic.ttc rmlv V :0:lxmincho.ttc gbmv V :0:lxgothic.ttc
または
rml H HiraMinPro-W6.otf gbm H HiraKakuStd-W8.otf rmlv V HiraMinPro-W6.otf gbmv V HiraKakuStd-W8.otf
ttcの場合はコレクションなので何番目かを指定する(この例では0番目)。 mapファイルはもしかすると、/usr/share/texmf/dvipdfm/config/に置いて、 mktexlsrしなくてはいけないかも知れない(未確認)((カレントディレクトリ にmapファイルをおけるかどうか後でテストする))
$ dvipdfmx -o mac-futo.pdf -f futo.map texpower
デフォルトでは、
$ grep '^f' /usr/share/texmf/dvipdfm/config/dvipdfmx.cfg f dvipdfm.map f kanjix.map
となっており、dvipdfmx.mapやkanjix.mapに書かれたフォントを埋め込まない ようになっている。したがって、kanjix.mapに書かれたフォントを埋め込みた いときには、
$ dvipdfmx -o out.pdf -f kanjix.map hoge
とする(らしい)。
AcrobatReader付属の小塚明朝の埋め込み
otf-ujmr-h UniJIS-UTF16-H KozMinProVI-Regular.otf otf-ujmr-v UniJIS-UTF16-V KozMinProVI-Regular.otf otf-cjmr-h Adobe-Japan1-6 KozMinProVI-Regular.otf otf-cjmr-v Identity-V KozMinProVI-Regular.otf hminr-h H KozMinProVI-Regular.otf hminr-v V KozMinProVI-Regular.otf
MacOSXにdviファイルを移して、dvipdfmxのfオプションを使うとあっさりフォ ントの埋め込みに成功した。
埋め込み前
$ pdffonts hoge.pdf name type emb sub uni object ID ------------------------------------ ------------ --- --- --- --------- Ryumin-Light-Identity-H CID Type 0 no no no 5 0 FLWUAF+CMSY8 Type 1C yes yes yes 6 0 GothicBBB-Medium-Identity-H CID Type 0 no no no 8 0 UMGJAK+CMR10 Type 1C yes yes yes 9 0 ABPAIR+CMSY6 Type 1C yes yes yes 10 0 QANCEA+CMR8 Type 1C yes yes yes 11 0 DGGJMD+CMTT8 Type 1C yes yes yes 12 0
リュウミンLと中ゴシックBBBが埋め込まれていない。scpでMacOSXへdviファイ ルをコピーする。
$ dvipdfmx -o with-fonts.pdf -f kanjix.map hoge $ pdffonts with-fonts.pdf name type emb sub uni object ID ------------------------------------ ------------ --- --- --- --------- LCMCGT+HiraMinPro-W3-Identity-H CID Type 0C yes yes no 5 0 EHOMJA+CMSY8 Type 1C yes yes yes 6 0 XYTKAQ+HiraKakuPro-W3-Identity-H CID Type 0C yes yes no 8 0 BPWRGZ+CMR10 Type 1C yes yes yes 9 0 JDTLHM+CMSY6 Type 1C yes yes yes 10 0 SOFXDX+CMR8 Type 1C yes yes yes 11 0 NFOLJZ+CMTT8 Type 1C yes yes yes 12 0 [umusus@shakan5 2007jjsm]$ acroread ~/tanimura-with-fonts.pdf &
ヒラギノ明朝体W3とヒラギノ角ゴシックW3がちゃんと埋め込まれている。
pdfにIPAフォントを埋め込む場合は,以下の内容のファイル ipa.map を用意して
rml H ipam.ttf rmlv V ipam.ttf gbm H ipag.ttf gbmv V ipag.ttf
以下のように dvipdfmx を起動する
$ dvipdfmx -f ipa.map hogehoge.dvi
ipam.ttf
などのファイルが見つからないというエラーが出る場合は,とりあ
えずカレントディレクトリに *.ttf
をコピーすればOK.
同様に,pdfにMSゴシック,MS明朝を埋め込む場合は,以下の設定ファイルを用意する
rml H :0:msmincho.ttc rmlv V :0:msmincho.ttc gbm H :0:msgothic.ttc gbmv V :0:msgothic.ttc
小塚フォントを埋め込む場合
rml H KozMinProVI-Regular.otf rmlv V KozMinProVI-Regular.otf gbm H KozGoPro-Medium.otf gbmv V KozGoPro-Medium.otf
jsarticle.clsを使っている場合は、フォント名が異なるので注意する。
rml-jis H KozMinProVI-Regular.otf rmlv-jis V KozMinProVI-Regular.otf gbm-jis H KozGoPro-Medium.otf gbmv-jis V KozGoPro-Medium.otf
PDFにメモを貼りたい場所に、TeXソースの中で下記のように書く。
\special{pdf: ann width 7cm height 5cm << /Type /Annot /Subtype /Text /Open true /Contents (1セメの時に作ったレポートで、実験したものです。) >>}
というようにアノテーション機能が使える。/OpenはPDFを開いたときのメモの 状態でtrueまたはfalseを指定。メモの内容は/Contentsに書く。色は、/Cで指 定する。例えば、/C [0 0.5 1]というようにRGB値で指定する。
$ dvipdfmx -S test2 test2.dvi -> test2.pdf Owner password: Re-enter owner password: User password: Re-enter user password:
これをAcrobat Readerで閲覧しようとすると、
というようにパスワードを聞かれる。このとき、print:no copy:no change:no addNotes:noになる。閲覧するに もパスワードが必要。
暗号化レベルはKオプション、許可設定はPオプションで行う。 例えば、印刷のみ許可にしたいときは下記のようにする。
$ dvipdfmx -S -K 128 -P 0x0804 dvifile
詳しくはPermission flag for PDF encryptionを参照する。
$ pdfimages sample.pdf samplepdfimagesコマンドでは、PDFファイルに含まれるすべての画像データ(飾り罫 やアイコンなど)がファイル化されるため、不用意に実行すると膨大な数の画 像ファイルが作成されてしまう。-fオプション(開始ページ指定)や-lオプショ ン(終了ページ指定)で対象となるページを指定する。
pdftoppmを使う方法とghostscriptを経由する方法がある。
mkdir img pdftoppm -r 36 hoge.pdf img/
これで36 dpiでimg配下に PPM画像を出力する
PDF画像の縮小化として
pdftoppm 1.pdf 1 for p in *.ppm ; do convert -scale 50% $p $p.jpg done convert 1*.ppm.jpg 1small.pdf
も考えられる。convertでなくてnetPBMを使ってもよい。
convertを用いた実験。applestore03.jpgというファイルをpdf化する。pdf化 する前に、最適化したjpegも用意する。
$ jpegtran -optimize -copy none -outfile applestore03-optimize.jpg -verbose applestore03.jpg
Independent JPEG Group's JPEGTRAN, version 6b 27-Mar-1998
Copyright (C) 1998, Thomas G. Lane
Start of Image
JFIF APP0 marker: version 1.01, density 72x72 1
Miscellaneous marker 0xed, length 26
Miscellaneous marker 0xe1, length 560
Define Quantization Table 0 precision 0
Define Quantization Table 1 precision 0
Start Of Frame 0xc0: width=1280, height=960, components=3
Component 1: 2hx2v q=0
Component 2: 1hx1v q=1
Component 3: 1hx1v q=1
Define Huffman Table 0x00
Define Huffman Table 0x10
Define Huffman Table 0x01
Define Huffman Table 0x11
Start Of Scan: 3 components
Component 1: dc=0 ac=0
Component 2: dc=1 ac=1
Component 3: dc=1 ac=1
Ss=0, Se=63, Ah=0, Al=0
End Of Image
ファイル | サイズ |
---|---|
元のjpeg画像 | 426844 |
最適化したjpeg画像 | 395761 |
元画像をオプションなしで変換したpdf | 419051 |
最適化画像をオプションなしで変換したpdf | 417863 |
下手に圧縮を指定するとサイズが10倍になる。変換元の画像を最適化しても、 pdfにするとさほど変わらない。
$ pdftk A=slide-20060804.pdf B=/tmp/applestore03-nooption.pdf cat A1-2 B1 A3 output combined.pdf owner_pw health user_pw gis
$ pwgen 8 1 saRie3Ah $ pdftk A=sp-slide-20061209.pdf cat A1-2 A5-66 \ output tanimura-20061209.pdf owner_pw saRie3Ah
公開がまずい3-4頁を削除して出力する。pwgenで8文字のパスワードを1個作成 し、所有者パスワードを設定する。TeXから作成したpdfはいつでも再作成でき るので、パスワードは使い捨てにする。ユーザパスワードを設定すると、閲覧 にもパスワードを要求されるので注意する。
ページ削除しない状態では、Titleなどもとの情報は生きている。
$ pdfinfo -upw oL4ieYei tanimura-20061209.pdf Title: spパッケージのクラスとメソッド Subject: 統計数理研究所共同研究「Rの整備と利用」研究会 Keywords: Spatial; GIS; R Author: 谷村 晋 Creator: LaTeX with hyperref package Producer: dvipdfmx (20040411) CreationDate: Tue Dec 12 10:43:51 2006 Tagged: no Pages: 64 Encrypted: yes (print:no copy:no change:no addNotes:no) Page size: 841.89 x 595.28 pts (A4) File size: 1310691 bytes Optimized: no PDF version: 1.4
$ pdfinfo tanimura-20061209.pdf Creator: pdftk 1.12 - www.pdftk.com Producer: itext-paulo (lowagie.com)[JDK1.1] - build 132 CreationDate: Mon Dec 11 19:13:01 2006 ModDate: Mon Dec 11 19:13:01 2006 Tagged: no Pages: 64 Encrypted: yes (print:no copy:no change:no addNotes:no) Page size: 841.89 x 595.28 pts (A4) File size: 1261680 bytes Optimized: no PDF version: 1.4
ところが、ページを抽出したりするとTitleなどが消えてしまう。
$ pdftk encripted.pdf input_pw password output no_passwd.pdf
- PDF to Word (verypdf.com社) http://www.verypdf.com/pdf2word/ - PDF2Office http://www.recosoft.com/japan/download/ - ALLPDF converter http://japan.bcltechnologies.com/products/AllPDF/allpdf.htm - Acrobat 6 - リッチテキストPDF (アンテナハウス) http://arena.nikkeibp.co.jp/col/20050713/112801/ - DocSmartz PDF to Word Converter http://www.docsmartz.net/?gclid=CJ237Ju58IgCFSY-TAod2XRbjQ -
Rで作成した図が
うーん、こまった。これはVineLinuxからUbuntuへ乗り換えることで解決。
ラスター画像をPDFに埋め込むとき、高解像度の画像を縮小して埋め込んでも、 高解像度のままで埋め込まれるので、PDFのファイルサイズは大きくなる。もち ろん、ズームしたときに埋め込まれた画像が綺麗に見えるので、それはそれで よいのだが、e-mailに添付したいときなど、巨大サイズのPDFになってしまうの を避けたい場合もあるだろう。
GhostscriptでPDFを作成するときに、最適化を指定できる。例えば、Ghostscript(実 際のコマンド名は、gs)のラッパであるps2pdf14を使うなら、
$ ps2pdf14 -dPDFSETTINGS=/screen hoge.ps
これで、埋め込まれた高解像度のラスター画像は、72dpiの解像度に縮小されて、 軽いPDFができる。
例えば、手元で1.3MBのpngでやってみたけど、dvipdfmxだと1.7MBに増えて、 ps2pdf14でscreen指定したのは3.1KBだった。
でも、不思議なことに、pdfinfoの出力は、
Optimized: noになっている。
-dPDFSETTINGS
で指定できる値は、下記の通り。
-dPDFSETTINGS=/screen -dPDFSETTINGS=/ebook -dPDFSETTINGS=/printer -dPDFSETTINGS=/prepress -dPDFSETTINGS=/default
なお、screenは72dpi、ebookは150dpi、printerは300dpiに縮小される。「縮小 する」は、downsampleというらしい。
ちなみに、ps2pdf14の既定値では、letterサイズになっているので、A4を指定 する必要がある。-sPAPERSIZE=a4オプションをつける。
ps2pdf14 \ -dNOKANJI \ -dAutoFilterColorImages=false \ -dAutoFilterGrayImages=false \ -sColorImageFilter=FlateEncode \ -sGrayImageFilter=FlateEncode \ -dPDFSETTINGS=/prepress \ -dUseFlateCompression=true \ input.ps
PDFファイル
透かし用のPDFファイル
$ pdftk tmp.pdf background bg.pdf output tmp2.pdf
結果
レイヤーの順番が変だ。字の上に被さってくるので、使い物にならない。
backgroundではなくstampを使ってみる。
$ pdftk tmp.pdf stamp bg.pdf output tmp3.pdf
stamp機能は1.40以降の新しいバージョンでのみサポートされているらしい。 残念。
1.41のrpmをパッケージングして、VinePlusにputした。早速、stamp機能を使 う。
stampは、元のpdfの上に重ねられるようで、「透かし」という意味では、意味 なし。半透明のpdfを重ねるとstampらしくなるかも知れない。
-toPostScript [options] pdf_file ... [ps_dir] -toPostScript [options] -pairs pdf_file_1 ps_file_1 ... -toPostScript [options] Converts the given pdf_files to PostScript. In the first form, if the last file specified is a directory, then all preceding files will be converted to PostScript and the generated PostScript files will be placed into ps_dir. If a directory is not specified, then the PostScript files will be placed in the same directory as the original file. In the second form, the file list contains pairs, each consisting of a PDF filename and a corresponding PostScript filename. If "-" is specified as the PostScript filename, the contents of the generated PS are dumped on stdout. The third form specifies a filter, reading a PDF file from standard input and writing the PostScript file to standard output. Note: When using -toPostScript it must be the first argument passed in on the command line. The following are valid options for the conversion of PDF to PostScript: -binary emit binary PostScript where possible -start <int> identify the first page in the document to be converted (default is the first page of the document). -end <int> identify the last page in the document to be converted (default is the last page of the document) -optimizeForSpeed emit PostScript such that all fonts are emitted once at the beginning of the document. This results in faster transmission times and smaller PostScript documents but requires more PostScript printer virtual memory. -landscape rotate the pages to print landscape -reverse reverse the page order of the output -odd emit only odd-numbered pages -even emit only even-numbered pages -commentsOff don't print comments -annotsOff don't print annots -stampsOff don't print stamps -markupsOn print document and markups -level2 emit Level 2 PostScript (level1 is not supported) -level3 emit Level 3 PostScript -printerhalftones use the printer default halftones. -saveVM download fonts as needed to preserve printer memory -size Paper size (letter,tabloid,ledger,legal,a3,a4,a5,b4,b5) -shrink shrink the pages to fit the page size -expand expand the pages to fit the page size -size <pagesize> set the page size. The following page sizes are recognized: letter - letter size paper tabloid - tabloid size paper ledger - ledger size paper executive - executive size paper a3 - ISO standard A3 size a4 - ISO standard A4 size a5 - ISO standard A5 size b4 - ISO standard B4 size b5 - ISO standard B5 size wxh - custom size paper where w is the integer width in points and h is the integer height in points -transQuality level set the transparency flattening level. Value from 1-5, where 1 means rasterize everything, 5 means rasterize as little as possible, default is 3.
This package is ps/eps/pdf converter which can be used both from the command-line and as a GUI application. Windowsユーザ用にインストラーが付いている。要ruby、GUIを使うなら要Tcl/Tk。MacOSXやLinuxでも使える模様。性能は不明。
PDFプレゼンテーションに特化したPDFビューア。Crossfadeができる。日本語可。キャッシュを作った方が便利。
$ impressive --cache persistent --cachefile Cache --transition Crossfade -T 2000 hoge.pdf
hoge.pdfが全面表示され、Cacheというファイルにキャッシュされる。切り替え効果は無指定だとランダムだけど、ここではCrossfadeで切り替え時間は 2000ms(既定値は1000ms)。Tabキーで一覧表示、zキーでズーム(元に戻すのもzキー)。
pdf2odpを用いて、pdfをodpに変換し、さらにodpをpptに変換する。