允许 内容类型中的标签:application/msword
现在,我一切都很好。它根据我的 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']." ".$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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Word 中打开时,图像不会出现,因为 Word 正在客户端桌面上运行并在本地查找图像...除非您为图像文件指定完整 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: