任何嵌入式文档查看器

发布于 2024-11-15 19:32:45 字数 244 浏览 4 评论 0原文

我希望在我的 CakePHP 应用程序中包含一个文档查看器,用于上传文档。我想要一个支持 Microsoft Word(.DOC 和 .DOCX)、Microsoft PowerPoint(.PPT 和 .PPTX)和 Adob​​e 便携式文档格式 (.PDF) 的查看器。

我希望我的用户能够查看文档,但不能下载。 Google 文档查看器很棒,但用户只需将 URL 插入地址栏即可下载文档。

我是否可以像可读文档一样与用户共享我的文档?

I am looking to include a document viewer in my CakePHP application for uploaded docs. I want a viewer that supports Microsoft Word (.DOC and .DOCX), Microsoft PowerPoint (.PPT and .PPTX) and Adobe Portable Document Format (.PDF).

I want my users to be able to view the documents, but not download it. Google document viewer is great, but users can just plug the URL into the address bar and download the document.

Is there anyway I can share my docs with users just as readable docs?

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

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

发布评论

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

评论(2

雨后咖啡店 2024-11-22 19:32:45

首先,您必须了解,当用户的浏览器显示某些文件/内容时,它已经在用户的计算机上。它已经被下载了。 “内容保留在服务器上,但用户可以看到它”并不存在魔法。数据总是从服务器传输到用户,并且用户可以以一种或另一种方式将数据保留在他的机器上。

如果您理解这一点,您有多种选择:

  • 您不关心拥有该文件的用户。这是最明智的选择。所有其他方法都是用户讨厌的某种“DRM”。
  • 仅将用户应看到的数据传输到浏览器:
    • 生成用户正在查看的文档部分的图像并将其发送到浏览器。用户没有文本数据,需要执行多次请求才能下载所有文档。
    • 编写一个浏览器插件(java、flash、javascript),从服务器读取加密文档,解密它们(同样,在用户的计算机上 - 这意味着他可以窥视它)并显示它。这样,用户不仅仅获得了文档,还需要对其进行解密。

存在现有的解决方案,即嵌入禁用下载选项的幻灯片共享演示文稿。不要尝试发明自己的东西,尤其是如果您不想在支持和持续增强方面走得更远的话。

First you must understand that when the user's browser displays some file/content, it is already on the user's machine. It has been downloaded already. There is no magic "the content stays on the server, but the user can see it". Data are always transferred from the server to the user, and the user can make the data stay on his machine - one way or another.

If you understood this, you have several options:

  • You do not care about the user having the file. This is the most sane option. All other methods are some sort of "DRM" which users hate.
  • Transfer the data the user shall see to the browser only:
    • generate an image of the part of the document the user is looking at and send that to the browser. The user has no text data and needs to do many requests to get all of the document downloaded.
    • write a browser plugin (java, flash, javascript) that reads encrypted documents from the server, unencrypts them (again, on the user's machine - which means he can peek into it) and displays it. This way, the user doesn't simply get the document but needs to decrypt it.

There are existing solutions, i.e. embedding slideshare presentations with disabled download option. Don't try to invent your own, especially not if you don't want to go the long way with support and continuous enhancements.

一梦浮鱼 2024-11-22 19:32:45

我使用谷歌文档查看器遵循以下指南。

  • 每次为文档生成随机 URL 地址(使用服务器端脚本和 htaccess。我使用 PHP 和 htaccess)。这不会让任何人直接访问该文件。
  • 使用 URL 对时间和日期进行编码(通过使用任何服务器字符串编码脚本),以便只能在特定时间(假设 5 分钟)内访问文件。
  • 仅通过匹配 Google 文档查看器用户代理来输出文件。这只会让 Google 文档查看器访问该文件,而其他人则无法访问,即使他们在浏览器中键入该地址也是如此。

这仍然不是一种非常安全的方法,但对我来说很有效。

I stick with the following guidelines using google document viewer.

  • Generate the random URL address everytime for the document (using server side scripting and htaccess. I am using PHP & htaccess). This will not give anyone direct access to the file.
  • Encode the time and date (by using any server string encoding script) with the URL so that file could be accessed only for certain time (let's say 5 minutes)
  • Output file only by matching Google Document Viewer User Agent. This will only give Google Document Viewer access to that file but no one else, even if they type that address in browser.

This is still not a very secure way but does the trick for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文