Link to home
Start Free TrialLog in
Avatar of Sigh_Man
Sigh_Man

asked on

pass text to a field in an Acrobat pdf form

Does anyone have sample code for passing text to a field on an Adobe Acrobat pdf form?

(WinForms in VB.Net).


TIA
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

Have you started any kind of code?
Here is a project that I made sometime ago with Adobe Acrobat 5 that makes a report from dates with a access database and products a pdf with header info and column info.. All string fields and paths need to be changed to match
what you need.


'FORM 1

Imports Microsoft.VisualBasic
Class frmPDFDisplay
    Inherits System.Windows.Forms.Form
    Private dataList As New ArrayList
#Region "Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        'This call is required by the Windows Form Designer.
        InitializeComponent()

        bFirstPage = True
        Me.Height = 175
    End Sub
    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
        If Disposing Then
            If Not components Is Nothing Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(Disposing)
    End Sub
    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer
    Public ToolTip1 As System.Windows.Forms.ToolTip
    Public WithEvents CmdCancel As System.Windows.Forms.Button
    Public WithEvents CmdOK As System.Windows.Forms.Button
    Public WithEvents lblFinish As System.Windows.Forms.Label
    Public WithEvents LblEnd As System.Windows.Forms.Label
    Public WithEvents LblStart As System.Windows.Forms.Label
    Public WithEvents FraDate As System.Windows.Forms.GroupBox
    Public WithEvents PdfRpt As AxPdfLib.AxPdf
    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    Friend WithEvents dtpStartDate As System.Windows.Forms.DateTimePicker
    Friend WithEvents dtpEndDate As System.Windows.Forms.DateTimePicker
    Friend WithEvents ErrorDate As System.Windows.Forms.ErrorProvider
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmPDFDisplay))
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.FraDate = New System.Windows.Forms.GroupBox
        Me.dtpEndDate = New System.Windows.Forms.DateTimePicker
        Me.dtpStartDate = New System.Windows.Forms.DateTimePicker
        Me.CmdCancel = New System.Windows.Forms.Button
        Me.CmdOK = New System.Windows.Forms.Button
        Me.lblFinish = New System.Windows.Forms.Label
        Me.LblEnd = New System.Windows.Forms.Label
        Me.LblStart = New System.Windows.Forms.Label
        Me.PdfRpt = New AxPdfLib.AxPdf
        Me.ErrorDate = New System.Windows.Forms.ErrorProvider
        Me.FraDate.SuspendLayout()
        CType(Me.PdfRpt, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'FraDate
        '
        Me.FraDate.BackColor = System.Drawing.SystemColors.Control
        Me.FraDate.Controls.Add(Me.dtpEndDate)
        Me.FraDate.Controls.Add(Me.dtpStartDate)
        Me.FraDate.Controls.Add(Me.CmdCancel)
        Me.FraDate.Controls.Add(Me.CmdOK)
        Me.FraDate.Controls.Add(Me.lblFinish)
        Me.FraDate.Controls.Add(Me.LblEnd)
        Me.FraDate.Controls.Add(Me.LblStart)
        Me.FraDate.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FraDate.ForeColor = System.Drawing.SystemColors.ControlText
        Me.FraDate.Location = New System.Drawing.Point(6, 3)
        Me.FraDate.Name = "FraDate"
        Me.FraDate.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.FraDate.Size = New System.Drawing.Size(475, 130)
        Me.FraDate.TabIndex = 1
        Me.FraDate.TabStop = False
        Me.FraDate.Text = "Select Dates"
        '
        'dtpEndDate
        '
        Me.dtpEndDate.Location = New System.Drawing.Point(240, 34)
        Me.dtpEndDate.Name = "dtpEndDate"
        Me.dtpEndDate.TabIndex = 10
        Me.dtpEndDate.Value = New Date(2001, 4, 30, 13, 49, 0, 0)
        '
        'dtpStartDate
        '
        Me.dtpStartDate.Location = New System.Drawing.Point(15, 34)
        Me.dtpStartDate.Name = "dtpStartDate"
        Me.dtpStartDate.TabIndex = 9
        Me.dtpStartDate.Value = New Date(2001, 2, 1, 13, 49, 0, 0)
        '
        'CmdCancel
        '
        Me.CmdCancel.BackColor = System.Drawing.SystemColors.Control
        Me.CmdCancel.Cursor = System.Windows.Forms.Cursors.Default
        Me.CmdCancel.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.CmdCancel.ForeColor = System.Drawing.SystemColors.ControlText
        Me.CmdCancel.Location = New System.Drawing.Point(237, 63)
        Me.CmdCancel.Name = "CmdCancel"
        Me.CmdCancel.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.CmdCancel.Size = New System.Drawing.Size(115, 25)
        Me.CmdCancel.TabIndex = 3
        Me.CmdCancel.Text = "&Cancel"
        '
        'CmdOK
        '
        Me.CmdOK.BackColor = System.Drawing.SystemColors.Control
        Me.CmdOK.Cursor = System.Windows.Forms.Cursors.Default
        Me.CmdOK.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.CmdOK.ForeColor = System.Drawing.SystemColors.ControlText
        Me.CmdOK.Location = New System.Drawing.Point(87, 63)
        Me.CmdOK.Name = "CmdOK"
        Me.CmdOK.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.CmdOK.Size = New System.Drawing.Size(121, 25)
        Me.CmdOK.TabIndex = 2
        Me.CmdOK.Text = "&Ok"
        '
        'lblFinish
        '
        Me.lblFinish.BackColor = System.Drawing.SystemColors.Control
        Me.lblFinish.Cursor = System.Windows.Forms.Cursors.Default
        Me.lblFinish.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblFinish.ForeColor = System.Drawing.SystemColors.ControlText
        Me.lblFinish.Location = New System.Drawing.Point(84, 96)
        Me.lblFinish.Name = "lblFinish"
        Me.lblFinish.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.lblFinish.Size = New System.Drawing.Size(292, 22)
        Me.lblFinish.TabIndex = 8
        '
        'LblEnd
        '
        Me.LblEnd.BackColor = System.Drawing.SystemColors.Control
        Me.LblEnd.Cursor = System.Windows.Forms.Cursors.Default
        Me.LblEnd.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.LblEnd.ForeColor = System.Drawing.SystemColors.ControlText
        Me.LblEnd.Location = New System.Drawing.Point(231, 15)
        Me.LblEnd.Name = "LblEnd"
        Me.LblEnd.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.LblEnd.Size = New System.Drawing.Size(178, 13)
        Me.LblEnd.TabIndex = 7
        Me.LblEnd.Text = "End Date:"
        '
        'LblStart
        '
        Me.LblStart.BackColor = System.Drawing.SystemColors.Control
        Me.LblStart.Cursor = System.Windows.Forms.Cursors.Default
        Me.LblStart.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.LblStart.ForeColor = System.Drawing.SystemColors.ControlText
        Me.LblStart.Location = New System.Drawing.Point(9, 15)
        Me.LblStart.Name = "LblStart"
        Me.LblStart.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.LblStart.Size = New System.Drawing.Size(178, 13)
        Me.LblStart.TabIndex = 6
        Me.LblStart.Text = "Start Date:"
        '
        'PdfRpt
        '
        Me.PdfRpt.Enabled = True
        Me.PdfRpt.Location = New System.Drawing.Point(9, 159)
        Me.PdfRpt.Name = "PdfRpt"
        Me.PdfRpt.OcxState = CType(resources.GetObject("PdfRpt.OcxState"), System.Windows.Forms.AxHost.State)
        Me.PdfRpt.Size = New System.Drawing.Size(100, 50)
        Me.PdfRpt.TabIndex = 0
        Me.PdfRpt.Visible = False
        '
        'ErrorDate
        '
        Me.ErrorDate.ContainerControl = Me
        '
        'frmPDFDisplay
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.ClientSize = New System.Drawing.Size(487, 208)
        Me.Controls.Add(Me.FraDate)
        Me.Controls.Add(Me.PdfRpt)
        Me.Cursor = System.Windows.Forms.Cursors.Default
        Me.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Location = New System.Drawing.Point(4, 23)
        Me.Name = "frmPDFDisplay"
        Me.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Text = "View PDF"
        Me.FraDate.ResumeLayout(False)
        CType(Me.PdfRpt, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub
#End Region
#Region "Click Events"
    Private Sub CmdCancel_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CmdCancel.Click
        End
    End Sub
    Private Sub CmdOK_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CmdOK.Click
        sDBStartDate = dtpStartDate.Value.ToShortDateString
        sDBEndDate = dtpEndDate.Value.ToShortDateString
        InitializeData()
        CheckFiles()
        FdfAcX = New FDFACXLib.FdfApp
        FdfDoc = FdfAcX.FDFCreate
        Me.lblFinish.Text = "Moving Data from " & sDBName & " per examier ...please wait"
        Export_IDR_PDF()
        ShowPDFView()
    End Sub
#End Region
#Region "Pick Dates Controls"
    Private Sub dtpStartDate_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpStartDate.ValueChanged
        If dtpStartDate.Value > Now Then
            ErrorDate.SetError(dtpStartDate, "Start Date Must be less than or equal to Todays Date")
            bErrorDate = True
        Else
            ErrorDate.SetError(dtpStartDate, "")
            bErrorDate = False
        End If
    End Sub

    Private Sub dtpStartDate_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dtpStartDate.KeyUp
        If e.KeyCode = 9 Then
            e.Handled = True
            Me.dtpEndDate.Focus()
        End If
    End Sub

    Private Sub dtpStartDate_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpStartDate.Leave
        dtpStartDate.Format = DateTimePickerFormat.Custom
        dtpStartDate.CustomFormat = "MM'/'dd'/'yyyy"   '"yyyy'-'MM'-'dd"    'Change format for SQL SERVER Dates
        sDBStartDate = dtpStartDate.Text
        dtpStartDate.Format = DateTimePickerFormat.Long
    End Sub

    Private Sub dtpEndDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpEndDate.Click
        If dtpEndDate.Value < dtpStartDate.Value Or dtpEndDate.Value > Now Then
            ErrorDate.SetError(dtpEndDate, "End Date Must be greater than or equal to Start Date or before todays date")
            bErrorDate = True
        Else
            ErrorDate.SetError(dtpEndDate, "")
            bErrorDate = False
        End If
    End Sub
    Private Sub dtpEndDate_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpEndDate.ValueChanged
        If dtpEndDate.Value < dtpStartDate.Value Or dtpEndDate.Value > Now Then
            ErrorDate.SetError(dtpEndDate, "End Date Must be greater than or equal to Start Date or before todays date")
            bErrorDate = True
        Else
            ErrorDate.SetError(dtpEndDate, "")
            bErrorDate = False
        End If
    End Sub
    Private Sub dtpEndDate_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpEndDate.Leave
        dtpEndDate.Format = DateTimePickerFormat.Custom
        dtpEndDate.CustomFormat = "MM'/'dd'/'yyyy" '"yyyy'-'MM'-'dd"        'Change format for SQL SERVER Dates
        sDBEndDate = dtpEndDate.Text
        dtpEndDate.Format = DateTimePickerFormat.Long
    End Sub

#End Region
    Private Sub InitializeData()

        Cursor.Current = Cursors.WaitCursor
        sDBName = "TaxTest.mdb"        '<---- A standard access database
        sTableName = "Tax"

        OpenDBADOConnection()
        Con = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBName & ";password=" & sDBPass & ";")

        sSql = ""
        sSql = "SELECT *, as_of_date FROM " & sTableName & " "
        sSql += "WHERE as_of_date BETWEEN #" & Trim(sDBStartDate) & "# And #" & Trim(sDBEndDate) & "# "
        sSql += "ORDER BY as_of_date"

        Try
            ADOAdapter = New OleDb.OleDbDataAdapter(sSql, Con)         'FOR ADO Access database
            ADOAdapter.Fill(DS)

        Catch Exp As Data.OleDb.OleDbException
            MsgBox(Exp.Message, MsgBoxStyle.Critical, "Load Report Error")
        Catch Exp As Exception
            MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
        End Try
        Cursor.Current = Cursors.Default
    End Sub
    Private Sub LoadArrayList()
        Dim i As Short
        Dim z As Short

        For i = 0 To DS.Tables(0).Rows.Count - 1
            ' Check to see if row is flagged as deleted.
            If Not DS.Tables(0).Rows(i).RowState = DataRowState.Deleted Then
                ' Get the product name for each record.
                For z = 0 To DS.Tables(0).Columns.Count - 1
                    dataList.Add(DS.Tables(0).Rows(i)(z).ToString())
                Next
            End If
        Next i
    End Sub
    Private Sub frmPDFDisplay_Closed(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Closed
        CheckFiles()
    End Sub
    Private Sub ShowPDFView()
        SavePDF()
        FraDate.Visible = False
        'show PDF file here
        With Me
            .PdfRpt.Visible = True
            .PdfRpt.setShowToolbar((True))
            .PdfRpt.LoadFile(sPDFPath)
            Cursor.Current = Cursors.Default
            .Show()
        End With
        Me.WindowState = FormWindowState.Maximized
    End Sub
    Private Sub frmPDFDisplay_Resize(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Resize
        PdfRpt.SetBounds(0, 0, Me.ClientRectangle.Width - 15, Me.ClientRectangle.Height - 15)
    End Sub
    Public Sub SavePDF()
        Cursor.Current = Cursors.WaitCursor

        sPDFPath = sAppPath & "Acrobat\IDR_ADJ.PDF"

        lblFinish.Text = "Creating Summary Reports ... Please wait"

        FdfDoc.FDFSaveToFile(sFDFPath)
        FdfDoc.FDFClose()
        FdfDoc = Nothing
        FdfAcX = Nothing

        AcroExchAVDoc = CreateObject("AcroExch.AVDoc")
        bOK = AcroExchAVDoc.Open(sFDFPath, "")
        AcroExchPDDoc = AcroExchAVDoc.GetPDDoc
        ' bOK = AcroExchPDDoc.Save(Acrobat.__MIDL___MIDL_itf_acrobat_0000_0005.PDSaveFull, sPDFPath)
        bOK = AcroExchPDDoc.Save(1, sPDFPath)
        AcroExchPDDoc.Close()
        AcroExchAVDoc.Close(True)
        Cursor.Current = Cursors.Default
    End Sub
End Class

'MODULE

Imports PDFCode
Imports Microsoft.VisualBasic
Module modPDFCode
#Region " MY Global Vars "
    '********* database Var's ************
    Public sSql As String
    Public sTableName As String
    Public iCount As Short
    Public myDataRow As DataRow
    Public DS As New DataSet
    Public ADOAdapter As OleDb.OleDbDataAdapter  '(ADO)

    '**** Server Connection Vars *********
    Public sDBServer As String               '<--- Server Name
    Public sUSERid As String                 '<--- User Id
    Public sDBName As String                 '<--- Database Name
    Public sDBPass As String                 '<--- Password
    Public Con As OleDb.OleDbConnection      '<--- for Access

    '******* Standard Var's *************
    Public sAppPath As String = Application.StartupPath
    Const sMasterPath As String = "C:\Visual Studio Projects\PDFcode\MasterTemp\"
    Public bLogin As Boolean
    Public sDBStartDate As String      'Start Date
    Public sDBEndDate As String        'End Date
    Public bErrorDate As Boolean       'Error Checker

    '******** Common Paths ***********
    Public sPath As String
    Public sWorkPath As String
    Public sSysPath As String
    Public sZipPath As String
    Public sDBasePath As String 'directory where customer data is."

    '****** AcroBat Objects ********
    '// You have to have these components in directory windows/system32---FDFACX.DLL, FDFTK.DLL
    '// You have to register (e.i.- regsvr32 d:\windows\system32\FDFACX.DLL)
    '// Files to reference FDFACX.DLL, PDF.OCX, ACROBAT.TLB(30kb)
    Public bOK As Boolean
    Public AcroApp As Acrobat.CAcroApp
    Public AcroExchAVDoc As Acrobat.CAcroAVDoc
    Public AcroExchPDDoc As Acrobat.CAcroPDDoc
    Public FdfAcX As FDFACXLib.FdfApp
    Public FdfDoc As FDFACXLib.FdfDoc
    Public sFDFPath As String
    Public sPDFPath As String

    '**** Used in PDF Reports ******
    Public sReportTitle As String
    Public sActionField As String
    Public sFieldHeader(4) As String
    Public sEntityName As String
    Public iPage As Short
    Public bFirstPage As Boolean
    Public bHit As Boolean
    Public sField As String
    Public fso As Scripting.FileSystemObject
#End Region
#Region " MY Server Connections "
    Public Sub OpenDBADOConnection()
        Try
            Con = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBName & ";password=" & sDBPass & ";")
            Con.Open()
            Con.Close()
        Catch Ex As Exception
            MsgBox("Exception: " & Ex.Message & "  " & Ex.ToString, MsgBoxStyle.Critical)
            Cursor.Current = Cursors.Default
        End Try
    End Sub
#End Region
    Public Sub IDR_Headers()
        Dim sdate As Date
        'Var.. for the report headers
        sEntityName = DS.Tables(0).Rows(0)(1).ToString() 'RS.Fields(1).Value
        sReportTitle = "Individual Document Requests"
        sFieldHeader(0) = "IDR Number"
        sFieldHeader(1) = "Issue"
        sFieldHeader(2) = "Requested by/"
        sFieldHeader(3) = "Initiated by"
        sFieldHeader(4) = "Request Date"
        sActionField = "Not Imported"
        With FdfDoc
            ' print the header or Add new page after 21 entries
            If bHit Then
                .FDFAddTemplate(True, sMasterPath & "idr_adj.pdf", "idr_adj_pg", True)
                bHit = False
                iPage += 1
                .FDFSetValue("page", CStr(iPage), True)
                .FDFSetValue("adjustment_entity_nm", sEntityName, False)
                .FDFSetValue("Title", sReportTitle, False)
                .FDFSetValue("IDR_Issue_num", sFieldHeader(0), False)
                .FDFSetValue("Issue", sFieldHeader(1), False)
                .FDFSetValue("Pro_Req_by", sFieldHeader(2), False)
                .FDFSetValue("Initiated_by", sFieldHeader(3), False)
                .FDFSetValue("Issue_Req_date", sFieldHeader(4), False)
                .FDFSetValue("Action", sActionField, False)
                sdate = Now.ToShortDateString
                .FDFSetValue("as_of_date", sdate, False)
                iCount = 1
            End If
        End With
    End Sub
    Public Sub IDR_Main(ByVal i As Integer)
        Dim sFieldName As String

        With FdfDoc
            'Main body of the report
            Try
                sField = IIf(DS.Tables(0).Rows(i)("idr_request_prefix_txt").ToString() <> "", DS.Tables(0).Rows(i)("idr_request_prefix_txt").ToString() & "-", " ")
                sFieldName = DS.Tables(0).Rows(i)("idr_request_num").ToString
                sFieldName = sFieldName.ToString.Format("0000")
                sField = sField & IIf(sFieldName <> "", sFieldName, " ")
                sField = Space(20 - Len(sField)) & Trim(sField)
            Catch e As InvalidCastException
                Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
            End Try
            .FDFSetValue("field1." & (iCount), sField, False)
            .FDFSetValue("field2." & (iCount), IIf(DS.Tables(0).Rows(i)("idr_subject_nm").ToString <> "", DS.Tables(0).Rows(i)("idr_subject_nm").ToString, " "), False)
            .FDFSetValue("field3." & (iCount), IIf(DS.Tables(0).Rows(i)("idr_requester_nm").ToString <> "", DS.Tables(0).Rows(i)("idr_requester_nm").ToString, " "), False)
            .FDFSetValue("field4." & (iCount), IIf(DS.Tables(0).Rows(i)("idr_initiator_nm").ToString <> "", DS.Tables(0).Rows(i)("idr_initiator_nm").ToString, " "), False)
            Try
                .FDFSetValue("field5." & (iCount), IIf(CStr(DS.Tables(0).Rows(i)("request_dt").ToString) <> "", CStr(DS.Tables(0).Rows(i)("request_dt").ToString), " "), False)
            Catch e As InvalidCastException
                .FDFSetValue("field5." & (iCount), " ", False)
            End Try
            iCount += 1
        End With
    End Sub
    Public Sub Export_IDR_PDF()
        Cursor.Current = Cursors.WaitCursor
        Dim i As Short

        If bFirstPage Then
            iCount = 1
            iPage = 0
            bHit = True
            bFirstPage = False
            IDR_Headers()
        End If

        Application.DoEvents()

        For i = 0 To DS.Tables(0).Rows.Count - 1
            ' Check to see if row is flagged as deleted.
            If Not DS.Tables(0).Rows(i).RowState = DataRowState.Deleted Then
                If IsDBNull(DS.Tables(0).Rows(i)("idr_requester_nm").ToString) Then
                Else
                    If iCount > 21 Then
                        bHit = True
                        IDR_Headers()
                    End If
                    IDR_Main(i)
                End If
            End If
        Next i
    End Sub
    Public Sub CheckFiles()
        Dim sPDFTempPath As String

        fso = New Scripting.FileSystemObject

        sAppPath = CurDir()
        If sAppPath.Substring(sAppPath.Length - 1, 1) <> "\" Then
            sAppPath += "\"
        End If

        sFDFPath = sAppPath & "WorkFDF.fdf"
        sPDFTempPath = sMasterPath & "temp.pdf"

        'Delete all old temp files
        With fso
            If .FileExists(sPDFTempPath) Then .DeleteFile((sPDFTempPath))
            If .FileExists(sFDFPath) Then .DeleteFile((sFDFPath))
        End With
        'fso only looks for that one file, Dir looks for all files then deletes them
        '  If Dir(sWorkPath & "*.id") <> "" Then Kill (sWorkPath & "*.id")
        '  If Dir(sWorkPath & "*.xml") <> "" Then Kill (sWorkPath & "*.xml")
        '  If Dir(sWorkPath & "*.zip") <> "" Then Kill (sWorkPath & "*.zip")

    End Sub
End Module
Avatar of Sigh_Man
Sigh_Man

ASKER

No I didn't have any code to begin with.  I wanted some code to do the following:

1. Open Acrobat application
2. Load a certain form (this can be hard-coded for now; I will deal with forms selection later)
3. (For example) Insert the word "SMITH" into the SURNAME field contained on the Acrobat form that it just opened.

Formatting and cosmetic changes (eg font size etc) will come later - what I need at the moment is the basics outlined above.  I have to disappear shortly but I will try the code later in the day.
If you could somehow highlight the relevant parts of your code required to perform the above steps that would be excellent, but if not - no problem!

Thanks again...
.....the form to be opened is a form already created by someone, so all I need to do is access the form and update the relevant field with the relevant info.
If you have a sample of the form you are working with would help.
I can cut up the code tomorrow as an example.
As an example:

www.irs.gov/pub/irs-pdf/fw9.pdf

How would you open up Acrobat and insert the name "John Smith" into the name field at the top of this form?

do you have a full Adobe Acrobat software for editing?
ASKER CERTIFIED SOLUTION
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
.....And yes, I have a full version of Acrobat for editting.
I'll give this a go and get back to you shortly.......   :D
Sorry for the ridiculous delay...!!
Although I haven't had chance to try & test this fully, the code seems to be the pointer I need.

Many thanks...   :D
I have reached the stage where I have completed everything else and I need to get this working.  More points are up for grabs on this issue -- see: https://www.experts-exchange.com/questions/21416380/Fill-fields-in-Adobe-Acrobat-form-pdf-fields.html

Thanks.