2014-02-07 49 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渲染。