Getting html tags to show up in word

Viewed 28

I'm using laravel and I have a summernote as my textarea. The issue I'm having is that, if I add some styling to my text in summernote for example I have a bold text. So in my database I have <p><b>Bold Text</b></p> and when I call it in for my word document I want it to display the text in bold.

For my word document generator I'm using phpoffice/phpword

$post->content is where the styling from summernote gets stored

$post = Post::find(1);

$postArr = [
 'title' => $post->title,
 'content' => $post->content
]

return $postArr;

I have tried {!! $postArr['content'] !!}, but I get an error saying

Word experienced an error trying to open the file

In my blade I have this

<w:p>
    <w:pPr>
        <w:rPr>
            <w:lang w:val="en-US"/>
        </w:rPr>
    </w:pPr>
</w:p>
<w:p>
    <w:pPr>
        <w:pStyle w:val="Heading2"/>
        <w:rPr>
            <w:lang w:val="en-US"/>
        </w:rPr>
    </w:pPr>
    <w:r>
        <w:rPr>
            <w:lang w:val="en-US"/>
        </w:rPr>
        <w:t>{!! $postArr['title'] !!}</w:t>
    </w:r>
</w:p>
<w:p>
    <w:pPr>
        <w:rPr>
            <w:lang w:val="en-US"/>
        </w:rPr>
    </w:pPr>
</w:p>

<w:p>
    <w:pPr>
        <w:rPr>
            <w:lang w:val="en-US"/>
        </w:rPr>
    </w:pPr>
</w:p>
<w:p>
    <w:pPr>
        <w:rPr>
            <w:lang w:val="en-US"/>
        </w:rPr>
    </w:pPr>
    <w:r>
        <w:rPr>
            <w:lang w:val="en-US"/>
        </w:rPr>
        <w:t>{!! $postArr['content'] !!}</w:t>
    </w:r>
</w:p>
0 Answers
Related