Copy link to clipboard
Copied
Hi everyone.
I'm attempting to prepopulate an IRS Form 1041 for a population. I am able to populate the text fields fine, but the checkboxes show as checked but when the form is saved the checked box doesn't persist.
Private Sub Command8_Click()
Dim FileNm As String
Dim FileNm2 As String
Dim aApp As Acrobat.AcroApp
Dim aAVDoc As Acrobat.AcroAVDoc
Dim aPDDoc As Acrobat.AcroPDDoc
Dim JSO As Object 'There is no explicit class type for the JSObject
FileNm = "\\its\fss\Plans\PEO-MEP\RichAnthony\EditPDF\IRS Form 1041_2023.pdf"
FileNm2 = "\\its\fss\Plans\PEO-MEP\RichAnthony\EditPDF\1041_Reports2\"
Set aApp = CreateObject("AcroExch.App")
Set aAVDoc = CreateObject("AcroExch.AVDoc")
If aAVDoc.Open(FileNm, "") Then
Set aPDDoc = aAVDoc.GetPDDoc()
Set JSO = aPDDoc.GetJSObject()
'Debugging - output all fields
' For i = 0 To JSO.numFields - 1
' Set Field = JSO.getField(JSO.getNthFieldName(i))
' Debug.Print i, Field.Name, Field.Value, Field.Type, Field.Page
' Next
' MsgBox "This is a pause."
'Create Result set
Dim rs As Object, strSql As String, GroupAccount As String
Dim FilePath As String, FileName As String, Criteria As String
Dim xFilePrefix As String
Dim xBegDate As String
Dim xEndDate As String
Dim xYrEnd As String
Dim xPlanName As String
Dim xTrustCompany As String
Dim xTrustCompanyaddress1 As String
Dim xTrustCompanyaddress2 As String
Dim xOTC_EFF_DATE As String
Dim xEIN As String
Dim xFiduciaryEIN As String
xBegDate = "JANUARY 01"
xEndDate = "DECEMBER 31"
xYtEnd = "23"
xTrustCompany = "EMPOWER TRUST COMPANY LLC"
xTrustCompanyaddress1 = "8525 E. ORCHARD RD 8T3"
xTrustCompanyaddress2 = "GREENWOOD VILLAGE, CO 80111-5002"
xFiduciaryEIN = "84-1455663"
xFilePrefix = "IRS 1041 "
'FilePath = SelectFolder & "\" This will be used to navigate to where the 1041 output will be dropped.
Set rs = CreateObject("ADODB.Recordset")
strSql = "Select * FROM [Tbl Plan Data];"
rs.Open strSql, CurrentProject.Connection
Do While Not rs.EOF
GroupAccount = rs![Group Account]
xPlanName = rs![Plan Name]
xOTC_EFF_DATE = rs![OTC_Effective_Date] 'Need to add to table.
If IsNull(rs![Trust EIN]) Then
xEIN = ""
Else
xEIN = rs![Trust EIN] 'Need to add to table.
End If
rs.MoveNext
FileName = FileNm2 & xFilePrefix & " " & GroupAccount & ".pdf"
Criteria = "[Group Account] = '" & GroupAccount & "'"
JSO.getField("topmostSubform[0].Page1[0].DateNameAddress_ReadOrder[0].f1_1[0]").Value = xBegDate
JSO.getField("topmostSubform[0].Page1[0].DateNameAddress_ReadOrder[0].f1_2[0]").Value = xEndDate
JSO.getField("topmostSubform[0].Page1[0].DateNameAddress_ReadOrder[0].f1_3[0]").Value = xYtEnd
JSO.getField("topmostSubform[0].Page1[0].DateNameAddress_ReadOrder[0].f1_4[0]").Value = xPlanName
JSO.getField("topmostSubform[0].Page1[0].DateNameAddress_ReadOrder[0].f1_5[0]").Value = xTrustCompany
JSO.getField("topmostSubform[0].Page1[0].DateNameAddress_ReadOrder[0].f1_6[0]").Value = xTrustCompanyaddress1
JSO.getField("topmostSubform[0].Page1[0].DateNameAddress_ReadOrder[0].f1_7[0]").Value = xTrustCompanyaddress2
JSO.getField("topmostSubform[0].Page1[0].LinesC-E[0].f1_10[0]").Value = xOTC_EFF_DATE
JSO.getField("topmostSubform[0].Page1[0].LinesC-E[0].f1_9[0]").Value = xEIN
JSO.getField("topmostSubform[0].Page1[0].SignatureDate_ReadOrder[0].SignatureDate_ReadOrder[0].f1_47[0]").Value = xFiduciaryEIN
JSO.getField("topmostSubform[0].Page1[0].LinesA-B[0].c1_6[0]").Value = 1
aPDDoc.Save PDSaveIncremental, FileName 'Save changes to the PDF document
Loop
aPDDoc.Close
End If
'Close the PDF; the True parameter prevents the Save As dialog from showing
aAVDoc.Close (True)
rs.Close
'Some cleaning
Set aAVDoc = Nothing
Set aPDDoc = Nothing
Set JSO = Nothing
Set rs = Nothing
MsgBox "Merge Process Complete."
End Sub
Copy link to clipboard
Copied
JSO.getField("topmostSubform[0].Page1[0].LinesA-B[0].c1_6[0]").Value = 1 'This is the line of code that won't persist when saved.
Copy link to clipboard
Copied
This isn't ColdFusion code, so I don't know what kind of answer you're going to get here. There are a few Acrobat and LiveCycle/AEM/whatever forums around. I don't know if Adobe actually has any of those. They do have Acrobat SDK documentation here:
https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/
As for the line of code that isn't persisting, maybe there's a datatype mismatch? I didn't think that was a thing in JavaScript or VBScript, but maybe just try making it into a string value instead of a numeric value:
JSO.getField("topmostSubform[0].Page1[0].LinesA-B[0].c1_6[0]").Value = "1"
Dave Watts, Eidolon LLC
Copy link to clipboard
Copied
That;s my point. This isn't something that is odd or peculiar.... wanting to prepopulate a pdf and save it. The reference in this application is to Adobe Pro..... So I thought this should be pretty boiuler plate type solution.
Copy link to clipboard
Copied
It may not be odd or peculiar, but it isn't ColdFusion. Adobe sells a lot of products. Knowing a lot about ColdFusion isn't going to help solve Acrobat problems.
Dave Watts, Eidolon LLC