What potential challenges may arise when trying to search PDF files using PHP, especially if the files are compressed or contain non-text elements?

When searching PDF files using PHP, potential challenges may arise when the files are compressed or contain non-text elements. To overcome this, you can use a library like `pdftotext` to extract text from PDF files before searching them. This way, you can ensure that the content is readable and searchable.

// Use pdftotext to extract text from PDF file
$pdfFile = 'example.pdf';
$text = shell_exec("pdftotext $pdfFile -");

// Search for a specific keyword in the extracted text
$keyword = 'example';
if (stripos($text, $keyword) !== false) {
    echo "Keyword found in PDF file.";
} else {
    echo "Keyword not found in PDF file.";
}