[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] Modify an existing PDF?



Jay Hannah wrote:
I need to open an existing .pdf file, change a text field value "CUSTOMER NAME HERE" to "Bob Jones", and save the .pdf file.

Has anyone done this programmatically? What did you use?

Huh... Super-ugly hacks straight on the binary data are pretty easy to do...

Strangely the J in JONES disappears... Hopefully most of our customers have last name SMITH. -laugh-

j


#!/usr/bin/perl

my $newline = '[(interaction)-301(of)-301(those)-301(BOB)-301(SMITH.)-301(Because)-301(of)-301(this,)-301(c)-30(ontinu-)]TJ';

open (IN, "Rogers.pdf");
open (OUT, ">Rogers_changed.pdf");
while (<IN>) {
  if (/elements.*in.*the.*cell/) {
     print OUT "$newline\n";
  } else {
     print OUT;
  }
}