Illegal Characters in FDF File - Stream

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi all,

I have been working on a php script lately that merges results from a db  
and an xml source and then populates a PDF through FDF. I have gotten  
nearly everything to work except multi line javascript. I have tried  
both of the following attacks on the problem to no avail.

First I tried setting the set_on_import directly... then I tried to set  
all the javascript in a function and then call the function on load...  
both of them generate illegal characters in the stream.

Both of these examples are in a for each that contain a $counter:

$js = 'this.getField("moveinready.' . $counter . '").display =  
display.visible;' . "\r";
$js .= 'this.getField("moveinready.' . $counter . '").display =  
display.visible;' . "\r";


$js = "function run_onload_()\r{\r"; $js .=  
'this.getField("moveinready.' . $counter . '").display =  
display.visible;' . "\r";
$js .= 'this.getField("moveinready.' . $counter . '").display =  
display.visible;' . "\r";
$js .= "\r}\r"; fdf_add_doc_javascript($fdf,"run_onload_", $js);

both methods die if I use a string like this for $js:

this.getField("move.1").display = display.hidden;\r
this.getField("bullet.1").display = display.visible;\r
this.getField("move.2").display = display.hidden;\r
this.getField("bullet.2").display = display.hidden;\r
this.getField("move.3").display = display.hidden;\r
this.getField("bullet.3").display = display.hidden;\r
this.getField("move.4").display = display.hidden;\r
this.getField("bullet.4").display = display.hidden;\r

both work fine if I limit the string to 1 line like this:

fdf_set_on_import_javascript($fdf , 'this.getField("move.1").display =  
display.hidden;' , true);

The fdf contains a stream of illegal characters when using a multi line  
string. However I cannot simply use a single instruction as the fdf  
seems to only want 1 on_import_js to a file.

any help would be great as this toolkit lacks documentation for php.


example of fdf output stream - supposed to be readable javascript here:

/FDF << /Fields 2 0 R /JavaScript << /Before 10 0 R >> >>

10 0 obj
<< /Filter [ /FlateDecode ] /Length 176 >>

Posted via a free Usenet account from

Re: Illegal Characters in FDF File - Stream

Unless someone has a better idea - as I think this object in the tool
kit is broken - I think I will just save the fdf out and then snip the
last few lines off and add my own stream containing the js and then
close out the fdf manually like so...

10 0 obj
<< /Filter [ /FlateDecode ] /Length 107 >>

function run_onload__(){\r this.getField("move.1").display =
display.hidden;\r this.getField("bullet.1").display = display.visible;
\r this.getField("move.2").display = display.hidden;\r
this.getField("bullet.2").display = display.hidden;\r }\r
/Root 1 0 R

Quoted text here. Click to load it

Re: Illegal Characters in FDF File - Stream

Anyone out there actually use the FDF tool kit?

Re: Illegal Characters in FDF File - Stream

Quoted text here. Click to load it

Guess not.

I reworked the code and it seems to work now.

Site Timeline