Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PDF fillable form

Status
Not open for further replies.

trScott

Technical User
Dec 13, 2004
31
0
0
US
Using a PDF fillable form, I've filled in all the values from my Access 2003 application and saved the document. I now need to make the fillable fields no longer editable (flattening perhaps)? Does anyone have an idea how to accomplish this via Access?

Thanks!
 
I found a way to render the form fields inactive (if using Adobe objects):

Dim gAVdoc As Acrobat.CAcroAVDoc, pdDoc As Acrobat.CAcroPDDoc, gApp As Acrobat.CAcroApp
Dim formApp As AFORMAUTLib.AFormApp, formField As AFORMAUTLib.field, formfields As AFORMAUTLib.Fields

Public Function RenderAllFormFieldsReadOnly(pdfFile As String) As Boolean
'Loops through all the fields and makes them read only

On Error GoTo Error_Handler

Dim numFields As Long
'A little method to see if file exists (can write your own or delete)
If (Not FileExists(pdfFile)) Then
RenderAllFormFieldsReadOnly = False
GoTo Exit_Here
End If
Set gAVdoc = CreateObject("AcroExch.avdoc")
If (gAVdoc.Open(pdfFile, "")) Then
Set pdDoc = gAVdoc.GetPDDoc
Set formApp = CreateObject("AFormAut.App")
Set formfields = formApp.Fields
numFields = formfields.Count
For Each formField In formfields
formField.IsReadOnly = True
Next
Call pdDoc.Save(PDSaveFull, pdfFile)
End If
RenderAllFormFieldsReadOnly = True

Exit_Here:
Call closePDFObjects(formfields, formApp, pdDoc, gAVdoc, gApp)
Exit Function

Error_Handler:
RenderAllFormFieldsReadOnly = False
Resume Exit_Here

End Function

Public Sub closePDFObjects(formfields As AFORMAUTLib.Fields, formApp As AFORMAUTLib.AFormApp, pdDoc As Acrobat.AcroPDDoc, _
gAVdoc As Acrobat.CAcroAVDoc, gApp As Acrobat.AcroApp)

If Not formfields Is Nothing Then
Set formfields = Nothing
End If
If Not formApp Is Nothing Then
Set formApp = Nothing
End If
If Not pdDoc Is Nothing Then
pdDoc.Close
End If
Set pdDoc = Nothing
If Not gAVdoc Is Nothing Then
gAVdoc.Close (-1)
End If
Set gAVdoc = Nothing
If Not gApp Is Nothing Then
gApp.Exit
End If
Set gApp = Nothing
'Call fCloseApp("AdobeAcrobat")
'Sleep 250 'Give it time to stop
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top