此HTML Word文档在OpenOffice.org中显示不正确 [英] This HTML Word document displays incorrectly in OpenOffice.org

查看:94
本文介绍了此HTML Word文档在OpenOffice.org中显示不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在php中有以下简单代码:

I have this simple code in php:

<?php

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

echo '<table cellspacing="0" cellpadding="0" border="0" width="8.4cm">
    <tr>
    <td colspan="3" style="text-align: right; height: 0.6cm">Nursery</td>
    </tr>
    <tr>
        <td style="height: 1.8cm"><img src="http://images.funadvice.com/photo/image/old/6943/tiny/cat.jpg" /></td>
        <td style="text-align: center; font-weight: bold">Sofia Abello</td>
    <td>&nbsp;</td>
    </tr> 
    <tr>
    <td style="text-align: left; height: 0.6cm">9AM Oct-12-08</td>
    <td>&nbsp;</td>
    <td style="text-align: right">Dance Studio</td>
    </tr>  
</table>';

?>

在MS Office Word上显示正常,但是,使用开放式Office书写器打开时,宽度会减小(不正确的宽度!).

displays ok with MS Office Word, however, width is reduced (not proper width!) when opened with open office writer.

推荐答案

您实际上是在将HTML导入MS Word和OpenOffice.org. HTML既不是Word也不是OpenOffice.org的本机格式,这意味着必须首先转换输入.

You are actually importing HTML into MS Word and OpenOffice.org. HTML is not the native format of neither Word nor OpenOffice.org, which means the input has to be converted first.

这些应用程序(其主要目的是以该应用程序的本机格式编辑文档)在这里做得并不完美也就不足为奇了.实际上-这不是一个大秘密-甚至不是Web浏览器,其主要目的 的HTML呈现在该领域也不是完美的.

It is no surprise that these applications (whose main purpose is the editing of documents in the application's native format) are doing not a perfect job there. In fact - and that's not a big secret - not even web browsers, whose main purpose is the rendering of HTML are not perfect in that area.

解决方案是提供在两个应用程序中均可使用的HTML.您可以使用条件注释来做到这一点,它是Microsoft对HTML的专有扩展,因此只能由微软产品.

The solution would be to provide HTML which works in both applications. You could do that using conditional comments which are a proprietary Microsoft extension to HTML and therefore only understood by Microsoft products.

这是您示例中的样子:

<![if !mso]>
<table cellspacing="0" cellpadding="0" border="0" width="8.4cm">
  <tr>
    <td>OpenOffice.org Version</td>
  </tr>
</table>
<![endif]>
<!--[if mso]>
<table cellspacing="0" cellpadding="0" border="0" width="8.4cm">
  <tr>
    <td>Microsoft Word version</td>
  </tr>
</table>
<![endif]-->

这篇关于此HTML Word文档在OpenOffice.org中显示不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆