@@ -64,45 +64,45 @@ class FPDM {
64
64
//@@@@@@@@@
65
65
66
66
67
- var $ pdf_source ; //string: full pathname to the input pdf , a form file
68
- var $ fdf_source ; //string: full pathname to the input fdf , a form data file
69
- var $ pdf_output ; //string: full pathname to the resulting filled pdf
70
-
71
- var $ pdf_entries ; //array: Holds the content of the pdf file as array
72
- var $ fdf_content ; //string: holds the content of the fdf file
73
- var $ fdf_parse_needed ;//boolean: false will use $fields data else extract data from fdf content
74
- var $ value_entries ; //array: a map of values to faliclitate access and changes
75
-
76
- var $ positions ; //array, stores what object id is at a given position n ($positions[n]=<obj_id>)
67
+ var $ pdf_source = '' ; //string: full pathname to the input pdf , a form file
68
+ var $ fdf_source = '' ; //string: full pathname to the input fdf , a form data file
69
+ var $ pdf_output = '' ; //string: full pathname to the resulting filled pdf
70
+
71
+ var $ pdf_entries = array () ; //array: Holds the content of the pdf file as array
72
+ var $ fdf_content = '' ; //string: holds the content of the fdf file
73
+ var $ fdf_parse_needed = false ;//boolean: false will use $fields data else extract data from fdf content
74
+ var $ value_entries = array () ; //array: a map of values to faliclitate access and changes
75
+
76
+ var $ positions = array () ; //array, stores what object id is at a given position n ($positions[n]=<obj_id>)
77
77
78
- var $ offsets ; //array of offsets for objects, index is the object's id, starting at 1
79
- var $ pointer ; //integer, Current line position in the pdf file during the parsing
78
+ var $ offsets = array () ; //array of offsets for objects, index is the object's id, starting at 1
79
+ var $ pointer = 0 ; //integer, Current line position in the pdf file during the parsing
80
80
81
- var $ shifts ; //array, Shifts of objects in the order positions they appear in the pdf, starting at 0.
82
- var $ shift ; //integer, Global shift file size due to object values size changes
81
+ var $ shifts = array () ; //array, Shifts of objects in the order positions they appear in the pdf, starting at 0.
82
+ var $ shift = 0 ; //integer, Global shift file size due to object values size changes
83
83
84
- var $ streams ; //Holds streams configuration found during parsing
85
- var $ streams_filter ; //Regexp to decode filter streams
84
+ var $ streams = '' ; //Holds streams configuration found during parsing
85
+ var $ streams_filter = '' ; //Regexp to decode filter streams
86
86
87
- var $ safe_mode ; //boolean, if set, ignore previous offsets do no calculations for the new xref table, seek pos directly in file
88
- var $ check_mode ; //boolean, Use this to track offset calculations errors in corrupteds pdfs files for sample
89
- var $ halt_mode ; //if true, stops when offset error is encountered
87
+ var $ safe_mode = false ; //boolean, if set, ignore previous offsets do no calculations for the new xref table, seek pos directly in file
88
+ var $ check_mode = false ; //boolean, Use this to track offset calculations errors in corrupteds pdfs files for sample
89
+ var $ halt_mode = false ; //if true, stops when offset error is encountered
90
90
91
- var $ info ; //array, holds the info properties
92
- var $ fields ; //array that holds fields-Data parsed from FDF
91
+ var $ info = array () ; //array, holds the info properties
92
+ var $ fields = array () ; //array that holds fields-Data parsed from FDF
93
93
94
- var $ verbose ; //boolean , a debug flag to decide whether or not to show internal process
95
- var $ verbose_level ; //integer default is 1 and if greater than 3, shows internal parsing as well
94
+ var $ verbose = false ; //boolean , a debug flag to decide whether or not to show internal process
95
+ var $ verbose_level = 1 ; //integer default is 1 and if greater than 3, shows internal parsing as well
96
96
97
- var $ support ; //string set to 'native' for fpdm or 'pdftk' for pdf toolkit
98
- var $ flatten_mode ; //if true, flatten field data as text and remove form fields (NOT YET SUPPORTED BY FPDM)
99
- var $ compress_mode ; //boolean , pdftk feature only to compress streams
100
- var $ uncompress_mode ; //boolean pdftk feature only to uncompress streams
101
- var $ security ; //Array holding securtity settings
97
+ var $ support = '' ; //string set to 'native' for fpdm or 'pdftk' for pdf toolkit
98
+ var $ flatten_mode = false ; //if true, flatten field data as text and remove form fields (NOT YET SUPPORTED BY FPDM)
99
+ var $ compress_mode = false ; //boolean , pdftk feature only to compress streams
100
+ var $ uncompress_mode = false ; //boolean pdftk feature only to uncompress streams
101
+ var $ security = array () ; //Array holding securtity settings
102
102
//(password owner nad user, encrypt (set to 40 or 128 or 0), allow <permissions>] see pdfk help
103
103
104
- var $ needAppearancesTrue ; //boolean, indicates if /NeedAppearances is already set to true
105
- var $ isUTF8 ; //boolean (true for UTF-8, false for ISO-8859-1)
104
+ var $ needAppearancesTrue = false ; //boolean, indicates if /NeedAppearances is already set to true
105
+ var $ isUTF8 = false ; //boolean (true for UTF-8, false for ISO-8859-1)
106
106
107
107
/**
108
108
* Constructor
@@ -112,7 +112,7 @@ class FPDM {
112
112
*@param string $fdf_source Source-Filename
113
113
*@param boolean $verbose , optional false per default
114
114
*/
115
- function FPDM () {
115
+ function __construct () {
116
116
//==============
117
117
118
118
$ args =func_get_args ();
@@ -617,7 +617,7 @@ function Output($dest='', $name=''){
617
617
$ this ->Error ($ ret ["return " ]);
618
618
}
619
619
620
- $ this ->buffer =$ this ->get_buffer ($ pdf_file );
620
+ // $this->buffer=$this->get_buffer($pdf_file);
621
621
622
622
623
623
$ dest =strtoupper ($ dest );
@@ -649,13 +649,13 @@ function Output($dest='', $name=''){
649
649
header ('Content-Type: application/pdf ' );
650
650
if (headers_sent ())
651
651
$ this ->Error ('Some data has already been output, can \'t send PDF file ' );
652
- header ('Content-Length: ' .strlen ($ this ->buffer ));
652
+ header ('Content-Length: ' .strlen ($ this ->get_buffer () ));
653
653
header ('Content-Disposition: inline; filename=" ' .$ name .'" ' );
654
654
header ('Cache-Control: private, max-age=0, must-revalidate ' );
655
655
header ('Pragma: public ' );
656
656
ini_set ('zlib.output_compression ' ,'0 ' );
657
657
}
658
- echo $ this ->buffer ;
658
+ echo $ this ->get_buffer () ;
659
659
break ;
660
660
case 'D ' :
661
661
//Download file
@@ -664,7 +664,7 @@ function Output($dest='', $name=''){
664
664
header ('Content-Type: application/x-download ' );
665
665
if (headers_sent ())
666
666
$ this ->Error ('Some data has already been output, can \'t send PDF file ' );
667
- header ('Content-Length: ' .strlen ($ this ->buffer ));
667
+ header ('Content-Length: ' .strlen ($ this ->get_buffer () ));
668
668
header ('Content-Disposition: attachment; filename=" ' .$ name .'" ' );
669
669
670
670
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT " ); // Date in the past
@@ -676,7 +676,7 @@ function Output($dest='', $name=''){
676
676
header ('Cache-Control: private, max-age=0, must-revalidate ' );
677
677
header ('Pragma: public,no-cache ' );
678
678
ini_set ('zlib.output_compression ' ,'0 ' );
679
- echo $ this ->buffer ;
679
+ echo $ this ->get_buffer () ;
680
680
break ;
681
681
case 'F ' :
682
682
//Save to local file
@@ -685,12 +685,12 @@ function Output($dest='', $name=''){
685
685
if (!$ f )
686
686
$ this ->Error ('Unable to create output file: ' .$ name .' (currently opened under Acrobat Reader?) ' );
687
687
688
- fwrite ($ f ,$ this ->buffer ,strlen ($ this ->buffer ));
688
+ fwrite ($ f ,$ this ->get_buffer () ,strlen ($ this ->get_buffer () ));
689
689
fclose ($ f );
690
690
break ;
691
691
case 'S ' :
692
692
//Return as a string
693
- return $ this ->buffer ;
693
+ return $ this ->get_buffer () ;
694
694
default :
695
695
$ this ->Error ('Incorrect output destination: ' .$ dest );
696
696
}
@@ -1111,7 +1111,7 @@ function get_xref_start_value() {
1111
1111
/**
1112
1112
* Read the offset of the xref table directly from file content
1113
1113
*
1114
- * @note content has been previously been defined in $this->buffer
1114
+ * @note content has been previously been defined in $this->get_buffer()
1115
1115
* @param int $object_id an object id, a integer value starting from 1
1116
1116
* @return int the wished xrefstart offset value
1117
1117
*/
@@ -1138,15 +1138,15 @@ function get_offset_object_value($object_id) {
1138
1138
static $ positions =null ;
1139
1139
static $ shifts =null ;
1140
1140
1141
- if (is_null ($ offsets )) { //...variables content set once. This is the beauty of php :)
1141
+ // if(is_null($offsets)) { //...variables content set once. This is the beauty of php :)
1142
1142
1143
1143
//!NOTE: xref table is ordered by object id (position's object is not defined linearly in the pdf !)
1144
1144
$ positions =$ this ->_get_positions_ordered ();
1145
1145
//Makes it 0 indexed as object id starts from 1 and positions starts from 0
1146
1146
$ offsets =$ this ->_get_offsets_starting_from_zero ();
1147
1147
//Shifts are already 0 indexed, don't change.
1148
1148
$ shifts =$ this ->shifts ;
1149
- }
1149
+ // }
1150
1150
1151
1151
$ p =$ positions [$ object_id ];
1152
1152
$ offset =$ offsets [$ p ];
@@ -1158,13 +1158,13 @@ function get_offset_object_value($object_id) {
1158
1158
/**
1159
1159
* Reads the offset of the xref table directly from file content
1160
1160
*
1161
- * @note content has been previously been defined in $this->buffer
1161
+ * @note content has been previously been defined in $this->get_buffer()
1162
1162
* @param int $object_id an object id, a integer value starting from 1
1163
1163
* @return int the wished offset
1164
1164
*/
1165
1165
function read_offset_object_value ($ object_id ) {
1166
1166
//------------------------------
1167
- $ buffer =$ this ->buffer ;
1167
+ $ buffer =$ this ->get_buffer () ;
1168
1168
$ previous_object_footer ='' ;//'endobj' or comment;
1169
1169
$ object_header =$ previous_object_footer .'\n ' .$ object_id .' 0 obj ' ;
1170
1170
$ chars = preg_split ('/ ' .$ object_header .'/ ' , $ buffer , -1 , PREG_SPLIT_OFFSET_CAPTURE );
@@ -1266,7 +1266,7 @@ function fix_xref_table() {
1266
1266
$ extract_offset_value_from_file =($ this ->safe_mode ||$ this ->check_mode );
1267
1267
1268
1268
//Get new file content (ie with values changed)
1269
- $ this ->buffer =$ this ->get_buffer ();
1269
+ // $this->get_buffer() =$this->get_buffer();
1270
1270
1271
1271
for ($ i =0 ;$ i <$ xLen ;$ i ++) {
1272
1272
@@ -2112,5 +2112,4 @@ function Error($msg) {
2112
2112
2113
2113
}
2114
2114
2115
- unset($ __tmp );
2116
- ?>
2115
+ unset($ __tmp );
0 commit comments