selimppc

pdf_example.php

Jan 18th, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. <?
  2.  
  3. /**********************************************************************
  4. **
  5. ** Example script that goes with the pdf_search class.
  6. **
  7. ** License: Public Domain
  8. ** Warranty: None
  9. **
  10. ** Author: Rene Kluwen / Chimit Software <[email protected]>
  11. **
  12. ***********************************************************************/
  13.  
  14. require("pdfsearch.php");
  15.  
  16. // The following determines the document to search in.
  17. $theDocument = "MyDocument.pdf";
  18.  
  19. // The text to search for. Usually we get this as a result of a form
  20. // submit.
  21. $searchText = "marbles";
  22.  
  23. // First we read the document into memory space.
  24. // Also, pdf documents can be read from a database or otherwise
  25. // (which is what I did when writing the class).
  26. $fp = fopen($theDocument, "r");
  27. $content = fread($fp, filesize($theDocument));
  28. fclose($fp);
  29.  
  30. // Allocate class instance
  31. $pdf = new pdf_search($content);
  32.  
  33. // And do the search
  34. if ($pdf->textfound($searchText)) {
  35.     echo "We found $searchText.";
  36. }
  37. else {
  38.     echo "$searchText was not found.";
  39. }
  40.  
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment