What are common pitfalls when trying to extract text from a PDF using PHP?

Common pitfalls when trying to extract text from a PDF using PHP include not handling special characters properly, not accounting for different encoding formats, and not considering the layout of the PDF which can affect the order of text extraction. To solve these issues, it is important to use a reliable library like `pdftotext` or `TCPDF` that can handle these complexities and provide accurate text extraction.

// Using pdftotext library for text extraction
$pdfFile = 'example.pdf';
$text = shell_exec("pdftotext $pdfFile -");
echo $text;