matthew ephraim

Introducing GhostscriptSharp

A few months ago, I posted some code that I had used to generate thumbnail images from PDF files. Before writing the code, I had searched high and low for some simple code that would allow me to take a PDF file and generate a thumbnail from the first page of that PDF file. Unfortunately, I didn’t find many C# solutions. The best I could find was the Ghostscript library and some references to using it from C#.

In my previous post, I talked about some of the issues I had with using Ghostscript from the command line. It wasn’t difficult, but it wasn’t something that I wanted to do. Finally, I ended up writing a C# wrapper that would talk to the Ghostscript library and generate the PDF thumbnail files that I wanted. I figured it was a common enough issue that at least someone else would find it useful.

Almost immediately, that post became the most popular post on my site. I still get 10 or so Google hits from it every day. So, I figured I’d clean up the code a little bit (which involved some helpful changes that people suggested in the comments of my post) and release it to the world.

I decided to call the library GhostscriptSharp and you can find it on Github. There are probably a lot of things that could be added or cleaned up, so if you’d like to contribute, feel free to create your own fork and let me know if you have changes I could pull in.

Tags: ,

5 Responses to “Introducing GhostscriptSharp”

  1. Martin Bour Says:

    Thanks for making this public. Searching the web, there are many references to Ghostscript for conversion, but no good examples of making it work in .NET. Your wrapper makes it clean and simple.

  2. flalar Says:

    Any thought to use this in a x64 environment?

  3. Matthew Ephraim Says:

    @flalar I haven’t given any thought to it. I haven’t been doing .Net development in a while, so it just hasn’t come up.

    Hopefully, someone else ends up needing that and forks the project on github. Otherwise, it might be a while before I get around to it.

  4. Charles Crolley Says:

    Fantastic, Matthew! Excellent work and you saved me a whole bunch of time and headache.

    The only addition I would have is that the ghostscript you made available didn’t work on my machine, but this one: http://pages.cs.wisc.edu/~ghost/doc/GPL/gpl863.htm did. (Make sure you get the Windows version toward the bottom of the page.)

    I don’t know if it was specific to my installation, but it may save others some time. AGAIN, GREAT WORK!

  5. Dash Says:

    Works fine with x64. .NET doesn’t care as it’s all CLR and Ghostscript is available as a x64 binary.

    I’ve forked the project and added a few features to suit what I was doing. Feel free to merge it back in if you’re interested.

Leave a Reply