Use these functions instead if you want to create a FDF file without installing the FDF toolkit. You would use it the same way as the fdf_* functions. BTW, I only wrote the basic library functions for creating FDFs.
The zip is attached.
-themightyindian
<?
define ( 'ntk_FDFValue' , 0 );
define ( 'ntk_FDFStatus' , 1 );
define ( 'ntk_FDFFile' , 2 );
define ( 'ntk_FDFID' , 3 );
define ( 'ntk_FDFFf' , 5 );
define ( 'ntk_FDFSetFf' , 6 );
define ( 'ntk_FDFClearFf' , 7 );
define ( 'ntk_FDFFlags' , 8 );
define ( 'ntk_FDFSetF' , 9 );
define ( 'ntk_FDFClrF' , 10 );
define ( 'ntk_FDFAP' , 11 );
define ( 'ntk_FDFAS' , 12 );
define ( 'ntk_FDFAction' , 13 );
define ( 'ntk_FDFAA' , 14 );
define ( 'ntk_FDFAPRef' , 15 );
define ( 'ntk_FDFIF' , 16 );
define ( 'ntk_FDFEnter' , 0 );
define ( 'ntk_FDFExit' , 1 );
define ( 'ntk_FDFDown' , 2 );
define ( 'ntk_FDFUp' , 3 );
define ( 'ntk_FDFFormat' , 4 );
define ( 'ntk_FDFValidate' , 5 );
define ( 'ntk_FDFKeystroke' , 6 );
define ( 'ntk_FDFCalculate' , 7 );
define ( 'ntk_FDFNormalAP' , 1 );
define ( 'ntk_FDFRolloverAP' , 2 );
define ( 'ntk_FDFDownAP' , 3 );
function ntk_fdf_header () {
header ( 'Content-type: application/vnd.fdf' );
}
function ntk_fdf_create () {
$fdf [ 'header' ] = "%FDF-1.2\n%????\n1 0 obj \n<< /FDF " ;
$fdf [ 'trailer' ] = ">>\nendobj\ntrailer\n<<\n/Root 1 0 R \n\n>>\n%%EOF" ;
return $fdf ;
}
function ntk_fdf_close (& $fdf ) {
unset( $fdf );
}
function ntk_fdf_set_file (& $fdf , $pdfFile ) {
$fdf [ 'file' ] = $pdfFile ;
}
function ntk_fdf_set_target_frame (& $fdf , $target ) {
$fdf [ 'target' ] = $target ;
}
function ntk_fdf_set_value (& $fdf , $fieldName , $fieldValue ) {
$fdf [ 'values' ] = array_merge ( $fdf [ 'values' ], array( $fieldName => $fieldValue ));
}
function ntk_fdf_add_doc_javascript (& $fdf , $scriptName , $script ) {
$fdf [ 'docscripts' ] = array_merge ( $fdf [ 'docscripts' ], array( $scriptName => $script ));
}
function ntk_fdf_set_javascript_action (& $fdf , $fieldName , $trigger , $script ) {
$fdf [ 'fieldscripts' ] = array_merge ( $fdf [ 'fieldscripts' ], array( $fieldName => array( $script , $trigger )));
}
function ntk_fdf_save (& $fdf , $fdfFile = null ) {
$search = array( '\\' , '(' , ')' );
$replace = array( '\\\\' , '\(' , '\)' );
$fdfStr = $fdf [ 'header' ];
$fdfStr .= "<< " ;
if(isset( $fdf [ 'file' ])) {
$fdfStr .= "/F (" . $fdf [ 'file' ]. ") " ;
}
if(isset( $fdf [ 'target' ])) {
$fdfStr .= "/Target (" . $fdf [ 'target' ]. ") " ;
}
if(isset( $fdf [ 'docscripts' ])) {
$fdfStr .= "/JavaScript << /Doc [\n" ;
// populate the doc level javascripts
foreach( $fdf [ 'docscripts' ] as $key => $value ) {
$fdfStr .= "(" . str_replace ( $search , $replace , $key ). ")(" . str_replace ( $search , $replace , $value ). ")" ;
}
$fdfStr .= "\n] >>\n" ;
}
if(isset( $fdf [ 'values' ]) || isset( $fdf [ 'fieldscripts' ])) {
// field level
$fdfStr .= "/Fields [\n" ;
if(isset( $fdf [ 'fieldscripts' ])) {
// populate the field level javascripts
foreach( $fdf [ 'fieldscripts' ] as $key => $val ) {
$fdfStr .= "<< /A << /S /JavaScript /JS (" . str_replace ( $search , $replace , $val [ 0 ]). ") >> /T (" . str_replace ( $search , $replace , $key ). ") >>\n" ;
}
}
if(isset( $fdf [ 'values' ])) {
// populate the fields
foreach( $fdf [ 'values' ] as $key => $value ) {
$fdfStr .= "<< /V (" . str_replace ( $search , $replace , $value ). ") /T (" . str_replace ( $search , $replace , $key ). ") >>\n" ;
}
}
$fdfStr .= "]\n" ;
}
$fdfStr .= ">>" ;
$fdfStr .= $fdf [ 'trailer' ];
if( $fdfFile ) {
$handle = fopen ( $fdfFile , 'w' );
fwrite ( $handle , $fdfStr );
fclose ( $handle );
}else {
echo $fdfStr ;
}
}
?>
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP , PHP , HTML , PDF , Excel fdf_close -- Close an FDF document Categories : PHP , PHP Functions , FDF Email Class Categories : PHP , Mail , PHP Classes Random text quote Categories : PHP , Arrays , Beginner Guides Storing / Retrieving pictures from database This can be used for banner / ads exchange. very useful for people developing big portal with ads in the site........ Categories : PHP , MySQL , Databases , HTML and PHP If you want to create select buttons featuring current date this example will show you how... Categories : Date Time , HTML and PHP , PHP Look for the *position* of the first occurence of string2
in string1, beginning at position start.
Categories : Complete Programs , PHP , Strings Word normalizing Categories : Search , PHP domxml_add_root -- Adds a further root node Categories : PHP , PHP Functions , DOM XML PHP Function to Encrypt/Decrypt a string without a known key. The string itself has his own different key for every character. Categories : PHP , Algorithms , Security , Authentication , Encryption A PHP Script that shows how to use FTP to run a shell script, read two local files and update data in a database. Categories : PHP , Filesystem , FTP , Date Time , Databases open source online php shop project ecommerce commerce Categories : PHP , Ecommerce Print structured array with offsets Categories : PHP , Debugging , Arrays This is a database wrapper for PostgreSQL, but can be simply modified for any other database type. Categories : Databases , PostgreSQL , PHP Email attachment code Categories : PHP , Email , Filesystem
Juan Jaramillo wrote : 1879
Hi there.. just wondering what all those constants are for? they're not used anywhere in the code..
Ravi Ramaswamy wrote : 1921
Hello Lalit,
I am looking for the syntax for SubmitForm. I believe this
will be similar to Javascript. My requirement is to set the
URL of the button dynamically from the form without FDF
toolkit.
Appreciate your help.
Thanks,
Ravi