Beispiel #1
0
function forge_fdf($pdf_form_url, &$fdf_data_strings, &$fdf_data_names, &$fields_hidden, &$fields_readonly)
{
    $fdf = "%FDF-1.2\r%ту╧╙\r\n";
    // header
    $fdf .= "1 0 obj\r<< ";
    // open the Root dictionary
    $fdf .= "\r/FDF << ";
    // open the FDF dictionary
    $fdf .= "/Fields [ ";
    // open the form Fields array
    $fdf_data_strings = burst_dots_into_arrays($fdf_data_strings);
    forge_fdf_fields_strings($fdf, $fdf_data_strings, $fields_hidden, $fields_readonly);
    $fdf_data_names = burst_dots_into_arrays($fdf_data_names);
    forge_fdf_fields_names($fdf, $fdf_data_names, $fields_hidden, $fields_readonly);
    $fdf .= "] \r";
    // close the Fields array
    // the PDF form filename or URL, if given
    if ($pdf_form_url) {
        $fdf .= "/F (" . escape_pdf_string($pdf_form_url) . ") \r";
    }
    $fdf .= ">> \r";
    // close the FDF dictionary
    $fdf .= ">> \rendobj\r";
    // close the Root dictionary
    // trailer; note the "1 0 R" reference to "1 0 obj" above
    $fdf .= "trailer\r<<\r/Root 1 0 R \r\r>>\r";
    $fdf .= "%%EOF\r\n";
    return $fdf;
}
Beispiel #2
0
/**
*   Generates the fdf code
*
*@param String      $pdf_form_url:  a string containing a URL path to a PDF file on the
*                   server. This PDF MUST exist and contain fields with
*                   the names referenced by $pdf_data for this function
*                   to work.
*@param Array   	$fdf_data_strings:  an array of any fields in $pdf_form_url that you want to
*                   populate, of the form key=>val; where the field
*                   name is the key, and the field's value is in val.
*@return String 
**/
function forge_fdf($pdf_form_url, $fdf_data_strings, $fdf_data_names, $fields_hidden, $fields_readonly)
{
    $fdf = "%FDF-1.2\r%ту╧╙\r\n";
    // header
    $fdf .= "1 0 obj\r<< ";
    // open the Root dictionary
    $fdf .= "\r/FDF << ";
    // open the FDF dictionary
    $fdf .= "/Fields [ ";
    // open the form Fields array
    // string data, used for text fields, combo boxes and list boxes
    foreach ($fdf_data_strings as $key => $value) {
        $fdf .= "<< /V (" . escape_pdf_string($value) . ")" . "/T (" . escape_pdf_string($key) . ") ";
        if (in_array($key, $fields_hidden)) {
            $fdf .= "/SetF 2 ";
        } else {
            $fdf .= "/ClrF 2 ";
        }
        if (in_array($key, $fields_readonly)) {
            $fdf .= "/SetFf 1 ";
        } else {
            $fdf .= "/ClrFf 1 ";
        }
        $fdf .= ">> \r";
    }
    // name data, used for checkboxes and radio buttons
    // (e.g., /Yes and /Off for true and false)
    foreach ($fdf_data_names as $key => $value) {
        $fdf .= "<< /V /" . escape_pdf_name($value) . " /T (" . escape_pdf_string($key) . ") ";
        if (in_array($key, $fields_hidden)) {
            $fdf .= "/SetF 2 ";
        } else {
            $fdf .= "/ClrF 2 ";
        }
        if (in_array($key, $fields_readonly)) {
            $fdf .= "/SetFf 1 ";
        } else {
            $fdf .= "/ClrFf 1 ";
        }
        $fdf .= ">> \r";
    }
    $fdf .= "] \r";
    // close the Fields array
    // the PDF form filename or URL, if given
    if ($pdf_form_url) {
        $fdf .= "/F (" . escape_pdf_string($pdf_form_url) . ") \r";
    }
    $fdf .= ">> \r";
    // close the FDF dictionary
    $fdf .= ">> \rendobj\r";
    // close the Root dictionary
    // trailer; note the "1 0 R" reference to "1 0 obj" above
    $fdf .= "trailer\r<<\r/Root 1 0 R \r\r>>\r";
    $fdf .= "%%EOF\r\n";
    return $fdf;
}