Few hours to Earth Hour (31st March 2012, 8.30-9.30 PM) now
and atmosphere has really gone cloudy and filled with pleasant smell which
happens on first rain. I will take this as Mother Nature’s appreciation for Earth Hour :-)
In last week, I was trying to add PowerPoint decks to the
web page in SharePoint which satisfies some criteria. There were two approaches
to do so.
1. Use
Fast Search PowerPoint Preview functionality
2. Use
Office
Web Apps to display the PowerPoint Deck using Page Viewer webpart or in iframe
I chose later approach as I felt it easy and quick. So I
uploaded the PowerPoint Deck to a document library. Opened it using office web
apps. Copied the url into clipboard. Then I added Page Viewer web part to web
part page and set the url property of it to the PowerPoint Deck url in
clipboard. Easy it is…but surprisingly Page Viewer web part gave an error…“This
content cannot be displayed in a iframe”.
After little bit of googling, I came to know the reason. Steven Van de Craen in his blog
has thrown a light on it. Excel services and Office Web Apps pages render the “X-FRAME-OPTIONS:SAMEORIGIN”
response header which causes this error. Steven has also given a solution to it
in his Codeplex
project which removes this culprit header using HttpModule.
Even though Steven’s solution is lucrative and easy, I was
not able to use it because of two reasons….
1. It
opens a gateway to Clickjacking
attacks
2. It
uses HttpModule which is not allowed in the SharePoint Governance at my client
place due to many valid reasons.
Further googling, I found another blog by Sean
Earp which uses the PowerPointFrame.aspx instead of PowerPoint.aspx. But
unlike PowerPoint.aspx which accepts the PowerPoint deck url as query string,
PowerPointFrame.aspx uses some guid which somehow points to the PowerPoint deck.
Figure 1 : PowerPoint.aspx and PowerPointFrame.aspx urls |
Hence this solution is good only when your PowerPoint deck to
be displayed on a page is fixed. In my case however, it was dynamic. I wanted
to embed the PowerPoint deck which satisfies some criteria. So after little bit
of digging, I was able to figure it out how PowerPointFrame.aspx query string guid
is constructed. Here is the code snippet I used to generate the guid.
//listItem
represents PowerPoint deck item in doc lib
string powerpointGuid = string.Format("F{0}m{1}m{2}m", SPContext.Current.Site.ID.ToString("N"),
SPContext.Current.Web.ID.ToString("N"),
listItem.UniqueId.ToString("N"));
|
Here is how my custom web part looks with PowerPoint decks. It displays the decks in iframes.
Figure 2 : My PowerPoint Deck custom webpart |
You also can use this logic but beware that Microsoft can
change this guid format in any of its SharePoint updates. If you are using it, don't forget to add popout=1 into the PowerPointFrame.aspx's query string. If you figure it out what is SlideId query string parameter, then please ensure that you are telling me that first.
Earth Hour has been started…Need to start mine one now
No comments:
Post a Comment