我有以下代码来填充PDF文档中的组合框。据Acrobat Forms API Reference
,据我所知,代码是正确的但是在from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://www.awgp.org')
images = driver.find_elements_by_tag_name('img')
for img in images:
dimensions = img.size
width = dimensions['width']
height = dimensions['height']
print('{}x{}'.format(width, height))
调用中代码失败,并出现以下错误:
对象“ IField”的方法“ PopulateListOrComboBox”失败
PopulateListOrComboBox
此外,我还测试了这段代码以尝试填充它,但是它也因以下错误而失败:
自动化错误未指定错误
Dim acroApp As Acrobat.acroApp
Set acroApp = New Acrobat.acroApp
Dim myForm As Acrobat.AcroAVDoc
Set myForm = New Acrobat.AcroAVDoc
Dim bOK As Boolean
bOK = myForm.Open("C:\Users\sholtzman\downloads\wordFormTest.pdf", "temp")
Dim theRealForm As AFORMAUTLib.AFormApp
Set theRealForm = New AFORMAUTLib.AFormApp
Dim pdField As AFORMAUTLib.Field
Set pdField = theRealForm.Fields.Add("triaCoverage", "combobox", 0, 10, 20, 100, 200)
Dim items(2) As String
items(0) = " "
items(1) = "Accept"
items(2) = "Reject"
pdField.PopulateListOrComboBox items
最后,当我在添加组合框后保存并关闭文档时,可以进入 并手动设置列表值。有什么想法可以让我通过代码工作吗?
答案 0 :(得分:0)
我进行了更多研究,并通过替换该行找到了一个答案:
jso.getField("triaCoverage").setItems(1) = " "
与
jso.getField("triaCoverage").setItems(items)
但是,如果可能的话,我更喜欢使用PopulateListOrComboBox方法,因此我将在一段时间内不回答该问题。