Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

fill a pdf form with data Expand / Collapse
Author
Message
Posted Friday, July 20, 2007 6:06 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, October 7, 2014 2:22 AM
Points: 41, Visits: 67
what can be done in access to fill a pdf form with data stored in access?
Post #383628
Posted Friday, July 20, 2007 6:23 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Tuesday, February 5, 2013 4:24 AM
Points: 685, Visits: 104

some developers usually create their forms using e.g. word and then print it to a pdf printer. the reason being the ease of use of the the apis that are available




Everything you can imagine is real.

Post #383636
Posted Friday, July 20, 2007 6:26 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Tuesday, February 5, 2013 4:24 AM
Points: 685, Visits: 104
you would need to get the pdf form API/component/ DLL


Everything you can imagine is real.

Post #383638
Posted Friday, July 20, 2007 8:26 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, October 7, 2014 2:22 AM
Points: 41, Visits: 67

where can i get the pdf form API/component/ DLL?

is it free?

Post #383704
Posted Friday, July 20, 2007 8:57 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Tuesday, February 5, 2013 4:24 AM
Points: 685, Visits: 104

you can try cute pdf, but its not free   http://www.cutepdf.com/ pdf sdk

from their sample code you will be doing something similar to

Dim objMyForm

Set objMyForm = Server.CreateObject("CutePDF.Document")  'Create form object

objMyForm.initialize("FS20-001-12345678-12345678")          'Initialize object by serial number of the license

'Open an encrypted PDF form file from an URL with password 'cutepdf'

if objMyForm.openFile("ftp://www.ftpsite.com/Encrypted_Form.pdf","cutepdf") = false then 

    errorMessage = objMyForm.GetLastError()

end if

'Set some value into fields

nReturn = objMyForm.setField("Company", "Acro Software Inc.")

nReturn = objMyForm.setField("Address.1", "Company address")

nReturn = objMyForm.setField("Address.2", "City, State, Zip")

nReturn = objMyForm.setField("Product", "CutePDF Form SDK")

'Save completed form file into a new PDF file

objMyForm.saveFile("D:\CutePDF SDK\Forms\Form01.pdf")

'Save a duplicate copy

objMyForm.saveFile("D:\CutePDF SDK\Forms\Form02.pdf")

----

which is your normal component usage




Everything you can imagine is real.

Post #383746
Posted Wednesday, August 14, 2013 9:15 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, October 13, 2014 4:52 PM
Points: 101, Visits: 236
Any way to convert the above vb code to sql
Post #1484360
Posted Tuesday, December 24, 2013 10:46 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, January 10, 2014 9:55 AM
Points: 1, Visits: 5
I spent a fair amount of time researching this very thing and trying all sorts of VBA code. I have successfully created code that will open a PDF and then insert data from Access into the form-fillable PDF. Getting code samples from Acrobat forums is extremely difficult. It's as if Acrobat programmers don't like to share code.

That said, I've been wanting to share how I did it because I can't be the only one who needed this. Yes, Access can output to Word. Yes, Access can output a report as PDF. But what if the PDF is not your creation? What if you just need to populate it with data you have in your database?

I am using Adobe Acrobat X Standard. I have a couple of ways I populate PDFs with data.
1. pass an array of values to the procedure that populates the PDF and loop thru the array to insert the data
2. use recordset and get data, then hard code the names of the PDF fields and populate them
3. use a table to store the field mapping so that I can use a loop to populate the PDF fields with the corresponding Access data

I work PT for an insurance brokerage so some of the forms I'm populating are called ACORD apps. You do NOT want to recreate these in Access so populating a PDF is 100x easier.

I'm attaching a text file with the various code samples. It's all VBA code so it can be pasted into a new module. It will have to be modified quite a bit to meet your needs, but it's a start. Here's a basic sample:
'   VERY BASIC EXAMPLE OF INSERTING DATA IN A PDF

Public Sub PopulateCertHolder(ByVal sValue As String, ByVal sAcord As String, ByVal sSaveAs As String)
Dim WshShell As Object

On Error GoTo PopulateCertHolder_Error

'open pdf fillable form
1 Set WshShell = CreateObject("Wscript.Shell")
2 WshShell.Run "Acrobat.exe " & sAcord

'delay to let the form load completely
3 PauseTime = 1
4 Start = Timer
5 Do While Timer < Start + PauseTime
6 DoEvents
7 Loop

8 Set APP = CreateObject("Acroexch.app")
9 Set AVDOC = CreateObject("AcroExch.AVDoc")
10 Set AVDOC = APP.GetActiveDoc
11 Set PDDOC = AVDOC.GetPDDoc
12 Set jso = PDDOC.GetJSObject

'populate fields
Dim val As Variant
18 Set x = jso.GetField("FormFieldName")
19 val = sValue
23 x.Value = val

'save file
31 PDDOC.Save 1, sSaveAs
32 AVDOC.Close 1
DoEvents
33 APP.CloseAllDocs
DoEvents
34 APP.Exit

'just in case window didn't close
35 fCloseApp "AcrobatSDIWindow"

'housekeeping on the way out
36 Set APP = Nothing
37 Set AVDOC = Nothing
38 Set PDDOC = Nothing
39 Set jso = Nothing

Exit_PopulateCertHolder:
Exit Sub

PopulateCertHolder_Error:
Call LogError(Err.Number, Err.Description, "AcrobatCode.PopulateCertHolder", Erl)
Resume Exit_PopulateCertHolder
End Sub


Hope this helps!
Diana


  Post Attachments 
AcrobatCode.txt (10 views, 19.25 KB)
Post #1525785
Posted Thursday, January 9, 2014 11:37 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, May 6, 2014 9:48 PM
Points: 2, Visits: 13
diana_criscione (12/24/2013)

That said, I've been wanting to share how I did it because I can't be the only one who needed this. Yes, Access can output to Word. Yes, Access can output a report as PDF. But what if the PDF is not your creation? What if you just need to populate it with data you have in your database?


Diana, thank you so so so much for sharing your findings with us. It definitely helps a lot. I saves us much time in searching and reading each related topics.
Post #1529642
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse