Pravin Work
Pravin Work

Reputation: 258

Reading PDF file with PHPWord library

I have tried reading the .docx file. I am successful in reading the .docx file. But I have to read .pdf file with PHPWord.

Any idea How can I do it?

I have tried the code

// Read contents
$source = "./example.pdf";
$phpWord = \PhpOffice\PhpWord\IOFactory::load($source, 'Word2007');

$data = '';
$section = $phpWord->addSection();
$section->addText($data);

$name = "officefile";
$source = __DIR__ . "/results/{$name}.html";

// Saving the document as HTML file...
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
$objWriter->save($source);

Upvotes: 0

Views: 1643

Answers (1)

Jacob Mulquin
Jacob Mulquin

Reputation: 3608

PHPWord cannot read PDF files. Please see this Github issue too see that it is out of scope of the project.

Some alternative methods of reading PDF files with PHP can be found in this Stackoverflow question.

Upvotes: 1

Related Questions