acrobat 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop/minitest.yml +2 -0
- data/.rubocop/strict.yml +4 -0
- data/.rubocop.yml +23 -0
- 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} +3 -4
- data/README.md +107 -0
- data/Rakefile +6 -54
- 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/exe/acrobat +3 -0
- data/gemfiles/rubocop.gemfile +6 -0
- data/lib/acrobat/app.rb +197 -187
- data/lib/acrobat/avdoc.rb +22 -0
- data/lib/acrobat/jso.rb +87 -94
- data/lib/acrobat/pdoc.rb +155 -137
- data/lib/acrobat/version.rb +5 -0
- data/lib/acrobat.rb +5 -44
- data/rbs_collection.yaml +19 -0
- data/samples_other/background.js +40 -0
- data/samples_other/find_word.vb +440 -0
- data/samples_other/form.vb +393 -0
- data/sig/generated/acrobat/app.rbs +94 -0
- data/sig/generated/acrobat/avdoc.rbs +15 -0
- data/sig/generated/acrobat/jso.rbs +37 -0
- data/sig/generated/acrobat/pdoc.rbs +63 -0
- data/sig/generated/acrobat/version.rbs +5 -0
- data/sig/generated/acrobat.rbs +6 -0
- data/sig/prototype/lib/acrobat/app.rbs +3 -0
- data/sig/prototype/lib/acrobat/jso.rbs +5 -0
- data/sig/prototype/lib/acrobat/pdoc.rbs +5 -0
- data/vba/overlay.vba +40 -0
- metadata +45 -180
- data/.gitignore +0 -32
- data/History.adoc +0 -6
- data/Manifest.txt +0 -14
- data/README.adoc +0 -117
- data/bin/acrobat +0 -3
- data/test/acrobat_test.rb +0 -36
- data/test/test_helper.rb +0 -13
@@ -0,0 +1,393 @@
|
|
1
|
+
Option Strict Off
|
2
|
+
Option Explicit On
|
3
|
+
Friend Class FormsAutomation
|
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 ExitButton As System.Windows.Forms.Button
|
37
|
+
Public WithEvents StatusBox As System.Windows.Forms.TextBox
|
38
|
+
Public WithEvents CreateFieldsButton As System.Windows.Forms.Button
|
39
|
+
Public WithEvents StatusLabel As System.Windows.Forms.Label
|
40
|
+
'NOTE: The following procedure is required by the Windows Form Designer
|
41
|
+
'It can be modified using the Windows Form Designer.
|
42
|
+
'Do not modify it using the code editor.
|
43
|
+
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
|
44
|
+
Me.components = New System.ComponentModel.Container
|
45
|
+
Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
|
46
|
+
Me.ExitButton = New System.Windows.Forms.Button
|
47
|
+
Me.StatusBox = New System.Windows.Forms.TextBox
|
48
|
+
Me.CreateFieldsButton = New System.Windows.Forms.Button
|
49
|
+
Me.StatusLabel = New System.Windows.Forms.Label
|
50
|
+
Me.SuspendLayout()
|
51
|
+
'
|
52
|
+
'ExitButton
|
53
|
+
'
|
54
|
+
Me.ExitButton.BackColor = System.Drawing.SystemColors.Control
|
55
|
+
Me.ExitButton.Cursor = System.Windows.Forms.Cursors.Default
|
56
|
+
Me.ExitButton.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
57
|
+
Me.ExitButton.ForeColor = System.Drawing.SystemColors.ControlText
|
58
|
+
Me.ExitButton.Location = New System.Drawing.Point(152, 15)
|
59
|
+
Me.ExitButton.Name = "ExitButton"
|
60
|
+
Me.ExitButton.RightToLeft = System.Windows.Forms.RightToLeft.No
|
61
|
+
Me.ExitButton.Size = New System.Drawing.Size(113, 25)
|
62
|
+
Me.ExitButton.TabIndex = 3
|
63
|
+
Me.ExitButton.Text = "Exit"
|
64
|
+
Me.ExitButton.UseVisualStyleBackColor = False
|
65
|
+
'
|
66
|
+
'StatusBox
|
67
|
+
'
|
68
|
+
Me.StatusBox.AcceptsReturn = True
|
69
|
+
Me.StatusBox.BackColor = System.Drawing.SystemColors.ButtonFace
|
70
|
+
Me.StatusBox.Cursor = System.Windows.Forms.Cursors.IBeam
|
71
|
+
Me.StatusBox.Enabled = False
|
72
|
+
Me.StatusBox.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
73
|
+
Me.StatusBox.ForeColor = System.Drawing.SystemColors.WindowText
|
74
|
+
Me.StatusBox.Location = New System.Drawing.Point(64, 56)
|
75
|
+
Me.StatusBox.MaxLength = 0
|
76
|
+
Me.StatusBox.Name = "StatusBox"
|
77
|
+
Me.StatusBox.ReadOnly = True
|
78
|
+
Me.StatusBox.RightToLeft = System.Windows.Forms.RightToLeft.No
|
79
|
+
Me.StatusBox.Size = New System.Drawing.Size(200, 19)
|
80
|
+
Me.StatusBox.TabIndex = 1
|
81
|
+
'
|
82
|
+
'CreateFieldsButton
|
83
|
+
'
|
84
|
+
Me.CreateFieldsButton.BackColor = System.Drawing.SystemColors.Control
|
85
|
+
Me.CreateFieldsButton.Cursor = System.Windows.Forms.Cursors.Default
|
86
|
+
Me.CreateFieldsButton.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
87
|
+
Me.CreateFieldsButton.ForeColor = System.Drawing.SystemColors.ControlText
|
88
|
+
Me.CreateFieldsButton.Location = New System.Drawing.Point(16, 15)
|
89
|
+
Me.CreateFieldsButton.Name = "CreateFieldsButton"
|
90
|
+
Me.CreateFieldsButton.RightToLeft = System.Windows.Forms.RightToLeft.No
|
91
|
+
Me.CreateFieldsButton.Size = New System.Drawing.Size(113, 25)
|
92
|
+
Me.CreateFieldsButton.TabIndex = 0
|
93
|
+
Me.CreateFieldsButton.Text = "Create Fields"
|
94
|
+
Me.CreateFieldsButton.UseVisualStyleBackColor = False
|
95
|
+
'
|
96
|
+
'StatusLabel
|
97
|
+
'
|
98
|
+
Me.StatusLabel.BackColor = System.Drawing.SystemColors.Control
|
99
|
+
Me.StatusLabel.Cursor = System.Windows.Forms.Cursors.Default
|
100
|
+
Me.StatusLabel.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
101
|
+
Me.StatusLabel.ForeColor = System.Drawing.SystemColors.ControlText
|
102
|
+
Me.StatusLabel.Location = New System.Drawing.Point(16, 58)
|
103
|
+
Me.StatusLabel.Name = "StatusLabel"
|
104
|
+
Me.StatusLabel.RightToLeft = System.Windows.Forms.RightToLeft.No
|
105
|
+
Me.StatusLabel.Size = New System.Drawing.Size(40, 17)
|
106
|
+
Me.StatusLabel.TabIndex = 2
|
107
|
+
Me.StatusLabel.Text = "Status:"
|
108
|
+
'
|
109
|
+
'FormsAutomation
|
110
|
+
'
|
111
|
+
Me.AcceptButton = Me.ExitButton
|
112
|
+
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
|
113
|
+
Me.BackColor = System.Drawing.SystemColors.Control
|
114
|
+
Me.ClientSize = New System.Drawing.Size(281, 89)
|
115
|
+
Me.Controls.Add(Me.ExitButton)
|
116
|
+
Me.Controls.Add(Me.StatusBox)
|
117
|
+
Me.Controls.Add(Me.CreateFieldsButton)
|
118
|
+
Me.Controls.Add(Me.StatusLabel)
|
119
|
+
Me.Cursor = System.Windows.Forms.Cursors.Default
|
120
|
+
Me.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
121
|
+
Me.Location = New System.Drawing.Point(11, 30)
|
122
|
+
Me.MaximizeBox = False
|
123
|
+
Me.Name = "FormsAutomation"
|
124
|
+
Me.RightToLeft = System.Windows.Forms.RightToLeft.No
|
125
|
+
Me.Text = "Acrobat Forms Automation Demo"
|
126
|
+
Me.ResumeLayout(False)
|
127
|
+
|
128
|
+
End Sub
|
129
|
+
#End Region
|
130
|
+
#Region "Upgrade Support "
|
131
|
+
Private Shared m_vb6FormDefInstance As FormsAutomation
|
132
|
+
Private Shared m_InitializingDefInstance As Boolean
|
133
|
+
Public Shared Property DefInstance() As FormsAutomation
|
134
|
+
Get
|
135
|
+
If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
|
136
|
+
m_InitializingDefInstance = True
|
137
|
+
m_vb6FormDefInstance = New FormsAutomation()
|
138
|
+
m_InitializingDefInstance = False
|
139
|
+
End If
|
140
|
+
DefInstance = m_vb6FormDefInstance
|
141
|
+
End Get
|
142
|
+
Set
|
143
|
+
m_vb6FormDefInstance = Value
|
144
|
+
End Set
|
145
|
+
End Property
|
146
|
+
#End Region
|
147
|
+
|
148
|
+
' ADOBE SYSTEMS INCORPORATED
|
149
|
+
' Copyright (C) 1994-2003 Adobe Systems Incorporated
|
150
|
+
' All rights reserved.
|
151
|
+
'
|
152
|
+
' NOTICE: Adobe permits you to use, modify, and distribute this file
|
153
|
+
' in accordance with the terms of the Adobe license agreement
|
154
|
+
' accompanying it. If you have received this file from a source other
|
155
|
+
' than Adobe, then your use, modification, or distribution of it
|
156
|
+
' requires the prior written permission of Adobe.
|
157
|
+
'
|
158
|
+
' -------------------------------------------------------------------
|
159
|
+
'
|
160
|
+
' FormsAutomation.vbp
|
161
|
+
'
|
162
|
+
' - The application shows how to add Text boxes, combo boxes, radio
|
163
|
+
' buttons and action buttons to a PDF. In this case, the PDF is
|
164
|
+
' empty and we are adding form fields to it.
|
165
|
+
'
|
166
|
+
' - To run the sample:
|
167
|
+
'
|
168
|
+
' Run the sample and click on the Create Fields button. The
|
169
|
+
' sample will open the IAC\TestFiles\FormsAutomation.pdf file
|
170
|
+
' in Acrobat and add form fields to it.
|
171
|
+
|
172
|
+
|
173
|
+
Dim formApp As AFORMAUTLib.AFormApp
|
174
|
+
Dim acroForm As AFORMAUTLib.Fields
|
175
|
+
Dim field As AFORMAUTLib.Field
|
176
|
+
Dim bOK As Boolean
|
177
|
+
Dim avDoc As Acrobat.CAcroAVDoc
|
178
|
+
Dim pdDoc As Acrobat.CAcroPDDoc
|
179
|
+
Dim radiobuttonArray(5) As String
|
180
|
+
|
181
|
+
Private Sub CreateFieldsButton_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CreateFieldsButton.Click
|
182
|
+
|
183
|
+
'Set the mouse icon to display an hourglass
|
184
|
+
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
|
185
|
+
|
186
|
+
'Disable the create fields button
|
187
|
+
CreateFieldsButton.Enabled = False
|
188
|
+
|
189
|
+
'Update the status box
|
190
|
+
StatusBox.Text = "Opening PDF Document..."
|
191
|
+
|
192
|
+
' Open the sample PDF file
|
193
|
+
avDoc = CreateObject("AcroExch.AVDoc")
|
194
|
+
Dim file As String = System.Windows.Forms.Application.StartupPath & "\..\..\..\..\TestFiles\FormsAutomation.pdf"
|
195
|
+
|
196
|
+
bOK = avDoc.Open(file, "Forms Automation Demo")
|
197
|
+
|
198
|
+
'If everything was OK opening the PDF, we now instantiate the Forms
|
199
|
+
'Automation object.
|
200
|
+
If (bOK) Then
|
201
|
+
formApp = CreateObject("AFormAut.App")
|
202
|
+
acroForm = formApp.Fields
|
203
|
+
Else
|
204
|
+
System.Runtime.InteropServices.Marshal.ReleaseComObject(avDoc)
|
205
|
+
avDoc = Nothing
|
206
|
+
MsgBox("Failed to open PDF Document. Aborting...")
|
207
|
+
End
|
208
|
+
End If
|
209
|
+
|
210
|
+
'Update the status box
|
211
|
+
StatusBox.Text = "Creating Form Fields..."
|
212
|
+
|
213
|
+
'Add a Text Field to the PDF
|
214
|
+
' Fields.Add takes seven parameters:
|
215
|
+
' FieldName is the The fully-qualified name of the field.
|
216
|
+
' FieldType is the field type for the newly created field. Valid types are:
|
217
|
+
' "text", "button", "combobox", "listbox", "checkbox", "radiobutton".
|
218
|
+
' You must spell the field type names exactly as shown, including
|
219
|
+
' use the quotation marks.
|
220
|
+
' PageNum is the zero-based page number to add the field to.
|
221
|
+
' Left A float for the left most position of the rectangle placement.
|
222
|
+
' Top A float for the top of the rectangle placement.
|
223
|
+
' Right A float for the right most position of the rectangle placement.
|
224
|
+
' Bottom A float for the bottom of the rectangle placement.
|
225
|
+
field = acroForm.Add("Name", "text", 0, 100, 650, 450, 675)
|
226
|
+
|
227
|
+
'Next use Field.SetBorderColor to set the color of the fields borders in
|
228
|
+
'Gray scale, Transparent, RGB or CMYK color. All values are floating point numbers
|
229
|
+
'between 0 and 1. In the example below, we are using RGB color space. So the last
|
230
|
+
'parameter is set to "0"
|
231
|
+
field.SetBorderColor("RGB", 0.7, 0.5, 0.3, 0)
|
232
|
+
|
233
|
+
'Field.TextSize sets the font size of the field. You can also use Field.TextFont
|
234
|
+
'to use a specific font. See the Acrobat Forms API Reference for more information
|
235
|
+
'on various font names.
|
236
|
+
field.TextSize = CShort("12")
|
237
|
+
'field.TextFont = "Times-Roman"
|
238
|
+
|
239
|
+
'You can use Field.DefaultValue to set the default value of a field.
|
240
|
+
field.DefaultValue = "Enter your full name here"
|
241
|
+
|
242
|
+
'Create a date field formatted to be "mm/dd/yyyy". The SetJavaScriptAction
|
243
|
+
'method sets the keystoke and format properties to the proper date format
|
244
|
+
'using JavaScript
|
245
|
+
field = acroForm.Add("Creation Date", "text", 0, 375, 680, 450, 715)
|
246
|
+
field.SetBorderColor("RGB", 0.7, 0.5, 0.3, 0)
|
247
|
+
field.TextSize = CShort("12")
|
248
|
+
field.DefaultValue = "01/01/2000"
|
249
|
+
field.SetJavaScriptAction("keystroke", "AFDate_KeystrokeEx(""mm/dd/yyyy"");")
|
250
|
+
field.SetJavaScriptAction("format", "AFDate_FormatEx(""mm/dd/yyyy"");")
|
251
|
+
|
252
|
+
'Now add a few more fields for address, city, state, zip code. The zip code
|
253
|
+
'field introduces a new functionality - using JavaScript to format the
|
254
|
+
'field values.
|
255
|
+
field = acroForm.Add("Address", "text", 0, 100, 620, 450, 645)
|
256
|
+
field.SetBorderColor("RGB", 0.7, 0.5, 0.3, 0)
|
257
|
+
field.TextSize = CShort("12")
|
258
|
+
field.DefaultValue = "Enter your address here"
|
259
|
+
|
260
|
+
field = acroForm.Add("City", "text", 0, 100, 590, 345, 615)
|
261
|
+
field.SetBorderColor("RGB", 0.7, 0.5, 0.3, 0)
|
262
|
+
field.TextSize = CShort("12")
|
263
|
+
field.DefaultValue = "Enter your City"
|
264
|
+
|
265
|
+
field = acroForm.Add("State", "text", 0, 350, 590, 375, 615)
|
266
|
+
field.SetBorderColor("RGB", 0.7, 0.5, 0.3, 0)
|
267
|
+
field.TextSize = CShort("12")
|
268
|
+
field.DefaultValue = "CA"
|
269
|
+
|
270
|
+
field = acroForm.Add("Zip", "text", 0, 385, 590, 450, 615)
|
271
|
+
field.SetBorderColor("RGB", 0.7, 0.5, 0.3, 0)
|
272
|
+
field.TextSize = CShort("12")
|
273
|
+
field.DefaultValue = "99999"
|
274
|
+
field.SetJavaScriptAction("keystroke", "AFSpecial_Keystroke(0);")
|
275
|
+
field.SetJavaScriptAction("format", "AFSpecial_Format(0);")
|
276
|
+
|
277
|
+
'To create a series of radio buttons. Create the field, then call
|
278
|
+
'Fields.Add again to create the children
|
279
|
+
field = acroForm.Add("Radio", "radiobutton", 0, 150, 500, 165, 515)
|
280
|
+
field.SetBorderColor("RGB", 0.75, 0.55, 0.35, 0)
|
281
|
+
|
282
|
+
field = acroForm.Add("Radio", "radiobutton", 0, 180, 500, 195, 515)
|
283
|
+
field.SetBorderColor("RGB", 0.75, 0.55, 0.35, 0)
|
284
|
+
|
285
|
+
field = acroForm.Add("Radio", "radiobutton", 0, 210, 500, 225, 515)
|
286
|
+
field.SetBorderColor("RGB", 0.75, 0.55, 0.35, 0)
|
287
|
+
|
288
|
+
field = acroForm.Add("Radio", "radiobutton", 0, 240, 500, 255, 515)
|
289
|
+
field.SetBorderColor("RGB", 0.75, 0.55, 0.35, 0)
|
290
|
+
|
291
|
+
field = acroForm.Add("Radio", "radiobutton", 0, 270, 500, 285, 515)
|
292
|
+
field.SetBorderColor("RGB", 0.75, 0.55, 0.35, 0)
|
293
|
+
|
294
|
+
'Build an array then call SetExportValues
|
295
|
+
radiobuttonArray(0) = "Red"
|
296
|
+
radiobuttonArray(1) = "Green"
|
297
|
+
radiobuttonArray(2) = "Blue"
|
298
|
+
radiobuttonArray(3) = "Yellow"
|
299
|
+
radiobuttonArray(4) = "Black"
|
300
|
+
radiobuttonArray(5) = "White"
|
301
|
+
field.SetExportValues(radiobuttonArray)
|
302
|
+
|
303
|
+
'Create a list box. This section of code will create a list box on the
|
304
|
+
'PDF and populate the list box with items.
|
305
|
+
field = acroForm.Add("My Combo Box", "combobox", 0, 100, 450, 380, 475)
|
306
|
+
field.SetBorderColor("RGB", 0.75, 0.55, 0.35, 0)
|
307
|
+
field.TextSize = CShort("12")
|
308
|
+
|
309
|
+
'Now that the list box is complete, let's build two arrays that
|
310
|
+
'will be used to populate the list box.
|
311
|
+
'First is an array of items that will be displayed to the user
|
312
|
+
Dim arrayOfItems(4) As String
|
313
|
+
arrayOfItems(0) = "[Choose an item from the list]"
|
314
|
+
arrayOfItems(1) = "Bird"
|
315
|
+
arrayOfItems(2) = "Cat"
|
316
|
+
arrayOfItems(3) = "Dog"
|
317
|
+
arrayOfItems(4) = "Gold Fish"
|
318
|
+
|
319
|
+
'Then the exported value that will come back in the FDF
|
320
|
+
Dim arrayOfExportValues(4) As String
|
321
|
+
arrayOfExportValues(0) = "X"
|
322
|
+
arrayOfExportValues(1) = "a"
|
323
|
+
arrayOfExportValues(2) = "b"
|
324
|
+
arrayOfExportValues(3) = "c"
|
325
|
+
arrayOfExportValues(4) = "d"
|
326
|
+
|
327
|
+
'Next, use the PopulateListOrComboBox method to add values into the
|
328
|
+
'combo box
|
329
|
+
field.PopulateListOrComboBox(arrayOfItems, arrayOfExportValues)
|
330
|
+
|
331
|
+
'Now, create a new submit button for the user to click on. Set the border
|
332
|
+
'style, the button caption, the color of the background. Field.Highlight sets
|
333
|
+
'the property of the button to look like it was pushed in.
|
334
|
+
field = acroForm.Add("Submit Button", "button", 0, 100, 50, 150, 100)
|
335
|
+
field.BorderStyle = "beveled"
|
336
|
+
field.SetButtonCaption("N", "Submit")
|
337
|
+
field.SetBackgroundColor("G", 0.85, 0.85, 0, 0)
|
338
|
+
field.Highlight = "push"
|
339
|
+
|
340
|
+
'Set the SubmitForm action to point to a web server.
|
341
|
+
field.SetSubmitFormAction("up", "http://your-webserver.com/cgi-bin/myscript", 0)
|
342
|
+
|
343
|
+
'Create a reset button just in case users want to change there minds a
|
344
|
+
'reset all the fields on the newly created PDF.
|
345
|
+
field = acroForm.Add("Reset Button", "button", 0, 175, 50, 225, 100)
|
346
|
+
field.BorderStyle = "beveled"
|
347
|
+
field.SetButtonCaption("N", "Reset")
|
348
|
+
field.SetBackgroundColor("G", 0.85, 0.85, 0, 0)
|
349
|
+
field.Highlight = "push"
|
350
|
+
'Set the ResetForm action for the button.
|
351
|
+
field.SetResetFormAction("up", 0)
|
352
|
+
|
353
|
+
'Update the Status box.
|
354
|
+
StatusBox.Text = "Fields have been added successfully."
|
355
|
+
|
356
|
+
'This section converts a AVDoc to a PDDoc. Then we use PDDoc.Save to
|
357
|
+
'save the PDF since there isn't a viewer level method to save an AVDoc.
|
358
|
+
|
359
|
+
'These lines are commented out to provide user feedback
|
360
|
+
'If present, no doc is visible and original form is changed
|
361
|
+
'so it isn't obvious what the sample did, and it doesn't work
|
362
|
+
'twice in a row.
|
363
|
+
'It's best to have Acrobat open and visible to see form creation
|
364
|
+
'''''''''
|
365
|
+
'Set pdDoc = avDoc.GetPDDoc
|
366
|
+
'bOK = pdDoc.Save(1, "C:\FormsAutomation.pdf")
|
367
|
+
'If bOK = False Then
|
368
|
+
'MsgBox "Unable to Save the PDF file"
|
369
|
+
'End If
|
370
|
+
|
371
|
+
' Close the AVDoc
|
372
|
+
'avDoc.Close (False)
|
373
|
+
'''''''''
|
374
|
+
'End provide User Feedback
|
375
|
+
|
376
|
+
CleanUp:
|
377
|
+
'Change the mouse pointer to display normal cursor and enable the Exit button
|
378
|
+
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
|
379
|
+
|
380
|
+
'Enable the create fields button
|
381
|
+
CreateFieldsButton.Enabled = True
|
382
|
+
End Sub
|
383
|
+
|
384
|
+
Private Sub ExitButton_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles ExitButton.Click
|
385
|
+
' End the program
|
386
|
+
End
|
387
|
+
|
388
|
+
End Sub
|
389
|
+
|
390
|
+
Private Sub FormsAutomation_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
391
|
+
StatusBox.Text = "Click Create Fields Button..."
|
392
|
+
End Sub
|
393
|
+
End Class
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# Generated from lib/acrobat/app.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Acrobat
|
4
|
+
class FileNotFound < StandardError
|
5
|
+
def initialize: (untyped path) -> untyped
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module FileSystemObject
|
10
|
+
def self.instance: () -> untyped
|
11
|
+
|
12
|
+
def self.windows_path: (untyped path) -> untyped
|
13
|
+
end
|
14
|
+
|
15
|
+
module ACRO
|
16
|
+
end
|
17
|
+
|
18
|
+
module Acrobat
|
19
|
+
class App
|
20
|
+
# [WIN32_OLE] ole_obj
|
21
|
+
attr_reader ole_obj: untyped
|
22
|
+
|
23
|
+
def initialize: () -> untyped
|
24
|
+
|
25
|
+
def self.close: (untyped path) -> untyped
|
26
|
+
|
27
|
+
# Runs the adobe app and quits at the end
|
28
|
+
# @example
|
29
|
+
# Acrobat::App.run do |app|
|
30
|
+
# doc = app.open('doc.pdf')
|
31
|
+
# doc.fill_form( city: 'City', state: 'ST')
|
32
|
+
# doc.save_as('filled.pdf')
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# @rbs return Void
|
36
|
+
def self.run: () -> Void
|
37
|
+
|
38
|
+
def self.replace_pages: (untyped pdf_file, untyped replacement, output_name: untyped, **untyped opts) -> untyped
|
39
|
+
|
40
|
+
# Fills the form with updates in a hash
|
41
|
+
# @example
|
42
|
+
# Acrobat::App.fill_form(myform.pdf, output_name: 'filled.pdf
|
43
|
+
# , update_hash: { name: 'dom', filled_date: 1/20/2013
|
44
|
+
# @rbs pdf_form: String -- the String path of a fillable pdf file
|
45
|
+
# @rbs output_name: String -- the name of the saved filled pdf file
|
46
|
+
# @rbs update_hash: Hash -- the hash with updates
|
47
|
+
def self.fill_form: (String pdf_form, output_name: String, update_hash: Hash) -> untyped
|
48
|
+
|
49
|
+
# @rbs return Array[AvDoc]
|
50
|
+
# @rbs &: (AvDoc) -> Void
|
51
|
+
def avdocs: () { (AvDoc) -> Void } -> Array[AvDoc]
|
52
|
+
|
53
|
+
# show the Adobe Acrobat application
|
54
|
+
def show: () -> untyped
|
55
|
+
|
56
|
+
# hide the Adobe Acrobat application
|
57
|
+
def hide: () -> untyped
|
58
|
+
|
59
|
+
# Finds the pdfs in a dir
|
60
|
+
# @rbs dir: String -- the directory to find pdfs in
|
61
|
+
# @rbs return Array[Pathname] -- of pdf files
|
62
|
+
def find_pdfs_in_dir: (String dir) -> Array[Pathname]
|
63
|
+
|
64
|
+
def merge_pdfs: (*untyped pdfs) -> untyped
|
65
|
+
|
66
|
+
# merges the pdfs in directory
|
67
|
+
# @rbs dir: String -- the path of the directory
|
68
|
+
# @rbs name: String | Nil -- the name of the returned pdf file
|
69
|
+
# if the name is nil, the name is "merged.pdf"
|
70
|
+
# @rbs output_dir: String | Nil -- the name of the output dir
|
71
|
+
# if the output_dir is nil, the output dir is the dir param
|
72
|
+
# return [Boolean] if the merge was successful or not
|
73
|
+
def merge_pdfs_in_dir: (String dir, ?name: String | Nil, ?output_dir: String | Nil) -> untyped
|
74
|
+
|
75
|
+
# quit the Adobe App.
|
76
|
+
# closes the open adobe documents and quits the program
|
77
|
+
# @rbs return nil
|
78
|
+
def quit: () -> nil
|
79
|
+
|
80
|
+
attr_reader docs: untyped
|
81
|
+
|
82
|
+
# open the file.
|
83
|
+
# @rbs file: String | Pathname -- #to_path
|
84
|
+
# @rbs &: (PDoc) -> Nil
|
85
|
+
# @rbs return PDoc -- the open file as a Pdoc instance
|
86
|
+
def open: (String | Pathname file) { (PDoc) -> Nil } -> PDoc
|
87
|
+
|
88
|
+
def form: () -> untyped
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def load_constants: (untyped ole_obj) -> untyped
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Generated from lib/acrobat/avdoc.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Acrobat
|
4
|
+
class AvDoc
|
5
|
+
attr_reader ole_obj: WIN32OLE
|
6
|
+
|
7
|
+
attr_reader pdoc_name: String
|
8
|
+
|
9
|
+
def initialize: (untyped ole) -> untyped
|
10
|
+
|
11
|
+
# Close the AvDoc
|
12
|
+
# @rbs save: Boolean -- if true asks to save if false closes without saving
|
13
|
+
def close: (?Boolean save) -> untyped
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Generated from lib/acrobat/jso.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Acrobat
|
4
|
+
class Jso
|
5
|
+
attr_reader doc: untyped
|
6
|
+
|
7
|
+
attr_reader ole_obj: untyped
|
8
|
+
|
9
|
+
def initialize: (untyped doc, untyped ole) -> untyped
|
10
|
+
|
11
|
+
def find_field: (untyped name_or_number) -> untyped
|
12
|
+
|
13
|
+
def ole_get_field: (untyped field) -> untyped
|
14
|
+
|
15
|
+
def console: () -> untyped
|
16
|
+
|
17
|
+
def show_console: () -> untyped
|
18
|
+
|
19
|
+
def field_names: () -> untyped
|
20
|
+
|
21
|
+
def export_as_fdf: (untyped name) -> untyped
|
22
|
+
|
23
|
+
def import_fdf: (untyped path) -> untyped
|
24
|
+
|
25
|
+
def fields_hash: () -> untyped
|
26
|
+
|
27
|
+
def set_field: (untyped name, untyped value) -> untyped
|
28
|
+
|
29
|
+
def get_field: (untyped name) -> untyped
|
30
|
+
|
31
|
+
def field_count: () -> untyped
|
32
|
+
|
33
|
+
def clear_form: () -> untyped
|
34
|
+
|
35
|
+
def fill_form: (untyped hash) -> untyped
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Generated from lib/acrobat/pdoc.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Acrobat
|
4
|
+
class PDoc
|
5
|
+
attr_reader ole_obj: untyped
|
6
|
+
|
7
|
+
attr_reader path: Path | Nil
|
8
|
+
|
9
|
+
def self.from_path: (untyped path) -> untyped
|
10
|
+
|
11
|
+
def initialize: (untyped ole, ?untyped path) -> untyped
|
12
|
+
|
13
|
+
def show: (?untyped name) -> untyped
|
14
|
+
|
15
|
+
# @rbs return Fixnum -- the number of pages in the pdf
|
16
|
+
def page_count: () -> Fixnum
|
17
|
+
|
18
|
+
def last_page: () -> untyped
|
19
|
+
|
20
|
+
# merges the doc to the
|
21
|
+
# @rbs doc: PDoc|String|Pathname -- an open PDoc to merge or filename
|
22
|
+
# @rbs return Boolean -- whether the doc was merged correctly
|
23
|
+
def merge: (PDoc | String | Pathname doc) -> Boolean
|
24
|
+
|
25
|
+
# opens and/or returns PDoc
|
26
|
+
# @rbs doc: String|Pathname|Pdoc -- the String path of a pdf file
|
27
|
+
def open_ole_pdoc: (String | Pathname | Pdoc doc) -> untyped
|
28
|
+
|
29
|
+
def fill_and_save: (untyped results, ?name: untyped, ?dir: untyped) -> untyped
|
30
|
+
|
31
|
+
def prepend_pages: (src_path: untyped, ?src_page_start: untyped, ?src_page_end: untyped) -> untyped
|
32
|
+
|
33
|
+
# returns [Pathname] of d
|
34
|
+
# @rbs dir: [String, Nil] the String path
|
35
|
+
# @rbs return dir [Pathname] Pathname of dir or of working directory
|
36
|
+
def default_dir: ([ String, Nil ] dir) -> dir[Pathname]
|
37
|
+
|
38
|
+
def save_as: (untyped name, ?dir: untyped) -> untyped
|
39
|
+
|
40
|
+
def name: () -> untyped
|
41
|
+
|
42
|
+
def close: () -> untyped
|
43
|
+
|
44
|
+
def replace_pages: (untyped doc, ?start: untyped, ?replace_start: untyped, ?num_of_pages: untyped, ?merge_annotations: untyped) -> untyped
|
45
|
+
|
46
|
+
# return the instance of JSO object
|
47
|
+
# @rbs return [Jso] a WIN32OLE wrapped Jso object 'javascript object'
|
48
|
+
def jso: () -> [ Jso ]
|
49
|
+
|
50
|
+
# return the field_names of the pdf form
|
51
|
+
def field_names: () -> untyped
|
52
|
+
|
53
|
+
def fill_form: (untyped results) -> untyped
|
54
|
+
|
55
|
+
def ole_insert_pages: (untyped merge_doc, ?self_start_page: untyped, ?merge_doc_page_start: untyped, ?number_pages: untyped, ?bookmarks: untyped) -> untyped
|
56
|
+
|
57
|
+
def ole_replace_pages: (untyped merge_doc, ?self_start_page: untyped, ?merge_doc_page_start: untyped, ?number_pages: untyped, ?bookmarks: untyped) -> untyped
|
58
|
+
|
59
|
+
def insert_pages: (src: untyped, ?insert_after: untyped, ?src_page_start: untyped, ?src_page_end: untyped) -> untyped
|
60
|
+
|
61
|
+
def merge_pdoc: (untyped doc, **untyped options) -> untyped
|
62
|
+
end
|
63
|
+
end
|
data/vba/overlay.vba
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
Private Function ApplyBackgroundToPDF(BasePDF As String, BackgroundPDF As String)
|
2
|
+
Dim pdDoc As Acrobat.CAcroPDDoc
|
3
|
+
Dim pdTemplate As Acrobat.CAcroPDDoc
|
4
|
+
Dim template As Variant
|
5
|
+
Dim lngPage As Long
|
6
|
+
|
7
|
+
'Open base document
|
8
|
+
Set pdDoc = CreateObject("AcroExch.PDDoc")
|
9
|
+
pdDoc.Open BasePDF
|
10
|
+
DoEvents
|
11
|
+
|
12
|
+
'Open background document
|
13
|
+
Set pdTemplate = CreateObject("AcroExch.PDDoc")
|
14
|
+
pdTemplate.Open BackgroundPDF
|
15
|
+
DoEvents
|
16
|
+
|
17
|
+
'Add background document to base document
|
18
|
+
pdDoc.InsertPages pdDoc.GetNumPages - 1, pdTemplate, 0, 1, 0
|
19
|
+
|
20
|
+
'Create a template from the inserted background document
|
21
|
+
Set template = pdDoc.GetJSObject.CreateTemplate("background", pdDoc.GetNumPages - 1)
|
22
|
+
|
23
|
+
'Place the template as a background to all pages
|
24
|
+
For lngPage = 0 To pdDoc.GetNumPages - 2
|
25
|
+
template.Spawn lngPage, True, True
|
26
|
+
Next
|
27
|
+
|
28
|
+
'Delete last page (used for template creation purposes only)
|
29
|
+
pdDoc.DeletePages pdDoc.GetNumPages - 1, pdDoc.GetNumPages - 1
|
30
|
+
|
31
|
+
'Save
|
32
|
+
pdDoc.Save 1, BasePDF
|
33
|
+
|
34
|
+
'Close & Destroy Objects
|
35
|
+
pdDoc.Close
|
36
|
+
Set pdDoc = Nothing
|
37
|
+
|
38
|
+
pdTemplate.Close
|
39
|
+
Set pdTemplate = Nothing
|
40
|
+
End Function
|