how to get table and text value of phpword here i m try to read table as well as text value which i m getting from doc file(getting from database)
here is my code
if($element instanceof PhpOffice\PhpWord\Element\Text) why this line is not working
i had taken this code from github
https://github.com/PHPOffice/PHPWord/issues/768
but it not working please suggest any solution what i m try to do is converting doc into html so i can display it into browser
What is the error or what do you see?
it not going in if condition
i have value i cheched it using dd
foreach($phpWord->getSections() as $section) {
foreach($section->getElements() as $element) {
if($element instanceof PhpOffice\PhpWord\Element\Text)
{
dd('h');
echo($element->getText() . "<br><br>");
}
else{
it come here instead of if condition
}
}
And what about dd($element); to see the type?
@bashy it have array value
#Text: array:1 [▶]
#Table: array:1 [▶]
#TextRun:array:1 [▶]
and i want to access Table value
if($element instanceof PhpOffice\PhpWord\Element\Table)
since i have Table in element array so why above if condition not working it getting out if condition(else)
@bipin Then that's not an instance of Table alone is it?
yes, if i use this if condition if(!$element->getText()==null) then it work perfectly
If this is the response, you can't do if ($element instanceof Table) since it's not an instance of.
#Text: array:1 [▶]
#Table: array:1 [▶]
#TextRun:array:1 [▶]
@bashy is there any package which convert doc, docx or any other file to PDF
@Kaustubh I don't know of any myself. Had a search around? Saw a few from "laravel doc to pdf" search.
@bashy element->getText working ,is there any other way
@bipin Sorry, haven't looked at anything like this before.
Please sign in or create an account to participate in this conversation.