Ref/fdf-Phpdoc专题
fdf_add_doc_javascript
Adds javascript code to the FDF document
说明
bool <span
class="methodname">fdf_add_doc_javascript ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $script_name
, <span
class="methodparam">string
$script_code
)
Adds a script to the FDF, which Acrobat then adds to the doc-level scripts of a document, once the FDF is imported into it.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
script_name
The script name.
script_code
The script code. It is strongly suggested to use \r for linebreaks
within the script code.
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 Adding JavaScript code to a FDF
<?php
$fdf = fdf_create();
fdf_add_doc_javascript($fdf, "PlusOne", "function PlusOne(x)\r{\r return x+1;\r}\r");
fdf_save($fdf);
?>
will create a FDF like this:
%FDF-1.2
%âãÏÓ
1 0 obj
<<
/FDF << /JavaScript << /Doc [ (PlusOne)(function PlusOne\(x\)\r{\r return x+1;\r}\r)] >> >>
>>
endobj
trailer
<<
/Root 1 0 R
>>
%%EOF
fdf_add_template
Adds a template into the FDF document
说明
bool <span
class="methodname">fdf_add_template ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">int $newpage
, <span
class="methodparam">string $filename
, string
$template
, <span
class="type">int $rename
)
Warning
本函数还未编写文档,仅有参数列表。
fdf_close
Close an FDF document
说明
void <span
class="methodname">fdf_close ( <span
class="type">resource $fdf_document
)
Closes the FDF document.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
返回值
没有返回值。
参见
- fdf_open
fdf_create
Create a new FDF document
说明
resource <span class="methodname">fdf_create ( <span class="methodparam">void )
Creates a new FDF document.
This function is needed if one would like to populate input fields in a PDF document with data.
返回值
Returns a FDF document handle, or false
on error.
范例
示例 #1 Populating a PDF document
<?php
$outfdf = fdf_create();
fdf_set_value($outfdf, "volume", $volume, 0);
fdf_set_file($outfdf, "http:/testfdf/resultlabel.pdf");
fdf_save($outfdf, "outtest.fdf");
fdf_close($outfdf);
Header("Content-type: application/vnd.fdf");
$fp = fopen("outtest.fdf", "r");
fpassthru($fp);
unlink("outtest.fdf");
?>
参见
- fdf_close
- fdf_save
- fdf_open
fdf_enum_values
Call a user defined function for each document value
说明
bool <span
class="methodname">fdf_enum_values ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">callable $function
[, <span
class="methodparam">mixed $userdata
] )
Warning
本函数还未编写文档,仅有参数列表。
fdf_errno
Return error code for last fdf operation
说明
int fdf_errno ( void )
Gets the error code set by the last FDF function call.
A textual description of the error may be obtained using with <span class="function">fdf_error.
返回值
Returns the error code as an integer, or zero if there was no errors.
参见
- fdf_error
fdf_error
Return error description for FDF error code
说明
string <span
class="methodname">fdf_error ([ <span
class="type">int $error_code
=
-1 ] )
Gets a textual description for the FDF error code given in error_code
.
参数
error_code
An error code obtained with fdf_errno. If
not provided, this function uses the internal error code set by the last
operation.
返回值
Returns the error message as a string, or the string no error if nothing went wrong.
参见
- fdf_errno
fdf_get_ap
Get the appearance of a field
说明
bool <span
class="methodname">fdf_get_ap ( <span
class="type">resource $fdf_document
, <span
class="methodparam">string $field
,
int $face
,
string
$filename
)
Gets the appearance of a field
(i.e. the value of the /AP key) and
stores it in a file.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
field
face
The possible values are FDFNormalAP
, FDFRolloverAP
and
FDFDownAP
.
filename
The appearance will be stored in this parameter.
返回值
成功时返回 true
, 或者在失败时返回 false
。
fdf_get_attachment
Extracts uploaded file embedded in the FDF
说明
array <span
class="methodname">fdf_get_attachment ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $fieldname
, <span
class="methodparam">string $savepath
)
Extracts a file uploaded by means of the "file selection" field
fieldname
and stores it under savepath
.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
fieldname
savepath
May be the name of a plain file or an existing directory in which the
file is to be created under its original name. Any existing file under
the same name will be overwritten.
Note:
There seems to be no other way to find out the original filename but to store the file using a directory as
savepath
and check for the basename it was stored under.
返回值
The returned array contains the following fields:
path
- path were the file got storedsize
- size of the stored file in bytestype
- mimetype if given in the FDF
范例
示例 #1 Storing an uploaded file
<?php
$fdf = fdf_open_string($HTTP_FDF_DATA);
$data = fdf_get_attachment($fdf, "filename", "/tmpdir");
echo "The uploaded file is stored in $data[path]";
?>
fdf_get_encoding
Get the value of the /Encoding key
说明
string <span
class="methodname">fdf_get_encoding ( <span
class="methodparam">resource
$fdf_document
)
Gets the value of the /Encoding key.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
返回值
Returns the encoding as a string. An empty string is returned if the default PDFDocEncoding/Unicode scheme is used.
参见
- fdf_set_encoding
fdf_get_file
Get the value of the /F key
说明
string <span
class="methodname">fdf_get_file ( <span
class="methodparam">resource
$fdf_document
)
Gets the value of the /F key.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
返回值
Returns the key value, as a string.
参见
- fdf_set_file
fdf_get_flags
Gets the flags of a field
说明
int <span
class="methodname">fdf_get_flags ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $fieldname
, <span
class="methodparam">int $whichflags
)
Warning
本函数还未编写文档,仅有参数列表。
fdf_get_opt
Gets a value from the opt array of a field
说明
mixed <span
class="methodname">fdf_get_opt ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $fieldname
[, <span
class="methodparam">int $element
<span
class="initializer"> = -1 ] )
Warning
本函数还未编写文档,仅有参数列表。
fdf_get_status
Get the value of the /STATUS key
说明
string <span
class="methodname">fdf_get_status ( <span
class="methodparam">resource
$fdf_document
)
Gets the value of the /STATUS key.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
返回值
Returns the key value, as a string.
参见
- fdf_set_status
fdf_get_value
Get the value of a field
说明
mixed <span
class="methodname">fdf_get_value ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $fieldname
[, <span
class="methodparam">int $which
<span
class="initializer"> = -1 ] )
Gets the value for the requested field.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
fieldname
Name of the FDF field, as a string.
which
Elements of an array field can be retrieved by passing this optional
parameter, starting at zero. For non-array fields, this parameter will
be ignored.
返回值
Returns the field value.
更新日志
版本 | 说明 |
---|---|
4.3.0 | Support for arrays and the which parameter were added. |
参见
- fdf_set_value
fdf_get_version
Gets version number for FDF API or file
说明
string <span
class="methodname">fdf_get_version ([ <span
class="methodparam">resource
$fdf_document
] )
Return the FDF version for the given document, or the toolkit API version number if no parameter is given.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
返回值
Returns the version as a string. For the current FDF toolkit 5.0 the API version number is 5.0 and the document version number is either 1.2, 1.3 or 1.4.
参见
- fdf_set_version
fdf_header
Sets FDF-specific output headers
说明
void <span class="methodname">fdf_header ( <span class="methodparam">void )
This is a convenience function to set appropriate HTTP headers for FDF output. It sets the Content-type: to application/vnd.fdf.
返回值
没有返回值。
fdf_next_field_name
Get the next field name
说明
string <span
class="methodname">fdf_next_field_name ( <span
class="methodparam">resource
$fdf_document
[, <span
class="type">string $fieldname
] )
Gets the name of the field after the given field. This name can be used with several functions.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
fieldname
Name of the FDF field, as a string. If not given, the first field will
be assumed.
返回值
Returns the field name as a string.
范例
示例 #1 Detecting all fieldnames in a FDF
<?php
$fdf = fdf_open($HTTP_FDF_DATA);
for ($field = fdf_next_field_name($fdf);
$field != "";
$field = fdf_next_field_name($fdf, $field)) {
echo "field: $field\n";
}
?>
参见
- fdf_get_value
fdf_open_string
Read a FDF document from a string
说明
resource <span
class="methodname">fdf_open_string ( <span
class="methodparam">string $fdf_data
)
Reads form data from a string.
You can use fdf_open_string together
with $HTTP_FDF_DATA
to process FDF form input from a remote client.
参数
fdf_data
The data as returned from a PDF form or created using <span
class="function">fdf_create and <span
class="function">fdf_save_string.
返回值
Returns a FDF document handle, or false
on error.
范例
示例 #1 Accessing the form data
<?php
$fdf = fdf_open_string($HTTP_FDF_DATA);
/* ... */
fdf_close($fdf);
?>
参见
- fdf_open
- fdf_close
- fdf_create
- fdf_save_string
fdf_open
Open a FDF document
说明
resource <span
class="methodname">fdf_open ( <span
class="type">string $filename
)
Opens a file with form data.
You can also use fdf_open_string to process the results of a PDF form POST request.
参数
filename
Path to the FDF file. This file must contain the data as returned from a
PDF form or created using fdf_create and
fdf_save.
返回值
Returns a FDF document handle, or false
on error.
范例
示例 #1 Accessing the form data
<?php
// Save the FDF data into a temp file
$fdffp = fopen("test.fdf", "w");
fwrite($fdffp, $HTTP_FDF_DATA, strlen($HTTP_FDF_DATA));
fclose($fdffp);
// Open temp file and evaluate data
$fdf = fdf_open("test.fdf");
/* ... */
fdf_close($fdf);
?>
参见
- fdf_open_string
- fdf_close
- fdf_create
- fdf_save
fdf_remove_item
Sets target frame for form
说明
bool <span
class="methodname">fdf_remove_item ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $fieldname
, <span
class="methodparam">int $item
)
Warning
本函数还未编写文档,仅有参数列表。
fdf_save_string
Returns the FDF document as a string
说明
string <span
class="methodname">fdf_save_string ( <span
class="methodparam">resource
$fdf_document
)
Returns the FDF document as a string.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
返回值
Returns the document as a string, or false
on error.
范例
示例 #1 Retrieving FDF as a string
<?php
$fdf = fdf_create();
fdf_set_value($fdf, "foo", "bar");
$str = fdf_save_string($fdf);
fdf_close($fdf);
echo $str;
?>
以上例程会输出:
%FDF-1.2
%âãÏÓ
1 0 obj
<<
/FDF << /Fields 2 0 R >>
>>
endobj
2 0 obj
[
<< /T (foo)/V (bar)>>
]
endobj
trailer
<<
/Root 1 0 R
>>
%%EOF
参见
- fdf_open_string
- fdf_close
- fdf_create
- fdf_save
fdf_save
Save a FDF document
说明
bool fdf_save
( resource
$fdf_document
[, <span
class="type">string $filename
] )
Saves a FDF document.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
filename
If provided, the resulting FDF will be written in this parameter.
Otherwise, this function will write the FDF to the default PHP output
stream.
返回值
成功时返回 true
, 或者在失败时返回 false
。
参见
- fdf_close
- fdf_create
- fdf_save_string
fdf_set_ap
Set the appearance of a field
说明
bool <span
class="methodname">fdf_set_ap ( <span
class="type">resource $fdf_document
, <span
class="methodparam">string
$field_name
, <span
class="type">int $face
, <span
class="type">string $filename
, <span
class="methodparam">int $page_number
)
Sets the appearance of a field (i.e. the value of the /AP key).
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
field_name
face
The possible values FDFNormalAP
, FDFRolloverAP
and
FDFDownAP
.
filename
page_number
返回值
成功时返回 true
, 或者在失败时返回 false
。
fdf_set_encoding
Sets FDF character encoding
说明
bool <span
class="methodname">fdf_set_encoding ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $encoding
)
Sets the character encoding for the FDF document.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
encoding
The encoding name. The following values are supported: "Shift-JIS",
"UHC", "GBK" and "BigFive".
An empty string resets the encoding to the default PDFDocEncoding/Unicode scheme.
返回值
成功时返回 true
, 或者在失败时返回 false
。
fdf_set_file
Set PDF document to display FDF data in
说明
bool <span
class="methodname">fdf_set_file ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $url
[, <span
class="methodparam">string
$target_frame
] )
Selects a different PDF document to display the form results in then the form it originated from.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
url
Should be given as an absolute URL.
target_frame
Use this parameter to specify the frame in which the document will be
displayed. You can also set the default value for this parameter using
fdf_set_target_frame.
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 Passing FDF data to a second form
<?php
/* set content type for Adobe FDF */
fdf_header();
/* start new fdf */
$fdf = fdf_create();
/* set field "foo" to value "bar" */
fdf_set_value($fdf, "foo", "bar");
/* tell client to display FDF data using "fdf_form.pdf" */
fdf_set_file($fdf, "http://www.example.com/fdf_form.pdf");
/* output fdf */
fdf_save($fdf);
/* clean up */
fdf_close($fdf);
?>
参见
- fdf_get_file
- fdf_set_target_frame
fdf_set_flags
Sets a flag of a field
说明
bool <span
class="methodname">fdf_set_flags ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $fieldname
, <span
class="methodparam">int $whichFlags
,
int
$newFlags
)
Sets certain flags of the given field.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
fieldname
Name of the FDF field, as a string.
whichFlags
newFlags
返回值
成功时返回 true
, 或者在失败时返回 false
。
参见
- fdf_set_opt
fdf_set_javascript_action
Sets an javascript action of a field
说明
bool <span
class="methodname">fdf_set_javascript_action ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $fieldname
, <span
class="methodparam">int $trigger
,
string
$script
)
Sets a javascript action for the given field.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
fieldname
Name of the FDF field, as a string.
trigger
script
返回值
成功时返回 true
, 或者在失败时返回 false
。
参见
- fdf_set_submit_form_action
fdf_set_on_import_javascript
Adds javascript code to be executed when Acrobat opens the FDF
说明
bool <span
class="methodname">fdf_set_on_import_javascript ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $script
, <span
class="methodparam">bool
$before_data_import
)
Warning
本函数还未编写文档,仅有参数列表。
参见
- fdf_add_doc_javascript
- fdf_set_javascript_action
fdf_set_opt
Sets an option of a field
说明
bool <span
class="methodname">fdf_set_opt ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $fieldname
, <span
class="methodparam">int $element
,
string
$str1
, <span
class="type">string $str2
)
Sets options of the given field.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
fieldname
Name of the FDF field, as a string.
element
str1
str2
返回值
成功时返回 true
, 或者在失败时返回 false
。
参见
- fdf_set_flags
fdf_set_status
Set the value of the /STATUS key
说明
bool <span
class="methodname">fdf_set_status ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $status
)
Sets the value of the /STATUS key. When a client receives a FDF with a status set it will present the value in an alert box.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
status
返回值
成功时返回 true
, 或者在失败时返回 false
。
参见
- fdf_get_status
fdf_set_submit_form_action
Sets a submit form action of a field
说明
bool <span
class="methodname">fdf_set_submit_form_action ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $fieldname
, <span
class="methodparam">int $trigger
,
string
$script
, <span
class="type">int $flags
)
Sets a submit form action for the given field.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
fieldname
Name of the FDF field, as a string.
trigger
script
flags
返回值
成功时返回 true
, 或者在失败时返回 false
。
参见
- fdf_set_javascript_action
fdf_set_target_frame
Set target frame for form display
说明
bool <span
class="methodname">fdf_set_target_frame ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $frame_name
)
Sets the target frame to display a result PDF defined with <span class="function">fdf_save_file in.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
frame_name
The frame name, as a string.
返回值
成功时返回 true
, 或者在失败时返回 false
。
参见
- fdf_save_file
fdf_set_value
Set the value of a field
说明
bool <span
class="methodname">fdf_set_value ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $fieldname
, <span
class="methodparam">mixed $value
[,
int $isName
] )
Sets the value
for the given field.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
fieldname
Name of the FDF field, as a string.
value
This parameter will be stored as a string unless it is an array. In this
case all array elements will be stored as a value array.
isName
Note:
In older versions of the FDF toolkit last parameter determined if the field value was to be converted to a PDF Name (= 1) or set to a PDF String (= 0).
The value is no longer used in the current toolkit version 5.0. For compatibility reasons it is still supported as an optional parameter beginning with PHP 4.3, but ignored internally.
返回值
成功时返回 true
, 或者在失败时返回 false
。
更新日志
版本 | 说明 |
---|---|
4.3.0 | Support for arrays in the value parameter was added. |
参见
- fdf_get_value
- fdf_remove_item
fdf_set_version
Sets version number for a FDF file
说明
bool <span
class="methodname">fdf_set_version ( <span
class="methodparam">resource
$fdf_document
, <span
class="type">string $version
)
Sets the FDF version
for the given document.
Some features supported by this extension are only available in newer FDF versions.
参数
fdf_document
The FDF document handle, returned by <span
class="function">fdf_create, <span
class="function">fdf_open or <span
class="function">fdf_open_string.
version
The version number. For the current FDF toolkit 5.0, this may be either
1.2, 1.3 or 1.4.
返回值
成功时返回 true
, 或者在失败时返回 false
。
参见
- fdf_get_version
目录
- fdf_add_doc_javascript — Adds javascript code to the FDF document
- fdf_add_template — Adds a template into the FDF document
- fdf_close — Close an FDF document
- fdf_create — Create a new FDF document
- fdf_enum_values — Call a user defined function for each document value
- fdf_errno — Return error code for last fdf operation
- fdf_error — Return error description for FDF error code
- fdf_get_ap — Get the appearance of a field
- fdf_get_attachment — Extracts uploaded file embedded in the FDF
- fdf_get_encoding — Get the value of the /Encoding key
- fdf_get_file — Get the value of the /F key
- fdf_get_flags — Gets the flags of a field
- fdf_get_opt — Gets a value from the opt array of a field
- fdf_get_status — Get the value of the /STATUS key
- fdf_get_value — Get the value of a field
- fdf_get_version — Gets version number for FDF API or file
- fdf_header — Sets FDF-specific output headers
- fdf_next_field_name — Get the next field name
- fdf_open_string — Read a FDF document from a string
- fdf_open — Open a FDF document
- fdf_remove_item — Sets target frame for form
- fdf_save_string — Returns the FDF document as a string
- fdf_save — Save a FDF document
- fdf_set_ap — Set the appearance of a field
- fdf_set_encoding — Sets FDF character encoding
- fdf_set_file — Set PDF document to display FDF data in
- fdf_set_flags — Sets a flag of a field
- fdf_set_javascript_action — Sets an javascript action of a field
- fdf_set_on_import_javascript — Adds javascript code to be executed when Acrobat opens the FDF
- fdf_set_opt — Sets an option of a field
- fdf_set_status — Set the value of the /STATUS key
- fdf_set_submit_form_action — Sets a submit form action of a field
- fdf_set_target_frame — Set target frame for form display
- fdf_set_value — Set the value of a field
- fdf_set_version — Sets version number for a FDF file