Login   Register  
PHP Classes
elePHPant
Icontem

File: pdf_example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Rene Kluwen  >  pdf_search  >  pdf_example.php  >  Download  
File: pdf_example.php
Role: Example script
Content type: text/plain
Description: Example usage
Class: pdf_search
Searches pdf documents for text
Author: By
Last change: Added author
Date: 2002-08-23 00:37
Size: 1,048 bytes
 

Contents

Class file image Download
<?

/**********************************************************************
**
** Example script that goes with the pdf_search class.
**
** License: Public Domain
** Warranty: None
**
** Author: Rene Kluwen / Chimit Software <rene.kluwen@chimit.nl>
**
***********************************************************************/

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($fpfilesize($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.";
}

?>