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"
,但不起作用。它只顯示灰色背景的塊。請參閱圖片以供參考。
有什麼建議嗎?
我有同樣的問題,我嘗試做一些事情,請參閱[敏捷文檔](http://docs.plone.org/external/plone.app.dexterity/docs/advanced/files-and-images.html ),但顯示框灰色'問題加載PDF',我覺得@Mathias可以幫助我們。 –