如何在HTML页面中嵌入文档?

时间:2011-04-06 11:43:18

标签: javascript html servlets browser-plugin

我们希望在从html页面检索文档后显示该文档(例如pptxxlsxdocxpdfhtml)数据库通过servlet的doGet方法 任何人都可以分享一些关于如何实现这一目标的片段吗?

3 个答案:

答案 0 :(得分:20)

除了图像之外的非html内容需要使用object,embed或iframe标记

进行检索
  1. iframe <iframe src="somepage.pdf"></iframe>
  2. object / embed <object src="somepage.pdf"><embed src="somepage.pdf"></embed></object>
  3. somepage.pdf可能是somepage.jsp?filename = somepage&amp; mimetype = application / pdf

    这是一个有趣的链接How to Embed Microsoft Office or PDF Documents in Web Pages

    这是一个stackoverflow search

答案 1 :(得分:7)

Google文档查看器可以处理此问题。

尝试

<html>
    <head>
        <style>
            *{margin:0;padding:0}
            html, body {height:100%;width:100%;overflow:hidden}
        </style>
        <meta charset="utf-8">
            <?php
                 $url = $_GET['url'];
             ?>
        <title><?php echo $url; ?></title>
    </head>
    <body>
        <iframe src="http://docs.google.com/viewer?url=<?=urlencode($url)?>&embedded=true"  style="position: absolute;width:100%; height: 100%;border: none;"></iframe>
    </body>
</html>

答案 2 :(得分:0)

如果您正在寻找文档的纯HTML版本(用于快速呈现和跨浏览器支持),您可以浏览Docspad。 Docspad帮助将所有不同的流行文档格式嵌入到您的Web应用程序中。 http://docspad.com

相关问题