2008-03-18
■ [Python] Adobe Illustrator の .ai ファイルを PDF に変換する
COM 経由で操作するだけ。Illustrator のファイル形式に対応してるプログラムって全然ないよね。
ダイアログの抑制とか全然できない。超困る。無人処理とかできない。たかだかバッチ処理でスレッド起動して監視かよ。全然手軽じゃない。
import os from win32com.client import Dispatch as CreateObject def ai2pdf(filename): """see http://www.adobe.com/devnet/illustrator/pdfs/IllustratorCS3_VBScript_Reference.pdf""" ai = CreateObject('Illustrator.Application') aiDontDisplayAlerts = -1 ai.UserInteractionLevel = aiDontDisplayAlerts ai.Open(filename) conf = CreateObject('Illustrator.PDFSaveOptions') dst = os.path.splitext(filename)[0] + '.pdf' ai.ActiveDocument.SaveAs(dst, conf) aiDoNotSaveChanges = 2 ai.ActiveDocument.Close(aiDoNotSaveChanges)
SaveAs / Export で渡すファイル名に日本語が含まれているか、長すぎると途中で切られる可能性がある (詳細は未確認)。
一時ファイルとして書き出してからリネームするのが一番楽。
トラックバック - http://d.hatena.ne.jp/chrono-meter/20080318/p1
リンク元
- 5 http://www.google.com/search?hl=ja&lr=lang_ja&ie=UTF-8&oe=UTF-8&q=explore+起動 フリーズ&num=50
- 4 http://q.hatena.ne.jp/1159912113
- 4 http://www.google.co.jp/search?sourceid=navclient&hl=ja&ie=UTF-8&rls=GFRC,GFRC:2007-02,GFRC:ja&q=CHRONO+METER
- 3 http://72.14.235.104/search?q=cache:JDM2yTXu1RsJ:d.hatena.ne.jp/chrono-meter/20070822/p1+glob+python&hl=ja&ct=clnk&cd=6&gl=jp&lr=lang_ja&client=firefox
- 2 http://d.hatena.ne.jp/
- 2 http://ezsch.ezweb.ne.jp/search/?sr=0101&query=CHRONO METER
- 2 http://search.yahoo.co.jp/search?p=CHRONO+METER&search.x=1&fr=top_ga1&tid=top_ga1&ei=UTF-8
- 2 http://www.google.co.jp/search?hl=ja&client=firefox-a&rls=org.mozilla:ja:official&hs=aQe&q=環境変数+vsinstalldir+visual+studio+マクロ&btnG=検索&lr=lang_ja
- 2 http://www.google.co.jp/search?hl=ja&rlz=1B3GGGL_jaJP213JP213&q=gcc-xml&btnG=検索&lr=
- 2 http://www.google.co.jp/search?num=100&hl=ja&c2coff=1&q=unicode+python+glob&lr=lang_ja