亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將刀片布局傳遞給 phpword

將刀片布局傳遞給 phpword

PHP
HUWWW 2021-06-16 09:17:48
我在 phpword 中使用 Laravel。所以在這里我想將 html 布局從刀片文件導出到 word。但是當我嘗試創建它時,出現的錯誤: DOMDocument::loadXML(): Opening and ending tag mismatch: link line 1 and head in Entity, line: 1我的代碼:$content = view('docs.index')->render();$dom = new DOMDocument();$dom->loadHTML($content);$dom->saveHTML();$phpWord = new PhpWord();Html::addHtml($phpWord->addSection(), $dom->saveHTML(), true);$objWriter = IOFactory::createWriter($phpWord, 'Word2007');$objWriter->save('doc_index_'.Carbon::now()->format('d-m-y h-i').'.docx');return view('papers.show')->with('success');這是我的刀片文件:<!DOCTYPE html><html><head>    <title>Doc HTML</title>    <meta charset="utf-8">    <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css" /></head><body><div>    <p>        Laravel is a web application framework with expressive, elegant syntax. <br />        We believe development must be an enjoyable and creative experience to be truly fulfilling. <br />        Laravel takes the pain out of development by easing common tasks used in many web projects. <br />    </p></div></body></html>打印我的 $content 變量:"""<!DOCTYPE html><html><head>    <title>Doc HTML</title>    <meta charset="utf-8" />    <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css" /></head><body><div>    <p>        Laravel is a web application framework with expressive, elegant syntax. <br />        We believe development must be an enjoyable and creative experience to be truly fulfilling. <br />        Laravel takes the pain out of development by easing common tasks used in many web projects. <br />    </p></div></body></html>"""
查看完整描述

3 回答

?
阿晨1998

TA貢獻2037條經驗 獲得超6個贊

您的<meta>標簽在技術上沒有關閉。要遵循省略結束標記的元素的規范,它們必須以/>. 因此,您擁有的<br /><link ... />您的元標記應該是怎樣的<meta ... />。


查看完整回答
反對 回復 2021-06-19
?
人到中年有點甜

TA貢獻1895條經驗 獲得超7個贊

<!DOCTYPE html>模板開頭的部分導致了該錯誤。關于讀取樣式文件,從上面討論PHPWord/Html.php 中提供的函數詳細信息的鏈接,您可以看到 addHtml 將只使用 body 標記的內容而忽略其他所有內容。

關于上述討論中的另一個問題,我認為 PHPWord 不支持來自 css 文件的任何類型的樣式包含 - 在這個特定示例中,我不確定將引導響應式樣式應用于 word 文檔的預期結果是什么內容。


查看完整回答
反對 回復 2021-06-19
  • 3 回答
  • 0 關注
  • 257 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號