PHP到DOC - CSS和图像未在doc文件中应用

时间:2014-07-24 12:04:30

标签: php html css doc

我在PHP的帮助下创建了doc文件  的 doc.php:

<?php
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=document_name.doc");

echo "<html>";
echo "<meta http-equiv='\Content-Type\' content='\text/html'; charset='Windows-1252'>";
echo "<head><link rel='stylesheet' type='text/css' href='../doc.css'></head>"; 
echo "<body>";
echo "<b>My first document</b><img src='../images/logo.png'>";
echo "</body>";
echo "</html>";
?>

执行此文件后,'document_name.doc'文件正在创建,但没有应用css和图像。

任何解决方案?

1 个答案:

答案 0 :(得分:1)

您可以尝试使用标题:

<html>
    <meta http-equiv='\Content-Type\' content='\text/html'; charset='Windows-1252'>
    <head>
        <link rel='stylesheet' type='text/css' href='../doc.css'>
    </head>
    <body>enter code here
        <b>My first document</b>
        <img src='../images/logo.png'>
    </body>
</html>

如果您设计并创建word文档,可以查看PHPWord