how to search pdf in folder using php

Solutions on MaxInterview for how to search pdf in folder using php by the best coders in the world

showing results for - "how to search pdf in folder using php"
Damien
04 Feb 2016
1>");
2		if (is_array($a_filter)){
3			$j++;
4			$a_chunks[$j]["filter"] = $a_filter[0];
5
6			$a_data = getDataArray($obj,"stream\r\n","endstream");
7			if (is_array($a_data)){
8				$a_chunks[$j]["data"] = substr($a_data[0],strlen("stream\r\n"),strlen($a_data[0])-strlen("stream\r\n")-strlen("endstream"));
9			}
10		}
11	}
12
13	// decode the chunks
14	foreach($a_chunks as $chunk){
15
16		// look at each chunk and decide how to decode it - by looking at the contents of the filter
17		$a_filter = split("/",$chunk["filter"]);
18		
19		if ($chunk["data"]!=""){
20			// look at the filter to find out which encoding has been used			
21			if (substr($chunk["filter"],"FlateDecode")!==false){
22				$data =@ gzuncompress($chunk["data"]);
23				if (trim($data)!=""){
24					$result_data .= ps2txt($data);
25				} else {
26				
27					//$result_data .= "x";
28				}
29			}
30		}
31	}
32	
33	return $result_data;
34	
35}
36
37
38// Function    : ps2txt()
39// Arguments   : $ps_data - postscript data you want to convert to plain text
40// Description : Does a very basic parse of postscript data to
41//               return the plain text
42// Author      : Jonathan Beckett, 2005-05-02
43function ps2txt($ps_data){
44	$result = "";
45	$a_data = getDataArray($ps_data,"[","]");
46	if (is_array($a_data)){
47		foreach ($a_data as $ps_text){
48			$a_text = getDataArray($ps_text,"(",")");
49			if (is_array($a_text)){
50				foreach ($a_text as $text){
51					$result .= substr($text,1,strlen($text)-2);
52				}
53			}
54		}
55	} else {
56		// the data may just be in raw format (outside of [] tags)
57		$a_text = getDataArray($ps_data,"(",")");
58		if (is_array($a_text)){
59			foreach ($a_text as $text){
60				$result .= substr($text,1,strlen($text)-2);
61			}
62		}
63	}
64	return $result;
65}
66
67
68// Function    : getFileData()
69// Arguments   : $filename - filename you want to load
70// Description : Reads data from a file into a variable
71//               and passes that data back
72// Author      : Jonathan Beckett, 2005-05-02
73function getFileData($filename){
74	$handle = fopen($filename,"rb");
75	$data = fread($handle, filesize($filename));
76	fclose($handle);
77	return $data;
78}
79
80
81// Function    : getDataArray()
82// Arguments   : $data       - data you want to chop up
83//               $start_word - delimiting characters at start of each chunk
84//               $end_word   - delimiting characters at end of each chunk
85// Description : Loop through an array of data and put all chunks
86//               between start_word and end_word in an array
87// Author      : Jonathan Beckett, 2005-05-02
88function getDataArray($data,$start_word,$end_word){
89
90	$start = 0;
91	$end = 0;
92	unset($a_result);
93	
94	while ($start!==false && $end!==false){
95		$start = strpos($data,$start_word,$end);
96		if ($start!==false){
97			$end = strpos($data,$end_word,$start);
98			if ($end!==false){
99				// data is between start and end
100				$a_result[] = substr($data,$start,$end-$start+strlen($end_word));
101			}
102		}
103	}
104	return $a_result;
105}
106
107?>
108