extract_pages( $file_path ) ); } /** Extract each physical PDF page, preserving blank-page numbering. */ public function extract_pages( string $file_path ): array { if ( ! file_exists( $file_path ) ) { Logger::error( 'PdfExtractor failed: File does not exist.', array( 'path' => $file_path ) ); return array(); } try { $parser = new \Smalot\PdfParser\Parser(); $pdf = $parser->parseFile( $file_path ); $pages = array(); foreach ( $pdf->getPages() as $index => $page ) { $pages[ $index + 1 ] = TextHelper::clean_text( $page->getText() ); } return $pages; } catch ( \Exception $e ) { Logger::error( 'PdfExtractor failed: ' . $e->getMessage(), array( 'path' => $file_path ) ); return array(); } } }