how to search in pdf files using php predefined classes?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
hannnndy
Forum Contributor
Posts: 131
Joined: Sat Jan 12, 2008 2:09 am
Location: Iran>Tehran
Contact:

how to search in pdf files using php predefined classes?

Post by hannnndy »

hi,

I have no idea how to search in pdf files have you any idea or suggestion or even function that can help me doing so?

please leave me a simple sample codes to understand?

Code: Select all

function pdf_search($buffer) {
$this->_buffer = $buffer;
}
 
// This function returns the next line from the document. If a stream follows, it is deflated into readable text.
function nextline() {
$pos = strpos($this->_buffer, "\r");
if ($pos === false) {
return false;
}
$line = substr($this->_buffer, 0, $pos);
$this->_buffer = substr($this->_buffer, $pos + 1);
 
if ($line == "stream") {
$endpos = strpos($this->_buffer, "endstream");
$stream = substr($this->_buffer, 1, $endpos - 1);
$stream = @gzuncompress($stream);
$this->_buffer = $stream . substr($this->_buffer, $endpos + 9);
}
return $line;
}
is there any better way to do so?
User avatar
hannnndy
Forum Contributor
Posts: 131
Joined: Sat Jan 12, 2008 2:09 am
Location: Iran>Tehran
Contact:

Re: how to search in pdf files using php predefined classes?

Post by hannnndy »

thanks for reply
Actually that would not help me because it is a little complex I need something object oriented like a class
and calling only a method of it have you any better idea?
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: how to search in pdf files using php predefined classes?

Post by Ambush Commander »

As far as I can tell, PDFlib is OO...

There might be some pure PHP PDF reading classes to use, but most of the ones out there are for generating PDFs.
User avatar
hannnndy
Forum Contributor
Posts: 131
Joined: Sat Jan 12, 2008 2:09 am
Location: Iran>Tehran
Contact:

Re: how to search in pdf files using php predefined classes?

Post by hannnndy »

so have you any idea for me what to do?
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: how to search in pdf files using php predefined classes?

Post by Ambush Commander »

I don't know what you want to do. Therefore, I can't say. :-)
User avatar
hannnndy
Forum Contributor
Posts: 131
Joined: Sat Jan 12, 2008 2:09 am
Location: Iran>Tehran
Contact:

Re: how to search in pdf files using php predefined classes?

Post by hannnndy »

easily there is a pdf file named name.pdf

I need afunction to open that and find the specific string in it like "sample text" and gives me the count of the string in df file or even the page string occured in it

just this nothing more !!!
Post Reply