@@ -64,45 +64,45 @@ class FPDM {
6464 //@@@@@@@@@
6565
6666
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>)
7777
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
8080
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
8383
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
8686
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
9090
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
9393
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
9696
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
102102 //(password owner nad user, encrypt (set to 40 or 128 or 0), allow <permissions>] see pdfk help
103103
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)
106106
107107 /**
108108 * Constructor
@@ -112,7 +112,7 @@ class FPDM {
112112 *@param string $fdf_source Source-Filename
113113 *@param boolean $verbose , optional false per default
114114 */
115- function FPDM () {
115+ function __construct () {
116116 //==============
117117
118118 $ args =func_get_args ();
@@ -617,7 +617,7 @@ function Output($dest='', $name=''){
617617 $ this ->Error ($ ret ["return " ]);
618618 }
619619
620- $ this ->buffer =$ this ->get_buffer ($ pdf_file );
620+ // $this->buffer=$this->get_buffer($pdf_file);
621621
622622
623623 $ dest =strtoupper ($ dest );
@@ -649,13 +649,13 @@ function Output($dest='', $name=''){
649649 header ('Content-Type: application/pdf ' );
650650 if (headers_sent ())
651651 $ 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 () ));
653653 header ('Content-Disposition: inline; filename=" ' .$ name .'" ' );
654654 header ('Cache-Control: private, max-age=0, must-revalidate ' );
655655 header ('Pragma: public ' );
656656 ini_set ('zlib.output_compression ' ,'0 ' );
657657 }
658- echo $ this ->buffer ;
658+ echo $ this ->get_buffer () ;
659659 break ;
660660 case 'D ' :
661661 //Download file
@@ -664,7 +664,7 @@ function Output($dest='', $name=''){
664664 header ('Content-Type: application/x-download ' );
665665 if (headers_sent ())
666666 $ 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 () ));
668668 header ('Content-Disposition: attachment; filename=" ' .$ name .'" ' );
669669
670670 header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT " ); // Date in the past
@@ -676,7 +676,7 @@ function Output($dest='', $name=''){
676676 header ('Cache-Control: private, max-age=0, must-revalidate ' );
677677 header ('Pragma: public,no-cache ' );
678678 ini_set ('zlib.output_compression ' ,'0 ' );
679- echo $ this ->buffer ;
679+ echo $ this ->get_buffer () ;
680680 break ;
681681 case 'F ' :
682682 //Save to local file
@@ -685,12 +685,12 @@ function Output($dest='', $name=''){
685685 if (!$ f )
686686 $ this ->Error ('Unable to create output file: ' .$ name .' (currently opened under Acrobat Reader?) ' );
687687
688- fwrite ($ f ,$ this ->buffer ,strlen ($ this ->buffer ));
688+ fwrite ($ f ,$ this ->get_buffer () ,strlen ($ this ->get_buffer () ));
689689 fclose ($ f );
690690 break ;
691691 case 'S ' :
692692 //Return as a string
693- return $ this ->buffer ;
693+ return $ this ->get_buffer () ;
694694 default :
695695 $ this ->Error ('Incorrect output destination: ' .$ dest );
696696 }
@@ -1111,7 +1111,7 @@ function get_xref_start_value() {
11111111 /**
11121112 * Read the offset of the xref table directly from file content
11131113 *
1114- * @note content has been previously been defined in $this->buffer
1114+ * @note content has been previously been defined in $this->get_buffer()
11151115 * @param int $object_id an object id, a integer value starting from 1
11161116 * @return int the wished xrefstart offset value
11171117 */
@@ -1138,15 +1138,15 @@ function get_offset_object_value($object_id) {
11381138 static $ positions =null ;
11391139 static $ shifts =null ;
11401140
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 :)
11421142
11431143 //!NOTE: xref table is ordered by object id (position's object is not defined linearly in the pdf !)
11441144 $ positions =$ this ->_get_positions_ordered ();
11451145 //Makes it 0 indexed as object id starts from 1 and positions starts from 0
11461146 $ offsets =$ this ->_get_offsets_starting_from_zero ();
11471147 //Shifts are already 0 indexed, don't change.
11481148 $ shifts =$ this ->shifts ;
1149- }
1149+ // }
11501150
11511151 $ p =$ positions [$ object_id ];
11521152 $ offset =$ offsets [$ p ];
@@ -1158,13 +1158,13 @@ function get_offset_object_value($object_id) {
11581158 /**
11591159 * Reads the offset of the xref table directly from file content
11601160 *
1161- * @note content has been previously been defined in $this->buffer
1161+ * @note content has been previously been defined in $this->get_buffer()
11621162 * @param int $object_id an object id, a integer value starting from 1
11631163 * @return int the wished offset
11641164 */
11651165 function read_offset_object_value ($ object_id ) {
11661166 //------------------------------
1167- $ buffer =$ this ->buffer ;
1167+ $ buffer =$ this ->get_buffer () ;
11681168 $ previous_object_footer ='' ;//'endobj' or comment;
11691169 $ object_header =$ previous_object_footer .'\n ' .$ object_id .' 0 obj ' ;
11701170 $ chars = preg_split ('/ ' .$ object_header .'/ ' , $ buffer , -1 , PREG_SPLIT_OFFSET_CAPTURE );
@@ -1266,7 +1266,7 @@ function fix_xref_table() {
12661266 $ extract_offset_value_from_file =($ this ->safe_mode ||$ this ->check_mode );
12671267
12681268 //Get new file content (ie with values changed)
1269- $ this ->buffer =$ this ->get_buffer ();
1269+ // $this->get_buffer() =$this->get_buffer();
12701270
12711271 for ($ i =0 ;$ i <$ xLen ;$ i ++) {
12721272
@@ -2112,5 +2112,4 @@ function Error($msg) {
21122112
21132113}
21142114
2115- unset($ __tmp );
2116- ?>
2115+ unset($ __tmp );
0 commit comments