自定义file_view以在浏览器中查看pdf [英] Customise file_view to view pdfs in the browser
问题描述
我仍在为内部网运行Plone 3.0.6.我曾尝试升级到当前版本,但始终遇到障碍.当我有更多时间时,我会再去那儿.
I am still running Plone 3.0.6 for our Intranet. I have tried to upgrade to current version, but always come up against a road block. I'll have another go at that later when I have more time.
现在,我只需要自定义/portal_skins/plone_content/file_view即可在浏览器中打开pdf附件,而无需下载它们.我们正在安装一个新的信息亭系统,该信息亭系统将在浏览器中显示PDF,但无法浏览和查看文件系统中的文件.
For now, I just need to customise /portal_skins/plone_content/file_view to make it open pdf attachments in the browser instead of downloading them. We are installing a new kiosk system that will display PDFs in the browser but can't browse and view files in the filesystem.
我已经进行了很多搜索,发现其他人已经这样做了,但是还没有找到我正在运行的版本.我不是任何类型的开发人员,所以我不知道如何做他们在系统上所做的事情.
I've done a lot of searching and found others who have done this, but not for the version I'm running. I'm not a developer of any sort, so I can't figure out how to do what they have done on my system.
这是file_view的当前代码.
Here is the current code for file_view.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="here/main_template/macros/master"
i18n:domain="plone">
<body>
<div metal:fill-slot="main">
<tal:main-macro metal:define-macro="main"
tal:define="size python:here.getObjSize(here);
content_type here/get_content_type|here/Format;
kssClassesView context/@@kss_field_decorator_view;
getKssClasses nocall:kssClassesView/getKssClassesInlineEditable">
<div tal:replace="structure provider:plone.abovecontenttitle" />
<h1 class="documentFirstHeading">
<metal:field use-macro="python:here.widget('title', mode='view')">
Title
</metal:field>
</h1>
<div tal:replace="structure provider:plone.belowcontenttitle" />
<p class="documentDescription">
<metal:field use-macro="python:here.widget('description', mode='view')">
Description
</metal:field>
</p>
<div tal:replace="structure provider:plone.abovecontentbody" />
<p>
<metal:field use-macro="python:here.widget('file', mode='view')">
File
</metal:field>
</p>
<div tal:condition="python: content_type.startswith('text')">
<h2 i18n:translate="heading_file_contents">File contents</h2>
<pre tal:content="here/get_data|here/data|nothing">
</pre>
</div>
<div metal:use-macro="here/document_relateditems/macros/relatedItems">
show related items if they exist
</div>
<div tal:replace="structure provider:plone.belowcontentbody" />
</tal:main-macro>
</div>
</body>
</html>
我也搜索了at_download,并找到了/Plone/portal_skins/archetypes/at_download.它包含以下代码:
I've also done a search for at_download and found /Plone/portal_skins/archetypes/at_download. It contains this code:
if traverse_subpath:
field = context.getWrappedField(traverse_subpath[0])
else:
field = context.getPrimaryField()
return field.download(context)
任何人都可以告诉我要在浏览器中查看PDF时需要更改的内容吗?
Can anyone tell what I need to change to make PDFs view in the browser?
当前,当我选择一个PDF链接时,它看起来像这样. http://intranet.internal.lan/somewhere/Test.pdf/at_download/file
Currently when I select a link to a PDF it looks like this. http://intranet.internal.lan/somewhere/Test.pdf/at_download/file
我需要它看起来像这样.
I need it to look like this.
http://intranet.internal.lan/somewhere/Test.pdf
(没有/at_download/file)
(without /at_download/file)
任何帮助将不胜感激.
谢谢
大卫
推荐答案
我不知道它是否适用于plone 3.x.x,但是 我使用的是plone 4.1.6,我想渲染一个pdf文件 在浏览器中(在chrome和firefox中工作)并像这样放置 在页面模板中:
I don't know if it's work in plone 3.x.x, but I am using plone 4.1.6 and I wanted to render a pdf file in a browser (worked in chrome and firefox) and put like this in a page tamplate:
<a tal:attributes="href string:${edicao_url}/@@images/field_pdf" target="_blank">View PDF</a>
其中的网址显示:
http://localhost:8080/plone_site/content-type/@ @ images/field_pdf/
因此,字段field_pdf是内容类型的属性! 啊,我也使用了敏捷的内容类型!
So, the field field_pdf is an attribute from a content-type! Ah, and I am using too a content type from Dexterity!
希望此帮助对您有所帮助! = D
I hope this help help you! =D
这篇关于自定义file_view以在浏览器中查看pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!