Embed PDF In Dexterity File View - plone

I want a quick and easy (plugin dependent) PDF embedded view, not just a download link for File items.
My custom File schema looks like:
class IBulletin(form.Schema):
...
form.primary('file')
file = NamedBlobFile(
title=_(u"File"),
required=False,
)
class Bulletin(Item):
grok.implements(IBulletin, IFile)
I follow instruction at http://www.kcsts.co.uk/blog/embedded-pdf-in-file-view-with-plone and it works for Archetypes File view, but seems not working for Dexterity File view.
I guess the critical part is within <object ...> and <embed ...>. My trial to the template looks as follows:
<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">
Please click here to download the PDF.
<embed src="" class="viewembededfile" type="application/pdf"
tal:attributes="src location">
</embed>
</object>
...
I also tried <object ... attributes="data context/absoulte_url;" and <embed ... attributes="src context/absolute_url" but does not work. It shows only a block with gray background. See the image for reference.
Any advice?

I faced the same problem and after some trial and error, I found out that if I don't include the file name at the end of the location of the pdf file then at least Firefox starts to show the embedded pdf.
<object type="application/pdf"
tal:attributes="data string:${context/absolute_url}/##download/file">
</object>
Same applies for links to the pdf file, with file name a download dialog is shown, and without the pdf file is rendered inside Firefox.

Related

TinyMCE stripping embed code in Drupal 6 using Wysiwyg module

I have a Drupal 6 installation with a Wysiwyg profile set up to use TinyMCE. The profile has the media button turned on. I have defined the Filtered HTML input format to allow the <embed>, <object>, and <param> tags and made this the default format for all roles. When you use the media button (the thing that looks like a couple frames of film) and enter a url, code like the following is generated and visible in the source:
<object width="100" height="100" data="http://youtu.be/wEWSHWp5vHM" type="application/x-shockwave-flash">
<param name="data" value="http://youtu.be/wEWSHWp5vHM" />
<param name="src" value="http://youtu.be/wEWSHWp5vHM" />
</object>
However, when you preview or save the post, the video is not rendered.
Here is the list of allowed tags:
<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><form><input><br><p><div><span><img><h1><h2><h3><h4><h5><h6><table><tr><td><thead><th><tbody><iframe><embed><object><param>
Anybody have any idea what I'm doing wrong? I found this recent post that seems to imply that you need to set TinyMCE to not use media_strict, but I can't believe you have to add a homebrew module to get embedding to work: http://drupal.org/node/368388#comment-5501684
What happens when you try embedding using 'Full HTML Filter'? You might also create a whole new input filter type for this content type.

how to show pdf inside the aspx page?

net mvc 3. I want to display the pdf file as a part of aspx page for preview purpose.
i don't want to use IFrame control. can we do this ?
I know you said no frames, but Google PDF viewer seems to be the most popular:
<iframe src="http://docs.google.com/gview?url=http://example.com/mypdf.pdf&embedded=true"
style="width:718px; height:700px;" frameborder="0"></iframe>
And you can try:
<embed src="http://yoursite.com/the.pdf" width="500" height="375">
Best Way to Embed PDF in HTML

.swf will play in IE but not Chrome

I have a asp.net 3.5 page that shows a file with a .swf extension. In IE when the page is pulled up the flash file is played and all looks normal. When I look at it in Google Chrome their is just a white space where the file should be playing. Is their a way to make the file play when viewing in chrome?
Here is the code:
<object width="400" height="250">
<param name="movie" value="abc.swf">
<embed src="../StaticPages/abc.swf" width="400" height="250" />
</object>
IE 7-9 will play as long as the param value is a valid path; but Chrome and other compliant browsers require both param and embed paths to be correct.
The page that is showing the flash file is being loaded by a text file that has the text for the page and the tags in it to run the flash file.
Once I looked at the tags more I see where the issue was. the src and value path were not the same so chrome could not locate the file. When I updated the file locations to match it worked.
Thanks
Original Code
<object width="400" height="250">
<param name="movie" value="abc.swf">
<embed src="../StaticPages/abc.swf" width="400" height="250" />
Fixed/correct Code:
<object width="400" height="250">
<param name="movie" value="/StaticPages/abc.swf">
<embed src="/StaticPages/abc.swf" width="400" height="250" />
This is most likely to be related to way you embed your swf into your page.
Especially if it also occurs in other browsers like firefox.
You can use SWFObject for this. It is an open source javascript library that handles embedding swfs in all different browsers.
More information on why this occurs: http://livedocs.adobe.com/flex/3/html/help.html?content=wrapper_13.html
Or if you want a more fancy way to display video content on a browser, try
http://flowplayer.org/demos/installation/index.html
and
http://www.longtailvideo.com/players/jw-flv-player/
Could you provide the actual tags / javascript you are using to place the flash file in the page?
Have you tried opening the swf file by itself in chrome to make sure it is not just a tag issue?
As DennisJaamann points out, at least as far as firefox, there are issues with tags. Firefox won't play swfs using just the object tag without specifying the proper type.
The problem of the difference in browsers is such that if you poke at the Adobe site itself, you'll see they use a public library for embedding swfs on their own site.

ASP.NET Menu Problem With .swf file

I have a drop down menu and a swf file on an asp.net page. When the menu drops down it is behind the swf file when it should appear in front.
Add the following parameter to the OBJECT tag:
<param name="wmode" value="transparent">
Add the following parameter to the EMBED tag:
wmode="transparent"
(Taken from the Adobe site)

How do Change swf file dimension in html....?

I just built a flex applcation with AS3 only.. the generated swf will expand as much as browser's window..I wish to reduce the dimension of swf file...any ideas?? Thanks..
You may need to specify your swf dimensions eg:
[SWF(width="640", height="480")]
If you're viewing it directly in your browser, you should embed your swf inside an html document and specify the dimensions of your swf.
If this is for a public facing website, I'd recommend using SwfObject.js. Or if you aren't comfortable with Javascript you can use the object tag:
<object width="640" height="480">
<param name="movie" value="your_file.swf">
<embed id="embed" src="your_file.swf" width="640" height="480"></embed>
</object>

Resources