Welcome Guest Search | Active Topics | Members | Log In | Register
How To: Render PDFs and other doc types in the browser's plug-in Options
Roger Martin
Posted: Thursday, November 08, 2007 10:05:04 AM
Rank: Administration

Joined: 8/3/2007
Posts: 847
Location: Fort Atkinson, WI
Currently, if you add a PDF to Gallery Server and then click on its thumbnail image, you get the following message:

Your browser cannot display this media object, but you can download it by clicking the download link in the toolbar.

This will occur even if you have the PDF plug-in installed in your browser. You may wish to have the PDF appear immediately in the plug-in, much like when you normally click on a PDF link on the internet. Gallery Server does not do this by default because the plug-in takes over the whole browser window, forcing the user to use the browser's back button to get back to Gallery Server.

To have the PDF appear in the browser's plug-in when you click on the PDF's thumbnail image, add a new <mediaObject> element to the galleryObject/mediaObjects section of galleryserverpro.config (in the config directory), like this:

Code:
<galleryObject>
  <mediaObjects>
  ... existing config settings...

    <mediaObject mimeType="application/pdf">
      <browsers>
        <browser id="default" htmlOutput="
&lt;script type='text/javascript'&gt; window.location='{MediaObjectUrl}'; &lt;/script&gt;">
        </browser>
      </browsers>
    </mediaObject>

  </mediaObjects>
</galleryObject>


This will cause Gallery Server to render a bit of javascript that will redirect the user to a full page version of the PDF file. You can tweak the javascript as desired (for example, to open a new tab instead of replacing the current window). Add similar <mediaObject> elements for other MIME types such as Word docs, etc.

Read the section Rendering Media Objects to the Browser in the Admin Guide for more info.

Cheers!

Roger Martin
Lead Developer for Gallery Server Pro
Paul
Posted: Monday, November 03, 2008 12:05:56 AM
Rank: Member

Joined: 10/29/2008
Posts: 12
Location: Shanghai
I tried to paste the codes directly into galleryserverpro.config but returned error

Parser Error Message: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 70, position 1.

Source Error:

Line 68: <browsers>
Line 69: <browser id="default" htmlOutput="
Line 70: <script type='text/javascript'> window.location='{MediaObjectUrl}'; </script>">
Line 71: </browser>
Line 72: </browsers>

Do I need to insert a javascript into the above codes?


Roger Martin
Posted: Monday, November 03, 2008 9:17:23 AM
Rank: Administration

Joined: 8/3/2007
Posts: 847
Location: Fort Atkinson, WI
Oops. You should escape the < and > with &lt; and &gt;. I corrected the original post.


Roger Martin
Lead Developer for Gallery Server Pro
Paul
Posted: Monday, November 03, 2008 9:59:21 AM
Rank: Member

Joined: 10/29/2008
Posts: 12
Location: Shanghai
Great thanks Roger. It works fine! Is there any sample codes I can find for opening MIME docs in a new browser? I'm a newbie in web programming.
Roger Martin
Posted: Monday, November 03, 2008 10:05:22 AM
Rank: Administration

Joined: 8/3/2007
Posts: 847
Location: Fort Atkinson, WI
You mean, instead of the current web page being replaced with your PDF, you want it to open in a new tab or browser window? If so, that should be a simple change to the HTML template in galleryserverpro.config. Notice that all you are doing is specifying a little javascript:

window.location='{MediaObjectUrl}';

{MediaObjectUrl} is replaced by the actual URL at runtime. I don't know if off the top of my head, but you should be able to quickly google how to modify this to open in a new tab instead of the current window. It is standard javascript and not specific to GSP.


Roger Martin
Lead Developer for Gallery Server Pro
CJL
Posted: Saturday, November 29, 2008 2:58:35 AM
Rank: Newbie

Joined: 6/16/2008
Posts: 2
Hi Guys,

I am new here, this is my first post. I am not the coding guy, so I tried very hard to follow the example and finally I can read pdf, word & ppt files but for pps file (powerpoint slideshow) can't work. What is the correct coding for pps file?

Roger Martin
Posted: Sunday, November 30, 2008 10:39:02 AM
Rank: Administration

Joined: 8/3/2007
Posts: 847
Location: Fort Atkinson, WI
Add the .pps mime type to galleryserverpro.config. That is, scroll down to the <mimeTypes> section and add this line:

Code:
<mimeType fileExtension=".pps" browserId="default" type="application/vnd.ms-powerpoint" allowAddToGallery="true" />


Then add a new HTML template just like you did for the others:

Code:
<mediaObject mimeType="application/vnd.ms-powerpoint">
    <browsers>
        <browser id="default" htmlOutput="
&lt;script type='text/javascript'&gt; window.location='{MediaObjectUrl}'; &lt;/script&gt;">
        </browser>
    </browsers>
</mediaObject>


I will include .pps as a mime type in future versions of GSP.


Roger Martin
Lead Developer for Gallery Server Pro
CJL
Posted: Wednesday, December 03, 2008 6:35:28 AM
Rank: Newbie

Joined: 6/16/2008
Posts: 2
Hi Roger,

Thank you very much for your coding. It is working now. By the way what code to add to make it full screen view when opening photo(slideshow), video & documents such as word, excel & ppt/pps?

Thanks & cheers.
Roger Martin
Posted: Thursday, December 04, 2008 12:56:55 PM
Rank: Administration

Joined: 8/3/2007
Posts: 847
Location: Fort Atkinson, WI
I don't know how you do the full screen thing, if it is even possible. It will depend on the plug-in you use. If you figure out what javascript/HTML will do it, I can help you configure the config file to get it working in GSP.


Roger Martin
Lead Developer for Gallery Server Pro
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.2 (NET v2.0) - 9/27/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.