TOP > AcroExch.PDPage > GetRotate [...]
説明
現在のページに設定されている回転値を得る。
回転値は0度、90度、180度、270度の4種類のみです。
形式
short GetRotate();
引数
- 無し。
戻り値
- 回転値
※参照設定をしている場合はAcrobat OLE(IAC)専用の定数も提供される。
pdRotate0 = 0
pdRotate90 = 90
pdRotate180 = 180
pdRotate270 = 270
動作するバージョン
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ドキュメントの各ページに設定されている回転度を集計する。
001 Sub AcroExch_PDPage_GetRotate()
002
003 Debug.Print "Test_AcroPDPage_GetRotate:" & Now
004 Dim objAcroApp As New Acrobat.AcroApp
005 Dim objAcroAVDoc As New Acrobat.AcroAVDoc
006 Dim objAcroPDDoc As New Acrobat.AcroPDDoc
007 Dim objAcroPDPage As Acrobat.AcroPDPage
008 Dim objAcroAVPageView As Acrobat.AcroAVPageView
009 Dim objAcroPdAnnot As Acrobat.AcroPDAnnot
010 Dim lRet As Long '戻り値
011 Dim lCnt As Long '件数
012 Dim i As Long '添え字
013 Dim lPage As Long 'ページ数
014 Dim l0 As Long
015 Dim l90 As Long
016 Dim l180 As Long
017 Dim l270 As Long
018
019 'Acrobatを起動表示する
020 lRet = objAcroApp.Show
021 '画面にPDFドキュメントを表示する
022 lRet = objAcroAVDoc.Open("E:\Test01.pdf", "")
023
024 Set objAcroPDDoc = objAcroAVDoc.GetPDDoc()
025 Set objAcroAVPageView = objAcroAVDoc.GetAVPageView()
026 lPage = objAcroPDDoc.GetNumPages - 1
027 Debug.Print "PDF全頁数=" & (lPage + 1)
028
029 For i = 0 To lPage
030 'ページ移動する。
031 lRet = objAcroAVPageView.Goto(i)
032 '現在のページのPDPageオブジェクトを取得する
033 Set objAcroPDPage = objAcroAVPageView.GetPage
034 'ページ回転されているページの集計
035 Select Case objAcroPDPage.GetRotate
036 Case pdRotate0
037 l0 = l0 + 1
038 Case pdRotate90
039 l90 = l90 + 1
040 Case pdRotate180
041 l180 = l180 + 1
042 Case pdRotate270
043 l270 = l270 + 1
044 Case Else
045 Debug.Print "Proguramming Error"
046 End Select
047 'ページ回転されているページの回転度を表示する
048 Debug.Print "Page=" & (i + 1) & " 回転=" & _
049 objAcroPDPage.GetRotate
050 Next i
051
052 Debug.Print " 0度の頁=" & l0
053 Debug.Print " 90度の頁=" & l90
054 Debug.Print "180度の頁=" & l180
055 Debug.Print "270度の頁=" & l270
056
057 'PDFファイルを保存しないで閉じる(TEST用)
058 lRet = objAcroAVDoc.Close(1)
059
060 'Acrobatを閉じる
061 lRet = objAcroApp.Hide
062 lRet = objAcroApp.Exit
063
064 'オブジェクトを強制解放する
065 Set objAcroAVDoc = Nothing
066 Set objAcroPdAnnot = Nothing
067 Set objAcroPDPage = Nothing
068 Set objAcroAVPageView = Nothing
069 Set objAcroPDDoc = Nothing
070 Set objAcroApp = Nothing
071
072 End Sub
Highlight:プログラミング言語のソースコードを構文で色分け (GUI編)
実行結果
Test_AcroPDPage_GetRotate:2008/07/25 16:30:32
PDF全頁数=34
Page=1 回転=0
Page=2 回転=0
Page=3 回転=0
Page=4 回転=90
Page=5 回転=270
Page=6 回転=180
Page=7 回転=0
Page=8 回転=0
Page=9 回転=0
Page=10 回転=0
Page=11 回転=0
Page=12 回転=0
Page=13 回転=0
Page=14 回転=0
Page=15 回転=0
Page=16 回転=0
Page=17 回転=0
Page=18 回転=0
Page=19 回転=0
Page=20 回転=0
Page=21 回転=0
Page=22 回転=0
Page=23 回転=0
Page=24 回転=0
Page=25 回転=0
Page=26 回転=0
Page=27 回転=0
Page=28 回転=0
Page=29 回転=0
Page=30 回転=0
Page=31 回転=0
Page=32 回転=0
Page=33 回転=0
Page=34 回転=0
0度の頁=31
90度の頁=1
180度の頁=1
270度の頁=1
補足
- 参照設定をしてオブジェクトブラウザでAcrobatを指定すると、PDRotateFlagsのメンバーに
pdRotate0(=0), pdRotate90(=90), pdRotate180(=180), pdRotate270(=270)の4つが存在する。
これは
Const pdRotate0 = 0
Const pdRotate90 = 90 (&H5A)
Const pdRotate180 = 180 (&HB4)
Const pdRotate270 = 270 (&H10E)
を定義したと同じ事になる。 - PDFの各ページは原本を回転させた時にその情報を各ページが持っている事がこれで判明する。
動作確認環境
- WindowsXP Pro(+ SP3) +
Acrobat 8.1.2 Pro + Office 2003 + MicrosoftUpdate
< 戻る >