Fill in PDF Form

Started by CBassett, October 20, 2022, 06:16:20 PM

Previous topic - Next topic

CBassett

Is there a way in WinBatch to fill in the form fields on a Fillable PDF using data from a CSV File.

Something similar to what this one does with an Excel Spreadsheet:

BD             = ObjectCreate("Excel.Application")
BD.Visible     = @FALSE
BD.UserControl = @FALSE
oAPP           = BD.Workbooks


oAPP.Open(cXls)

oWS    = BD.Worksheets(1)
oWS.Activate

;Write Headings to SpreadSheet
ColCnt = ItemCountCSV(x, 1)

AcctExec = ItemExtractCSV(36, x, 1)  ;Account Executive (Originanl Meeting)

BD.Worksheets(1).cells(1, 1).Value = ItemExtractCSV(4, Hdg, 1)    ;Client Name
BD.Worksheets(1).cells(1, 2).Value = ItemExtractCSV(7, Hdg, 1)    ;Outliving Money
BD.Worksheets(1).cells(1, 3).Value = ItemExtractCSV(8, Hdg, 1)    ;Volatility
BD.Worksheets(1).cells(1, 4).Value = ItemExtractCSV(9, Hdg, 1)    ;Taxes
BD.Worksheets(1).cells(1, 5).Value = ItemExtractCSV(10, Hdg, 1)   ;Inflation
BD.Worksheets(1).cells(1, 6).Value = ItemExtractCSV(11, Hdg, 1)   ;CI / WT
BD.Worksheets(1).cells(1, 7).Value = ItemExtractCSV(29, Hdg, 1)   ;Riskalyze
BD.Worksheets(1).cells(1, 8).Value = ItemExtractCSV(2, Hdg, 1)    ;Agent Name
BD.Worksheets(1).cells(1, 9).Value = "Email"
BD.Worksheets(1).cells(1, 10).Value = "Extension"
BD.Workbooks(1).SaveAs(NewFile)

oWS = 0
oAPP.Close()
oAPP = 0
BD.quit()
ObjectClose(BD)
BD = 0

Thanks!

JTaylor

Was waiting to see if you got a reply or not as my response doesn't exactly answer your question.   You might look at the XFDF file format.   It works very well for populating PDFs, especially since that is what it is for  :).  The issue would be how to initiate the population.   If this is a one station thing there are free 3rd-party apps that will do the trick.  Guessing there is a COM/OLE or CLR option that will do it as well but would have to do some investigating on that front.

Jim

stanl

I looked back on early WB scripts [circa 2004-2007] for working with PDF. Most used Acrobat as in
Code (WINBATCH) Select


AcroApp = CreateObject("AcroExch.App")
AvDoc = CreateObject("AcroExch.AVDoc")
PDDoc = CreateObject("AcroExch.PDDoc")


[EDIT]: https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/OLE~with~Acrobat~Viewer+Deal~with~Fields~on~a~PDF~form.txt



If OP has Adobe installed that might be of some use. There is also an iText Library.  Excel's Power Query/Get Transform - works with PDF and might be an option.


Last resort would be WB RoboScript and Sendkeys()