2014-02-07 45 views
1

我想要一个快速简便(插件依赖)PDF内嵌视图,而不仅仅是一个下载链接文件的项目。嵌入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",但不起作用。它只显示灰色背景的块。请参阅图片以供参考。

enter image description here

有什么建议吗?

+0

我有同样的问题,我尝试做一些事情,请参阅[敏捷文档](http://docs.plone.org/external/plone.app.dexterity/docs/advanced/files-and-images.html ),但显示框灰色'问题加载PDF',我觉得@Mathias可以帮助我们。 –

回答

2

我面临同样的问题,一些试验和错误之后,我发现,如果我不以PDF文件的位置结束包括文件名,然后至少Firefox启动以显示嵌入的PDF。

<object type="application/pdf" 
    tal:attributes="data string:${context/absolute_url}/@@download/file"> 
</object> 

同样适用于链接到PDF文件,以文件名显示一个下载对话框,没有PDF文件的Firefox渲染。