AnsweredAssumed Answered

HOWTO: Embed the Share Previewer on your own website

Question asked by mikeh Employee on Nov 12, 2009
Latest reply on Sep 30, 2015 by imran
I posted this in reply to a question in the Alfresco Explorer forum, but thought it might be useful over here. It details one way you can embed the Share WebPreviewer on your own website with code along the lines of:
<embed type="application/x-shockwave-flash"
   src="http://<server>:<port>/share/components/preview/WebPreviewer.swf"
   width="670px"
   height="670px"
   id="WebPreviewer"
   name="WebPreviewer"
   quality="high"
   allowscriptaccess="sameDomain"
   allowfullscreen="true"
   wmode="transparent"
   flashvars="fileName=aaar.png&amp;paging=false&amp;url=http%3A%2F%2Flocalhost%3A8080%2Falfresco%2Fservice%2Fapi%2Fnode%2Fworkspace%2FSpacesStore%2F15ddb4a8-63a5-4bf3-95a8-4d121d2eaed2%2Fcontent%3Fc%3Dforce%26noCacheToken%3D1257980553515%26guest%3Dtrue&amp;show_fullscreen_button=true&amp;i18n_actualSize=Actual%20Size&amp;i18n_fitPage=Fit%20Page&amp;i18n_fitWidth=Fit%20Width&amp;i18n_fitHeight=Fit%20Height&amp;i18n_fullscreen=Fullscreen&amp;i18n_fullwindow=Maximize&amp;i18n_fullwindow_escape=Press%20Esc%20to%20exit%20full%20window%20mode&amp;i18n_page=Page&amp;i18n_pageOf=of" />
Note the flashvars variable is a string passed through "encodeURIComponent" consisting of the following variables:
fileName=aaar.png
paging=false
url=http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/15ddb4a8-63a5-4bf3-95a8-4d121d2eaed2/content?c=force&noCacheToken=1257980553515&guest=true
show_fullscreen_button=true
i18n_actualSize=Actual Size
i18n_fitPage=Fit Page
i18n_fitWidth=Fit Width
i18n_fitHeight=Fit Height
i18n_fullscreen=Fullscreen
i18n_fullwindow=Maximize
i18n_fullwindow_escape=Press Esc to exit full window mode
i18n_page=Page
i18n_pageOf=of"
Note the noCacheToken on the end of the "url" variable to ensure your users are always viewing the latest content. It's up to you whether you generate this value or not.
Obviously you'll have to update the "localhost:8080" part of the url to match your Alfresco server.
You'll want to set the paging variable to "true" for .swfs generated from Word documents, PDFs, etc. It's "false" for images, such as this example.

The i18n messages make the tag somewhat unwieldy, so I've uploaded a (completely unsupported and not fully tested) version of the WebPreviewer.swf that has the English strings built-in by default here: http://mikehatfield-alfresco.s3.amazonaws.com/WebPreviewer.swf.zip
<embed type="application/x-shockwave-flash"
   src="http://<server>:<port>/share/components/preview/WebPreviewer.swf"
   width="670px"
   height="670px"
   id="WebPreviewer"
   name="WebPreviewer"
   quality="high"
   allowscriptaccess="sameDomain"
   allowfullscreen="true"
   wmode="transparent"
   flashvars="fileName=aaar.png&amp;paging=false&amp;url=http%3A%2F%2Flocalhost%3A8080%2Falfresco%2Fservice%2Fapi%2Fnode%2Fworkspace%2FSpacesStore%2F15ddb4a8-63a5-4bf3-95a8-4d121d2eaed2%2Fcontent%3Fc%3Dforce%26noCacheToken%3D1257980553515%26guest%3Dtrue&amp;show_fullscreen_button=true" />

Questions:
  • Is this of interest at all to users in general?

  • Would it be useful for this HTML to be generated the Document Details page along with the existing three URLs?

  • Would you be happy for Share to automatically grant guest access to the document / would you only want a Site Manager to be able to do this / would you prefer a specific "Public Share" folder in the Document Library?
Comments and suggestions welcome.

Thanks,
Mike

Outcomes