TOP > AcroExch.PDAnnot > SetColor [...]
説明
PDFファイル上の注釈の色を設定します。色はカラー番号で指定します。
形式
VARIANT_BOOL SetColor(long nRGBColor);
引数
- 第1引数(long nRGBColor):カラー番号。
戻り値
- -1 : 設定出来た。
- 0 : 設定出来なかった。
動作するバージョン
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.1.2 Pro |
9 | - | Acrobat 9.3.2 Extended |
10 | - | Acrobat X (10.1.8) Extended |
11 | - | Acrobat XI (11.0.04) Extended |
- OK = 動作する。
- NO = 動作しない。 戻り値が0を返す。
- - = 未確認。
サンプル:ExcelのVBA
説明:PDFファイルの全てのテキスト注釈だけ、色を”明るい緑”に変更する。
- F8キーでステップ実行しながら動作確認する。
- 事前に参照設定をする。
001 Sub AcroExch_PDAnnot_SetColor()
002
003 Debug.Print "AcroExch_PDAnnot_SetColor:" & Now
004 Dim objAcroAVDoc As New Acrobat.AcroAVDoc
005 Dim objAcroAVPageView As Acrobat.AcroAVPageView
006 Dim objAcroPDDoc As Acrobat.AcroPDDoc
007 Dim objAcroPDPage As Acrobat.AcroPDPage
008 Dim objAcroPDAnnot As Acrobat.AcroPDAnnot
009 Dim objAcroTime As New Acrobat.AcroTime
010 Dim objRect As Acrobat.AcroRect
011 Dim lRet As Long '戻り値
012 Dim lPagesCnt As Long 'ページ数
013 Dim lAnnotsCnt As Long '注釈数
014 Dim i As Long '添え字
015 Dim j As Long '添え字
016 Dim lCnt As Long '件数
017 Dim lTextCnt As Long 'Text件数
018
019 lCnt = 0
020 lTextCnt = 0
021
022 'PDFドキュメントを開いて表示する。
023 lRet = objAcroAVDoc.Open("E:\Test01.pdf", "")
024 Set objAcroPDDoc = objAcroAVDoc.GetPDDoc()
025 Set objAcroAVPageView = objAcroAVDoc.GetAVPageView()
026 'PDFドキュメントのページ数を得る
027 lPagesCnt = objAcroPDDoc.GetNumPages() - 1
028 For i = 0 To lPagesCnt
029 '該当ページのページオブジェクトを得る ★注意①
030 Set objAcroPDPage = objAcroPDDoc.AcquirePage(i)
031 'PDFビュアーのページを移動させる
032 lRet = objAcroAVPageView.Goto(i) '(TEST用)
033 'ページに存在する注釈数を得る
034 lAnnotsCnt = objAcroPDPage.GetNumAnnots() - 1
035 For j = 0 To lAnnotsCnt
036 lCnt = lCnt + 1
037 Set objAcroPDAnnot = objAcroPDPage.GetAnnot(j)
038 If objAcroPDAnnot.GetSubtype = "Text" Then
039 'テキスト注釈の色を"明るい緑"に変更
040 lRet = objAcroPDAnnot.SetColor(65280)
041 lTextCnt = lTextCnt + 1
042 End If
043 Next j
044 Next i
045 Debug.Print "全件数= " & lCnt
046 Debug.Print "変更件数= " & lTextCnt
047
048 'PDFファイルを保存しないで閉じる
049 lRet = objAcroAVDoc.Close(1) '(TEST用)
050 'オブジェクトを強制解放する
051 Set objAcroAVDoc = Nothing
052 Set objAcroPDAnnot = Nothing
053 Set objAcroPDPage = Nothing
054 Set objAcroAVPageView = Nothing
055 Set objAcroPDDoc = Nothing
056
057 End Sub
Highlight:プログラミング言語のソースコードを構文で色分け (GUI編)
実行結果
TEST_PDAnnot_SetColor:2008/09/04 14:54:01
全件数= 247
変更件数= 3
※実行前のテキスト注釈
※実行後のテキスト注釈
補足
- 65280はRGB(0,255,0)のカラー番号。
動作確認環境
- WindowsXP Pro(+ SP3) +
Acrobat 8.1.2 Pro + Office 2003 + MicrosoftUpdate
< 戻る >