TOP > AcroExch.PDDoc > GetInfo [...]
説明
PDFドキュメントのInfo情報の指定されたキーの値を得ます。
最大512バイトは返されます。
文書プロパティの概要タブにある 「タイトル」、「作成者」、「サブタイトル」、「キーワード」、「アプリケーション」、「PDF変換」、「作成日」、「更新日」の項目もこれで取得できます。
形式
BSTR GetInfo(BSTR szInfoKey);
引数
- 第1引数(BSTR szInfoKey) :
キーワード
戻り値
- 文字列があったなら、成功。
- キーが存在しないか、何らかの理由で値を読むことができないなら、空の文字を返します。
動作するバージョン
Version | Adobe Acrobat |
備考
|
---|---|---|
4
|
-
|
Acrobat 4.0 ※Windows 98SE + Excel 2000 |
5
|
-
|
Acrobat 5.0.5 |
6
|
-
|
Acrobat 6.0.3 Pro |
7
|
-
|
Acrobat 7.0.9 Pro Acrobat 7.1.4 Pro |
8
|
OK
|
Acrobat 8.3.1 Pro |
9
|
-
|
Acrobat 9.3.2 Extended |
10
|
-
|
Acrobat X (10.1.8) Extended |
11
|
OK
|
Acrobat XI (11.0.14) Pro |
- OK = 動作する。
- NO = 動作しない。 戻り値が0を返す。
- - = 未確認。
サンプル:ExcelのVBA
説明:PDFドキュメントから文書プロパティの概要と詳細内容の値を得ます。
- F8キーでステップ実行しながら動作確認する。
- 事前に参照設定をする。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
Option Explicit Sub AcroExch_PDDoc_GetInfo() Dim objAcrobatPDDoc As New Acrobat.AcroPDDoc Dim lRet As Long Dim strGetInfo As String Const CON_FILE As String = "I:\Adobe PDF\execMenuItem.pdf" 'PDFオブジェクトをオープンする。 '注意)Acrobatは画面に表示されない。 lRet = objAcrobatPDDoc.Open(CON_FILE) '文書プロパティのタイトル strGetInfo = objAcrobatPDDoc.GetInfo("Title") Debug.Print "GetInfo(""Title"")=" & strGetInfo '文書プロパティの作成者 strGetInfo = objAcrobatPDDoc.GetInfo("Author") Debug.Print "GetInfo(""Author"")=" & strGetInfo '文書プロパティのサブタイトル strGetInfo = objAcrobatPDDoc.GetInfo("Subject") Debug.Print "GetInfo(""Subject"")=" & strGetInfo '文書プロパティのキーワード strGetInfo = objAcrobatPDDoc.GetInfo("Keywords") Debug.Print "GetInfo(""Keywords"")=" & strGetInfo '文書プロパティのアプリケーション strGetInfo = objAcrobatPDDoc.GetInfo("Creator") Debug.Print "GetInfo(""Creator"")=" & strGetInfo '文書プロパティのPDF変換 strGetInfo = objAcrobatPDDoc.GetInfo("Producer") Debug.Print "GetInfo(""Producer"")=" & strGetInfo '文書プロパティの作成日 strGetInfo = objAcrobatPDDoc.GetInfo("CreationDate") Debug.Print "GetInfo(""CreationDate"")=" & strGetInfo '文書プロパティの更新日 strGetInfo = objAcrobatPDDoc.GetInfo("ModDate") Debug.Print "GetInfo(""ModDate"")=" & strGetInfo '文書プロパティの strGetInfo = objAcrobatPDDoc.GetInfo("Trapped") Debug.Print "GetInfo(""Trapped"")=" & strGetInfo 'PDFオブジェクトを解放する。 objAcrobatPDDoc.Close Set objAcrobatPDDoc = Nothing End Sub |
実行結果
GetInfo("Title")=app.execMenuItem()
GetInfo("Author")=dareka
GetInfo("Subject")=app.execMenuItem("code");
GetInfo("Keywords")=app,execMenuItem,code
GetInfo("Creator")=Word 用 Acrobat PDFMaker 5.0
GetInfo("Producer")=Acrobat Distiller 5.0 (Windows)
GetInfo("CreationDate")=D:20011224105558+09'00'
GetInfo("ModDate")=D:20140423193007+09'00'
GetInfo("Trapped")=
補足
- 最初に「AcroExch.PDDoc:SetInfo メソッド」にあるExcel VBAサンプルを実行しておいて下さい。
- サンプル「Excel:PDFの文書プロパティを表示する」も参照
- 文書プロパティの開き方・タブの更新はココを参照。
参照
動作確認環境
- WindowsXP Pro(+ SP3) +
Acrobat 8.1.2 Pro + Office 2003 + フルMicrosoftUpdate - Windows 7 64bit(+ SP1) +
Acrobat 8.3.1 Pro + Office 2007 + WindowsUpdate - Windows 10 64bit +
Acrobat XI Pro + Office 2007 + WindowsUpdate
< 戻る >
メソッド「GetInfo(“Modified”)」は使えない
Acrobat 7.0.5 SDK (注:既にこのバージョンは未公開?)からダウンロード&インストールした Visual Basic.NET 2003 のサンプルコードを見ると
Label10.Text = AcroPDDoc.GetInfo(“Created“)
Label11.Text = AcroPDDoc.GetInfo(“Modified“)
とGetInfoメソッドの検索キーワードに「Created」と「Modified」がある。
これは間違いみたい。
キーワード「Modified」は間違いで「ModDate」が正解です。
strGetInfo = objAcrobatPDDoc.GetInfo(“ModDate“)
と使うのが正解です。
英語のPDF解説書にはこの記載は今のところ見つかりませんでした。
見つけた場所は、Acrobatメニューの[ファイル(F)]->[文書のプロパティ(D)]->文書のプロパティ画面の[概要]タブ->[その他のメタデータ(M)..]ボタンを押す。
上記の部分に入っています。
自分で入れたPSキーワードの内容も表示されています。
GetInfoメソッドはココにある内容をキーワードで値として拾ってきます。
< 戻る >