Hello All:

I am 6 days new to PHP. I find the syntax to be quite similar to Perl, so
that has helped alot.

I am having problems doing a search and replace in an Adobe PDF document.
What I have done is made an Adobe PDF document using Adobe Distiller from a
MS Word document. I then changed some of the fields to be forms. I made the
value of the forms something like ##VARIABLE1##.

Using PHP, I wanted to be able to call this form, and search and replace the
variable above with say, for example, a person's name.

Below is the code I am trying to use:

$contents = file ("Notice.pdf");

for($i=0; $i< sizeof($contents); $i++){

$staff .= eregi_replace("##VARIABLE1##", "$FirstName", $contents[$i]);

$length = $length + (strlen($contents[$i]));


$fp = fopen("Final.pdf", "w");

fputs ($fp, $staff,$length);

fclose ($fp);

The problem is that the filesize of the new file ends up being much smaller
than the original file. The above code works fine on plain text files, but
does not like PDF (probably any binary file for that matter).

Any ideas or suggestions?

Best Regards,

Gabriel C. Murphy

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to