Location: PHPKode > scripts > pdf_search > pdf_search/pdf_example.php
<?

/**********************************************************************
**
** Example script that goes with the pdf_search class.
**
** License: Public Domain
** Warranty: None
**
** Author: Rene Kluwen / Chimit Software <hide@address.com>
**
***********************************************************************/

require("pdfsearch.php");

// The following determines the document to search in.
$theDocument = "MyDocument.pdf";

// The text to search for. Usually we get this as a result of a form
// submit.
$searchText = "marbles";

// First we read the document into memory space.
// Also, pdf documents can be read from a database or otherwise
// (which is what I did when writing the class).
$fp = fopen($theDocument, "r");
$content = fread($fp, filesize($theDocument));
fclose($fp);

// Allocate class instance
$pdf = new pdf_search($content);

// And do the search
if ($pdf->textfound($searchText)) {
    echo "We found $searchText.";
}
else {
    echo "$searchText was not found.";
}

?>
Return current item: pdf_search