I work with images...a lot. Often this involves image processing of various types such as resizing, resampling, and various cleanup operations. However, a common issue is that people like to conflate Adobe PDF with images. As such, any application that works with images should also work with PDF. However, since PDF isn't in reality an image type (even though it can store images), to do any kind of editing or cleanup a PDF must be converted to an actual image type.
Anyone who has worked with PDF in more than a consumption capacity will know that Adobe products cost money. The most useful enterprise products cost a lot of money. However, there are free options such as Ghostscript if you're willing to learn the SDK. For my personal imaging library I've chosen to create a class that invokes Ghostscript to consume a PDF and produce an image for processing.
The code is straightforward, but because Ghostscript is a C-based SDK, it might be confusing to C# programmers who aren't used to lower level languages or the P/Invoke support in .NET.
The biggest benefit of this class is that it supports streams and byte arrays on top of just the files supported by Ghostscript. One example of using byte arrays is extracting a PDF from an email attachment (which one of my production applications does). Streams are obviously useful without providing examples, of course. ;)
Note 1: For this class to work, gsdll32.dll (available on the Ghostscript site) must be available either by dropping it in the application folder or storing it in the GAC.
Note 2: This class is not fully tested, so use it at your own risk. If you find any bugs or make any improvements, I happily welcome feedback.
Edited 2 Years Ago by deceptikon