acrobat 0.0.8 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.standard.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/Guardfile +28 -30
- data/{LICENSE.adoc → LICENSE.txt} +21 -22
- data/README.md +107 -0
- data/Rakefile +10 -48
- data/examples/6030.17.antenna.pdf +0 -0
- data/examples/6030.17.cm300.tx.pdf +0 -0
- data/examples/form_field.rb +21 -0
- data/examples/merge.rb +11 -0
- data/lib/acrobat/app.rb +42 -57
- data/lib/acrobat/jso.rb +18 -25
- data/lib/acrobat/pdoc.rb +49 -42
- data/lib/acrobat/version.rb +5 -0
- data/lib/acrobat.rb +14 -17
- data/samples_other/background.js +40 -0
- data/samples_other/find_word.vb +440 -0
- data/samples_other/form.vb +393 -0
- data/vba/overlay.vba +40 -0
- metadata +34 -217
- checksums.yaml.gz.sig +0 -0
- data/.autotest +0 -25
- data/.gitignore +0 -32
- data/History.adoc +0 -6
- data/Manifest.txt +0 -15
- data/README.adoc +0 -117
- data/bin/acrobat +0 -3
- data/test/acrobat_test.rb +0 -36
- data/test/test_helper.rb +0 -13
- data.tar.gz.sig +0 -1
- metadata.gz.sig +0 -2
@@ -0,0 +1,440 @@
|
|
1
|
+
Option Strict Off
|
2
|
+
Option Explicit On
|
3
|
+
Friend Class FindTextForm
|
4
|
+
Inherits System.Windows.Forms.Form
|
5
|
+
#Region "Windows Form Designer generated code "
|
6
|
+
Public Sub New()
|
7
|
+
MyBase.New()
|
8
|
+
If m_vb6FormDefInstance Is Nothing Then
|
9
|
+
If m_InitializingDefInstance Then
|
10
|
+
m_vb6FormDefInstance = Me
|
11
|
+
Else
|
12
|
+
Try
|
13
|
+
'For the start-up form, the first instance created is the default instance.
|
14
|
+
If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
|
15
|
+
m_vb6FormDefInstance = Me
|
16
|
+
End If
|
17
|
+
Catch
|
18
|
+
End Try
|
19
|
+
End If
|
20
|
+
End If
|
21
|
+
'This call is required by the Windows Form Designer.
|
22
|
+
InitializeComponent()
|
23
|
+
End Sub
|
24
|
+
'Form overrides dispose to clean up the component list.
|
25
|
+
Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
|
26
|
+
If Disposing Then
|
27
|
+
If Not components Is Nothing Then
|
28
|
+
components.Dispose()
|
29
|
+
End If
|
30
|
+
End If
|
31
|
+
MyBase.Dispose(Disposing)
|
32
|
+
End Sub
|
33
|
+
'Required by the Windows Form Designer
|
34
|
+
Private components As System.ComponentModel.IContainer
|
35
|
+
Public ToolTip1 As System.Windows.Forms.ToolTip
|
36
|
+
Public WithEvents CloseBtn As System.Windows.Forms.Button
|
37
|
+
Public WithEvents FindBtn As System.Windows.Forms.Button
|
38
|
+
Public WithEvents InputText As System.Windows.Forms.TextBox
|
39
|
+
Public WithEvents OpenFileBtn As System.Windows.Forms.Button
|
40
|
+
Public WithEvents LabelInfo As System.Windows.Forms.Label
|
41
|
+
Friend WithEvents Label1 As System.Windows.Forms.Label
|
42
|
+
Public WithEvents pdfName As System.Windows.Forms.Label
|
43
|
+
'NOTE: The following procedure is required by the Windows Form Designer
|
44
|
+
'It can be modified using the Windows Form Designer.
|
45
|
+
'Do not modify it using the code editor.
|
46
|
+
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
|
47
|
+
Me.components = New System.ComponentModel.Container
|
48
|
+
Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
|
49
|
+
Me.CloseBtn = New System.Windows.Forms.Button
|
50
|
+
Me.FindBtn = New System.Windows.Forms.Button
|
51
|
+
Me.InputText = New System.Windows.Forms.TextBox
|
52
|
+
Me.OpenFileBtn = New System.Windows.Forms.Button
|
53
|
+
Me.LabelInfo = New System.Windows.Forms.Label
|
54
|
+
Me.pdfName = New System.Windows.Forms.Label
|
55
|
+
Me.Label1 = New System.Windows.Forms.Label
|
56
|
+
Me.SuspendLayout()
|
57
|
+
'
|
58
|
+
'CloseBtn
|
59
|
+
'
|
60
|
+
Me.CloseBtn.BackColor = System.Drawing.SystemColors.Control
|
61
|
+
Me.CloseBtn.Cursor = System.Windows.Forms.Cursors.Default
|
62
|
+
Me.CloseBtn.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
63
|
+
Me.CloseBtn.ForeColor = System.Drawing.SystemColors.ControlText
|
64
|
+
Me.CloseBtn.Location = New System.Drawing.Point(243, 86)
|
65
|
+
Me.CloseBtn.Name = "CloseBtn"
|
66
|
+
Me.CloseBtn.RightToLeft = System.Windows.Forms.RightToLeft.No
|
67
|
+
Me.CloseBtn.Size = New System.Drawing.Size(73, 25)
|
68
|
+
Me.CloseBtn.TabIndex = 4
|
69
|
+
Me.CloseBtn.Text = "Close"
|
70
|
+
Me.CloseBtn.UseVisualStyleBackColor = False
|
71
|
+
'
|
72
|
+
'FindBtn
|
73
|
+
'
|
74
|
+
Me.FindBtn.BackColor = System.Drawing.SystemColors.Control
|
75
|
+
Me.FindBtn.Cursor = System.Windows.Forms.Cursors.Default
|
76
|
+
Me.FindBtn.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
77
|
+
Me.FindBtn.ForeColor = System.Drawing.SystemColors.ControlText
|
78
|
+
Me.FindBtn.Location = New System.Drawing.Point(219, 55)
|
79
|
+
Me.FindBtn.Name = "FindBtn"
|
80
|
+
Me.FindBtn.RightToLeft = System.Windows.Forms.RightToLeft.No
|
81
|
+
Me.FindBtn.Size = New System.Drawing.Size(97, 25)
|
82
|
+
Me.FindBtn.TabIndex = 3
|
83
|
+
Me.FindBtn.Text = "Search"
|
84
|
+
Me.FindBtn.UseVisualStyleBackColor = False
|
85
|
+
'
|
86
|
+
'InputText
|
87
|
+
'
|
88
|
+
Me.InputText.AcceptsReturn = True
|
89
|
+
Me.InputText.BackColor = System.Drawing.SystemColors.Window
|
90
|
+
Me.InputText.Cursor = System.Windows.Forms.Cursors.IBeam
|
91
|
+
Me.InputText.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
92
|
+
Me.InputText.ForeColor = System.Drawing.Color.Blue
|
93
|
+
Me.InputText.Location = New System.Drawing.Point(12, 55)
|
94
|
+
Me.InputText.MaxLength = 0
|
95
|
+
Me.InputText.Name = "InputText"
|
96
|
+
Me.InputText.RightToLeft = System.Windows.Forms.RightToLeft.No
|
97
|
+
Me.InputText.Size = New System.Drawing.Size(201, 20)
|
98
|
+
Me.InputText.TabIndex = 2
|
99
|
+
Me.InputText.Text = " "
|
100
|
+
'
|
101
|
+
'OpenFileBtn
|
102
|
+
'
|
103
|
+
Me.OpenFileBtn.BackColor = System.Drawing.SystemColors.Control
|
104
|
+
Me.OpenFileBtn.Cursor = System.Windows.Forms.Cursors.Default
|
105
|
+
Me.OpenFileBtn.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
106
|
+
Me.OpenFileBtn.ForeColor = System.Drawing.SystemColors.ControlText
|
107
|
+
Me.OpenFileBtn.Location = New System.Drawing.Point(219, 12)
|
108
|
+
Me.OpenFileBtn.Name = "OpenFileBtn"
|
109
|
+
Me.OpenFileBtn.RightToLeft = System.Windows.Forms.RightToLeft.No
|
110
|
+
Me.OpenFileBtn.Size = New System.Drawing.Size(97, 25)
|
111
|
+
Me.OpenFileBtn.TabIndex = 0
|
112
|
+
Me.OpenFileBtn.Text = "Browse..."
|
113
|
+
Me.OpenFileBtn.UseVisualStyleBackColor = False
|
114
|
+
'
|
115
|
+
'LabelInfo
|
116
|
+
'
|
117
|
+
Me.LabelInfo.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer))
|
118
|
+
Me.LabelInfo.Cursor = System.Windows.Forms.Cursors.Default
|
119
|
+
Me.LabelInfo.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
120
|
+
Me.LabelInfo.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(128, Byte), Integer), CType(CType(0, Byte), Integer))
|
121
|
+
Me.LabelInfo.Location = New System.Drawing.Point(12, 86)
|
122
|
+
Me.LabelInfo.Name = "LabelInfo"
|
123
|
+
Me.LabelInfo.RightToLeft = System.Windows.Forms.RightToLeft.No
|
124
|
+
Me.LabelInfo.Size = New System.Drawing.Size(193, 17)
|
125
|
+
Me.LabelInfo.TabIndex = 5
|
126
|
+
'
|
127
|
+
'pdfName
|
128
|
+
'
|
129
|
+
Me.pdfName.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer))
|
130
|
+
Me.pdfName.Cursor = System.Windows.Forms.Cursors.Default
|
131
|
+
Me.pdfName.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
132
|
+
Me.pdfName.ForeColor = System.Drawing.Color.Blue
|
133
|
+
Me.pdfName.Location = New System.Drawing.Point(12, 13)
|
134
|
+
Me.pdfName.Name = "pdfName"
|
135
|
+
Me.pdfName.RightToLeft = System.Windows.Forms.RightToLeft.No
|
136
|
+
Me.pdfName.Size = New System.Drawing.Size(201, 16)
|
137
|
+
Me.pdfName.TabIndex = 1
|
138
|
+
Me.pdfName.Text = "No PDF Open"
|
139
|
+
'
|
140
|
+
'Label1
|
141
|
+
'
|
142
|
+
Me.Label1.AutoSize = True
|
143
|
+
Me.Label1.Location = New System.Drawing.Point(12, 37)
|
144
|
+
Me.Label1.Name = "Label1"
|
145
|
+
Me.Label1.Size = New System.Drawing.Size(91, 15)
|
146
|
+
Me.Label1.TabIndex = 7
|
147
|
+
Me.Label1.Text = "Word to Find"
|
148
|
+
'
|
149
|
+
'FindTextForm
|
150
|
+
'
|
151
|
+
Me.AutoScaleBaseSize = New System.Drawing.Size(8, 14)
|
152
|
+
Me.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer))
|
153
|
+
Me.ClientSize = New System.Drawing.Size(324, 121)
|
154
|
+
Me.Controls.Add(Me.Label1)
|
155
|
+
Me.Controls.Add(Me.CloseBtn)
|
156
|
+
Me.Controls.Add(Me.FindBtn)
|
157
|
+
Me.Controls.Add(Me.InputText)
|
158
|
+
Me.Controls.Add(Me.OpenFileBtn)
|
159
|
+
Me.Controls.Add(Me.LabelInfo)
|
160
|
+
Me.Controls.Add(Me.pdfName)
|
161
|
+
Me.Cursor = System.Windows.Forms.Cursors.Default
|
162
|
+
Me.Font = New System.Drawing.Font("Courier New", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
163
|
+
Me.ForeColor = System.Drawing.Color.Blue
|
164
|
+
Me.Location = New System.Drawing.Point(4, 23)
|
165
|
+
Me.Name = "FindTextForm"
|
166
|
+
Me.RightToLeft = System.Windows.Forms.RightToLeft.No
|
167
|
+
Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual
|
168
|
+
Me.Text = "Find Text In PDF"
|
169
|
+
Me.ResumeLayout(False)
|
170
|
+
Me.PerformLayout()
|
171
|
+
|
172
|
+
End Sub
|
173
|
+
#End Region
|
174
|
+
#Region "Upgrade Support "
|
175
|
+
Private Shared m_vb6FormDefInstance As FindTextForm
|
176
|
+
Private Shared m_InitializingDefInstance As Boolean
|
177
|
+
Public Shared Property DefInstance() As FindTextForm
|
178
|
+
Get
|
179
|
+
If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
|
180
|
+
m_InitializingDefInstance = True
|
181
|
+
m_vb6FormDefInstance = New FindTextForm()
|
182
|
+
m_InitializingDefInstance = False
|
183
|
+
End If
|
184
|
+
DefInstance = m_vb6FormDefInstance
|
185
|
+
End Get
|
186
|
+
Set
|
187
|
+
m_vb6FormDefInstance = Value
|
188
|
+
End Set
|
189
|
+
End Property
|
190
|
+
#End Region
|
191
|
+
' ADOBE SYSTEMS INCORPORATED
|
192
|
+
' Copyright (C) 1994-2003 Adobe Systems Incorporated
|
193
|
+
' All rights reserved.
|
194
|
+
'
|
195
|
+
' NOTICE: Adobe permits you to use, modify, and distribute this file
|
196
|
+
' in accordance with the terms of the Adobe license agreement
|
197
|
+
' accompanying it. If you have received this file from a source other
|
198
|
+
' than Adobe, then your use, modification, or distribution of it
|
199
|
+
' requires the prior written permission of Adobe.
|
200
|
+
'------------------------------------------------------------
|
201
|
+
' FindTextDorm.frm
|
202
|
+
' VB project "VBjsoFindWord" is a Acrobat VB JavaScript Object sample.
|
203
|
+
' There is a dialog for the user to select a PDF and input a word to find.
|
204
|
+
' After each occurance is found, a dialog pops up to ask the user if continue the search.
|
205
|
+
' Final message will show the result: number of occurances found.
|
206
|
+
'
|
207
|
+
' The approach is to get the Acrobat JavaScript Object from the PDDoc
|
208
|
+
' of a PDF file first, after that you can call most Javascript methods.
|
209
|
+
' The search is case sensitive in this code.
|
210
|
+
' If Acrobat was already running with PDF opened before, then closing this VB
|
211
|
+
' program will not quit Acrobat.
|
212
|
+
'
|
213
|
+
' Note that this is only a sample to show how to use Acrobat JavaScript Object in VB.
|
214
|
+
' It is not supposed to work as a complete utility tool. Further improvements are needed
|
215
|
+
' to make it to be a robust program. Now the sample finds out English words only. If you need
|
216
|
+
' it to work with other languages such as Korean, Chinese, or others, you need to localize
|
217
|
+
' the VB project to enable write, show, and handle those characters in Unicode.
|
218
|
+
'------------------------------------------------------------
|
219
|
+
|
220
|
+
'declare global variables
|
221
|
+
Dim gApp As Acrobat.CAcroApp
|
222
|
+
Dim gPdDoc As Acrobat.CAcroPDDoc
|
223
|
+
Dim gAvDoc As Acrobat.CAcroAVDoc
|
224
|
+
Dim gPDFPath As String
|
225
|
+
|
226
|
+
'flag for Acrobat.
|
227
|
+
'true:if Acrobat was already running with PDF opened before. false: otherwise
|
228
|
+
Dim gExisting As Boolean
|
229
|
+
|
230
|
+
Private Sub FindTextForm_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
|
231
|
+
|
232
|
+
Dim numOpenPDFs As Short
|
233
|
+
|
234
|
+
'Initialize Acrobat by creating App object
|
235
|
+
'If Acrobat is running, it will get the existing acrobat object.
|
236
|
+
gApp = CreateObject("AcroExch.App")
|
237
|
+
|
238
|
+
' show Acrobat
|
239
|
+
gApp.Show()
|
240
|
+
|
241
|
+
' is a PDF already open?
|
242
|
+
numOpenPDFs = gApp.GetNumAVDocs
|
243
|
+
|
244
|
+
'if there is a PDF opened, get doc object
|
245
|
+
If numOpenPDFs > 0 Then
|
246
|
+
gExisting = True
|
247
|
+
gAvDoc = gApp.GetActiveDoc
|
248
|
+
gPdDoc = gAvDoc.GetPDDoc
|
249
|
+
|
250
|
+
'show file name
|
251
|
+
pdfName.Text = gAvDoc.GetTitle
|
252
|
+
Else
|
253
|
+
gExisting = False
|
254
|
+
End If
|
255
|
+
|
256
|
+
InputText.Text = ""
|
257
|
+
LabelInfo.Text = ""
|
258
|
+
|
259
|
+
End Sub
|
260
|
+
|
261
|
+
|
262
|
+
Private Sub FindTextForm_Closed(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Closed
|
263
|
+
|
264
|
+
'End Acrobat only if it was not existing before
|
265
|
+
'or it is existing but no PDF file opened.
|
266
|
+
If Not gApp Is Nothing Then
|
267
|
+
If gExisting = False Then
|
268
|
+
gApp.CloseAllDocs()
|
269
|
+
gApp.Exit()
|
270
|
+
End If
|
271
|
+
End If
|
272
|
+
|
273
|
+
' clean
|
274
|
+
If Not gApp Is Nothing Then
|
275
|
+
System.Runtime.InteropServices.Marshal.ReleaseComObject(gApp)
|
276
|
+
gApp = Nothing
|
277
|
+
End If
|
278
|
+
If Not gPdDoc Is Nothing Then
|
279
|
+
System.Runtime.InteropServices.Marshal.ReleaseComObject(gPdDoc)
|
280
|
+
gPdDoc = Nothing
|
281
|
+
End If
|
282
|
+
If Not gAvDoc Is Nothing Then
|
283
|
+
System.Runtime.InteropServices.Marshal.ReleaseComObject(gAvDoc)
|
284
|
+
gAvDoc = Nothing
|
285
|
+
End If
|
286
|
+
|
287
|
+
End
|
288
|
+
|
289
|
+
End Sub
|
290
|
+
|
291
|
+
Private Sub CloseBtn_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CloseBtn.Click
|
292
|
+
FindTextForm_Closed(Me, New System.EventArgs())
|
293
|
+
End Sub
|
294
|
+
|
295
|
+
Private Sub OpenFileBtn_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OpenFileBtn.Click
|
296
|
+
Dim foundErr As Boolean
|
297
|
+
|
298
|
+
' open file box for user to select a PDF file
|
299
|
+
gPDFPath = vbNullString
|
300
|
+
|
301
|
+
Dim CommonDialog1 As New OpenFileDialog
|
302
|
+
|
303
|
+
CommonDialog1.Filter = "PDF Files (*.pdf)|*.pdf"
|
304
|
+
If CommonDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
|
305
|
+
gPDFPath = CommonDialog1.FileName
|
306
|
+
End If
|
307
|
+
|
308
|
+
'If a file is selected, try to open it
|
309
|
+
Dim fname As String
|
310
|
+
If Len(gPDFPath) > 0 Then
|
311
|
+
|
312
|
+
'Show acribat if it's hidden
|
313
|
+
gApp.Show()
|
314
|
+
|
315
|
+
' create PDDoc object
|
316
|
+
foundErr = False
|
317
|
+
gPdDoc = CreateObject("AcroExch.PDDoc")
|
318
|
+
|
319
|
+
' open the PDF in acrobat
|
320
|
+
If gPdDoc.Open(gPDFPath) Then
|
321
|
+
fname = gPdDoc.GetFileName
|
322
|
+
gPdDoc.OpenAVDoc(fname)
|
323
|
+
pdfName.Text = fname
|
324
|
+
Else
|
325
|
+
MsgBox("Failed to open " & gPDFPath)
|
326
|
+
End If
|
327
|
+
End If
|
328
|
+
|
329
|
+
End Sub
|
330
|
+
|
331
|
+
Private Sub FindBtn_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles FindBtn.Click
|
332
|
+
Dim inumOpenPDFs As Integer
|
333
|
+
|
334
|
+
' is a PDF already open?
|
335
|
+
inumOpenPDFs = gApp.GetNumAVDocs
|
336
|
+
|
337
|
+
'there must be a PDF file opened
|
338
|
+
If gApp.GetNumAVDocs > 0 Then
|
339
|
+
|
340
|
+
'get the Doc.
|
341
|
+
gAvDoc = gApp.GetActiveDoc
|
342
|
+
gPdDoc = gAvDoc.GetPDDoc
|
343
|
+
|
344
|
+
'show file name
|
345
|
+
pdfName.Text = gAvDoc.GetTitle
|
346
|
+
|
347
|
+
'there must be a word input.
|
348
|
+
If Len(InputText.Text) = 0 Then
|
349
|
+
MsgBox("Please input a word")
|
350
|
+
Else
|
351
|
+
'OK, go search....
|
352
|
+
FindWordJSO()
|
353
|
+
End If
|
354
|
+
Else
|
355
|
+
'warning message
|
356
|
+
pdfName.Text = ""
|
357
|
+
MsgBox("Please open a PDF file.")
|
358
|
+
End If
|
359
|
+
|
360
|
+
End Sub
|
361
|
+
|
362
|
+
|
363
|
+
Private Sub FindWordJSO()
|
364
|
+
Dim gbStop As Boolean
|
365
|
+
|
366
|
+
'local variables
|
367
|
+
Dim jso As Object
|
368
|
+
Dim nCount As Integer
|
369
|
+
Dim i, j As Integer
|
370
|
+
Dim word As String
|
371
|
+
Dim result As Integer
|
372
|
+
Dim nPages, nWords As Integer
|
373
|
+
Dim rc As Short
|
374
|
+
|
375
|
+
' get JavaScript Object
|
376
|
+
' note jso is related to PDDoc of a PDF,
|
377
|
+
jso = gPdDoc.GetJSObject
|
378
|
+
|
379
|
+
' count
|
380
|
+
nCount = 0
|
381
|
+
gbStop = False
|
382
|
+
|
383
|
+
' search for the text
|
384
|
+
If Not jso Is Nothing Then
|
385
|
+
|
386
|
+
' info
|
387
|
+
LabelInfo.Text = "Search ... "
|
388
|
+
|
389
|
+
' total number of pages
|
390
|
+
nPages = jso.numPages
|
391
|
+
|
392
|
+
' Go through pages
|
393
|
+
For i = 0 To nPages - 1
|
394
|
+
|
395
|
+
' check each word in a page
|
396
|
+
nWords = jso.getPageNumWords(i)
|
397
|
+
For j = 0 To nWords - 1
|
398
|
+
|
399
|
+
' get a word
|
400
|
+
word = jso.getPageNthWord(i, j)
|
401
|
+
If VarType(word) = VariantType.String Then
|
402
|
+
|
403
|
+
' compare the word with what the user wants
|
404
|
+
result = StrComp(word, InputText.Text, CompareMethod.Text)
|
405
|
+
|
406
|
+
' if same
|
407
|
+
If result = 0 Then
|
408
|
+
nCount = nCount + 1
|
409
|
+
rc = jso.selectPageNthWord(i, j)
|
410
|
+
|
411
|
+
' info
|
412
|
+
LabelInfo.Text = "# " & nCount & " found in page " & (i + 1)
|
413
|
+
|
414
|
+
If MsgBox("The word is found: Count " & nCount & ". Continue?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then
|
415
|
+
GoTo TheEnd
|
416
|
+
End If
|
417
|
+
|
418
|
+
' info
|
419
|
+
LabelInfo.Text = "Search ... "
|
420
|
+
LabelInfo.Refresh()
|
421
|
+
|
422
|
+
End If
|
423
|
+
End If
|
424
|
+
Next j
|
425
|
+
Next i
|
426
|
+
|
427
|
+
TheEnd:
|
428
|
+
' summary
|
429
|
+
If nCount > 0 Then
|
430
|
+
LabelInfo.Text = "Total found: " & nCount
|
431
|
+
Else
|
432
|
+
LabelInfo.Text = "Not found in the document"
|
433
|
+
End If
|
434
|
+
|
435
|
+
System.Runtime.InteropServices.Marshal.ReleaseComObject(jso)
|
436
|
+
jso = Nothing
|
437
|
+
|
438
|
+
End If
|
439
|
+
End Sub
|
440
|
+
End Class
|