允许 内容类型中的标签:application/msword

发布于 2024-10-14 08:07:52 字数 1283 浏览 5 评论 0原文

现在,我一切都很好。它根据我的 CSS 打印(text-align: center;)。
我唯一的问题是图像。这是 HTML 代码:

<table id="cert">  
    <td>  
        <tr><h1>Singapore Aviation Academy</h1></tr>  
        <tr><img src = "img/logo1.jpg" /></tr>  
        <tr><h2>Certificate of Completion </h2></tr>  
        <tr>is hereby granted to</tr>  
        <tr><?php echo "<b>".$row['fname']."&nbsp;&nbsp;".$row['lname']."</b>"; ?> </tr>  
        <tr>to certify that he/she has completed to satisfaction for</tr>  
        <tr><?php echo "<b>".$row1['course_title']."</b>"; ?></tr>  
    </td>  
</table>  

紧接着:

<?php       
//This php will enable documents to be embedded with Microsoft Word

header("Content-type: application/msword"); //Document will be embedded using the application, Microsoft Word  
header("Content-disposition: attachment; filename= \"Certificate for ".$row['fname']." ".$row['lname']."\""); //States the file name when opened to edit or view  
?>

问题出在 标记中。如果没有最后几行 PHP 代码,图像就会出现。有了它,图像就不会显示在 MS-Word 中。

知道如何解决这个问题吗?

Right now, I have everything fine. It prints according to my CSS (text-align: center;).
the only problem I have is with the image. This is the HTML code:

<table id="cert">  
    <td>  
        <tr><h1>Singapore Aviation Academy</h1></tr>  
        <tr><img src = "img/logo1.jpg" /></tr>  
        <tr><h2>Certificate of Completion </h2></tr>  
        <tr>is hereby granted to</tr>  
        <tr><?php echo "<b>".$row['fname']."  ".$row['lname']."</b>"; ?> </tr>  
        <tr>to certify that he/she has completed to satisfaction for</tr>  
        <tr><?php echo "<b>".$row1['course_title']."</b>"; ?></tr>  
    </td>  
</table>  

Right after that:

<?php       
//This php will enable documents to be embedded with Microsoft Word

header("Content-type: application/msword"); //Document will be embedded using the application, Microsoft Word  
header("Content-disposition: attachment; filename= \"Certificate for ".$row['fname']." ".$row['lname']."\""); //States the file name when opened to edit or view  
?>

The problem is in that <img> tag. Without the last lines of PHP codes, the image appears. With it, the image just won't show in the MS-Word.

Any idea how to solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

要走就滚别墨迹 2024-10-21 08:07:52

在 Word 中打开时,图像不会出现,因为 Word 正在客户端桌面上运行并在本地查找图像...除非您为图像文件指定完整 URL,否则它不会在您的服务器上查找。

选项:

  • 修改您的 HTML,以便嵌入图像二进制文件而不是链接
  • 使用图像的完整 URL
  • 创建“真实”Word 文档,其中图像正确嵌入而不是作为链接
  • 创建图像嵌入而不是链接的 PDF ,或使用完整 URL 链接

The image won't appear when opened in Word because word is running on the client's desktop and looking for the image locally... unless you specify a full URL for the image file, it doesn't know to look on your server.

Options:

  • Modify your HTML so the image binary is embedded rather than a link
  • Use the full URL for your image
  • Create a "real" word document, with the image correctly embedded rather than as a link
  • Create a PDF with the image embedded rather than linked, or linked using the full URL
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文