Advertisements
Cam Newton laughing; 2016 Wikipedia.Today I released a new Perl module to CPAN entitled CAM::PDFTaxforms. This is the result of some hacking I had to do to an old module called CAM::PDF years ago for a job assignment. The task involved generating a partially filled out tax form based on users’ inputs from a logistics company’s website and other database data. I quickly stumbled upon CAM::PDF which handled filling in data fields on tax and other PDF forms, but could not check any of the checkboxes on such forms. The easiest solution was to hack up a copy of CAM::PDF to fix it to do this, much easier than inventing new code! This was back in 2010. I submitted my patch to Chris Dolan, the author and maintainer of CAM::PDF, and then filed CPAN bug #61354 with the patch, and got no response back. I then tarred up my hacked version and added it to my download site in case I needed it again at another office or for anyone else needing this feature. I went back a couple of times to check the status of the request and found that new versions had been released since then and that the list of open issues was quite long (I try to respond to, address, and close issues filed against MY modules quickly). |
| The other day, I got an email requesting info and assistance with MY hacked version, for which I had to dust off the old code that I haven’t used in several years and make sure it still worked (it did), so I replied him with instructions. I haven’t heard back, so I assume he’s a happy user now. Anyway, being a bit bored lately and with no other programming projects (I’m retired from my full-time programming career but still work on my own stuff) it got me to thinking about that code again and I decided to see if I could repackage it into a new module. Revisiting the code, I found that it had a single main program source file and a utility script that I had modified, but also a subdirectory of several other module source files that it depended on. Having developed and worked on several Perl-Tk modules in more recent years, I realized that I could just create a “wrapper” module that would allow me to simply create a CAM::PDF object, inheriting all it’s methods, but seemlessly override the handful that contained my changes, and create a new module with a similar name, and release it with the same license (which is open-source, and allows derived works). Then I had to uninstall my old, hacked version of CAM::PDF (1.52.1) and install their latest version 1.60. |
| I decided to name it CAM::PDFTaxforms, took the methods that needed changing copying them into my new module, and start testing some IRS forms. I did run into some issues with their latest forms, particularly their use of high-ASCII (and some NULL) characters in their internal PDF field names causing the program to not work at all. I studied it and was able to fix that issue with a couple lines of new code, and a couple of other minor issues by applying a few patches that others had submitted to the CPAN bug system (that were also still open). I tested some other recent IRS tax forms and finally have it working fairly well. In theory one could write an entire tax-filing application with it (if one has an army of developers, accountants, and tons of time of their hands), but would have to redo it each year due to many forms changing (adding and removing fields and checkboxes). The next step was to modify the build files, documentation, test harness, etc. from CAM::PDF to fit our module. I also added a couple of new tests (and example programs). One takes a blank 2018 IRS form 1040-Schedule B and a little text file containing pairs of banks and mutual funds and dollar amounts, and creates a filled-in version of it, including calculating and filling in the total lines. The other one then “reads” it and checks that the fields are filled in with the proper data and checkboxes checked. Anyway, I hope others will find it useful! |
| You can find more of my CPAN modules here. |
| /end |
Advertisements