Introduction to Web Garden

My name is David Conlisk and I am a freelance Xamarin, IOT and
.NET developer based in Glasgow, Scotland. Here I will be blogging
about my experiences with Xamarin, IOT, .NET and web development in
general, and my forays into the world of open source programming,
and I'll be showing off some of my work. Feel free to check out the
blog or get in touch.

Latest Blog Posts

Generating thumbnail images for PDFs in Umbraco

Thursday, April 18, 2013 by David Conlisk

Sometimes you want to display thumbnail images beside a list of
PDF files on your website. It's possible to create thumbnails
automatically from PDFs using the GhostscriptSharp tool. I'll
show you how to get this to happen automatically in Umbraco.

To have something happen automatically in Umbraco, you can hook
into an event. For my purposes, I used the Media.AfterSave event.
This way any time a pdf document is uploaded or updated in the
media section, I create a thumbnail file based on the first page of
that document and store it on the file server. If you name it
correctly, it will even appear next to your pdf in the Umbraco
media section.

To use the GhostscriptSharp tool, just copy the
GhostscriptSharp.dll and gsdll32.dll files from the
GhostscriptSharp project (which you can download as a zip) into the
bin directory of your Umbraco site. Then add references to both of
those dlls to your UserControls project. Now add your event handler
to your UserControls project, so that it will be compiled into your
UserControls.dll file and copied into your Umbraco site. Umbraco is
smart enough to find any event handlers that implement the correct
interfaces in your compiled code - you don't need to do anything
else. The code for my event handler is shown below.

Please note! This has only been tested in Umbraco 4.9.x and
4.11.x.

I also had to do two other things. Firstly, make sure that the
application pool for your website is set to enable 32-bit
applications (you can find that setting in the Advanced Settings in
IIS7). I also had to remove the System.Data.SQLite.dll from the bin
folder of my Umbraco site when I made the change to the application
pool. I haven't noticed any side-effects.

Cheers for the tip! That looks like a useful tool. Looks like you can do both rendering on the fly, or use the managed API to create a file as I've done with GhostscriptSharp. Perhaps a blog post for the future ;)

David

24 April 2013 at 10:18:01

siva says:

how to get pdf 10th page as a thumbnail of it .if provide option to select page number .then that can use as a pdf thumbnail

Follow the link to GhostScriptSharp at the top of the blog post (https://github.com/mephraim/ghostscriptsharp). Use the Zip button to download the project. You'll find the gsd32.dll file in ghostscriptsharp-master\ThirdParty. To get the ghostscriptsharp.dll you'll need to open the GhostscriptSharp.cs project in visual studio and build it. I've also emailed you a copy of the built dll that I use.