I wrote a Perl library, CAM::PDF, with a command-line interface that can solve this. I tried using an FDF solution years ago, but found it way too complicated which is why I wrote CAM::PDF in the first place. My library uses a few heuristics to replace the form with the desired text, so it's not perfect. But it works most of the time, and it's fast, free and quite straightforward to use.