php - Reading PDF file with PHPWord library
Get the solution ↓↓↓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);
Answer
Solution:
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.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: illuminate\http\exceptions\posttoolargeexception
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.