【发布时间】:2014-08-07 15:59:03
【问题描述】:
我想要一个快速简单(依赖于插件)的 PDF 嵌入视图,而不仅仅是文件项的下载链接。
我的自定义文件架构如下所示:
class IBulletin(form.Schema):
...
form.primary('file')
file = NamedBlobFile(
title=_(u"File"),
required=False,
)
class Bulletin(Item):
grok.implements(IBulletin, IFile)
我按照http://www.kcsts.co.uk/blog/embedded-pdf-in-file-view-with-plone 的说明进行操作,它适用于原型文件视图,但似乎不适用于敏捷文件视图。
我猜关键部分在<object ...> 和<embed ...> 之内。我对模板的试用如下:
<metal:content-core define-macro="content-core"
tal:define="content_type context/file/contentType|nothing;
location string:${context/absolute_url}/@@download/file/${context/file/filename};
v python:context.restrictedTraverse('contenttype_utils');">
<object class="viewembededfile" type="application/pdf" data=""
tal:condition="python:content_type.endswith('pdf')"
tal:attributes="data location; width string:100%; height string:900">
<a href="" tal:attributes="href location">Please click here to download the PDF.</a>
<embed src="" class="viewembededfile" type="application/pdf"
tal:attributes="src location">
</embed>
</object>
...
我也尝试过<object ... attributes="data context/absoulte_url;" 和<embed ... attributes="src context/absolute_url",但都不起作用。它只显示一个灰色背景的块。请参阅图片以供参考。
有什么建议吗?
【问题讨论】:
-
我也遇到了同样的问题,我尝试过在Dexterity Doc 中看到类似的东西,但是用
problem to load PDF显示框灰色,我认为@Mathias 可以帮助我们。