This is a small tool that lets you choose a directory that contains filled PDF Form files, reads those files, and writes a CSV file with the form data from each file. The CSV file can then be opened using Microsoft Excel, Google Sheets, Apache OpenOffice or Libre Office Calc, or other spreadsheet or CSV reader programs.
The CSV file will have the format:
File | Field 1 | Field 2 | Field 3 | etc |
---|---|---|---|---|
file01.pdf | value 1 | value 2 | etc | |
file02.pdf | value 1 | value 2 | etc | |
file03.pdf | value 1 | value 2 | etc | |
data01.pdf | value 1 | value 3 | etc |
Where each of the Fields is taken from the name of the form field in the PDF file, and each of the values is taken from whatever the person filling the PDF file entered. It is not necessary that the PDF files all have the same form fields; that will results in some columns having data and others not.
If you double-click the program, it will start with a short welcome message; pressing OK on that will then show a file browser where you should choose the directory (or folder) that contains the filled PDF form files. After you choose it the CSV summary file will be written to the same directory (folder) as the PDF files, and a dialog box showing you the path of the summary file will be shown.
It looks like this:
MacOS | Windows |
You can also run the same program from the Windows Command Prompt or the MacOS Terminal.app by typing the name of the program followed by the path to a directory (or folder) containing the PDF form files.
Everytime you run the program, it will write a file to $TMPDIR
or
$TMP
or /tmp
or /temp
called pdfform2csv.log
. If there are
problems or you need help, look at that file, or use it to open an
issue.
Make a directory (or folder) called bin
, first.
- Build the binary
go build -o pdfform2csv main.go
- Make the application bundle structure
mkdir -p bin/pdfform2csv/Contents/MacOS mkdir -p bin/pdfform2csv/Contents/Resources
- Copy the binary
pdfform2csv
tobin/pdfform2csv/Contents/MacOS
- Run
python support/makeiconset.py support/pdfform2csv.png
and copy the resultingicns
file tobin/pdfform2csv/Contents/Resources
- Put the file
Info.plist
from thesupport
directory inbin/pdfform2csv/Contents/
; the contents of that file are something like:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleExecutable</key> <string>pdfform2csv</string> <key>CFBundleIconFile</key> <string>pdfform2csv.icns</string> <key>CFBundleIdentifier</key> <string>io.github.acaird</string> <key>NSHighResolutionCapable</key> <true/> <key>LSUIElement</key> <true/> </dict> </plist>
- edit the data in the
winres/
directory if needed; replacing the icon files also, if needed - Using go-winres make the
syso
files - build the binary
GOOS=windows GOARCH=amd64 go build -ldflags -H=windowsgui -i -o bin/pdfform2csv.exe main.go
- Packaging a Go Application for MacOS:
- https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5
- Convert PNG to ICNS on Mac OS
- https://retifrav.github.io/blog/2018/10/09/macos-convert-png-to-icns/
- Build, notarize, and sign Golang binaries for MacOS with GitHub
Actions
- https://www.kencochrane.com/2020/08/01/build-and-sign-golang-binaries-for-macos-with-github-actions/
- Dlgs: Dialogs for simple Go Apps
- https://pkg.go.dev/github.com/gen2brain/dlgs
- Adding Windows Resources to Go program
- https://github.com/tc-hib/go-winres
Note that the icons tend not to work at all. All of those steps to make them seem to be a waste of time. 🤷