8

I've used a tool from Aspose (Aspose.PDF.kit) to generate a JPG thumbnail on the fly of a PDF for a .NET application. This works great, but what kind of other alternatives are there? Codeproject.com has this tutorial, but it requires you to have the full version of Acrobat.

Is there an open source alternative that's geared for ASP.NET?

Anjisan
  • 1,789
  • 3
  • 15
  • 26

8 Answers8

4

I've actually done a fair bit of research into this, and this is what I've come up with:

  • TallComponents.com's evaluation version of PDFRasterizer proved to me that it can be done in under 50 lines of code. It's quite expensive - Around £500.

  • Buying Acrobat Pro to do it is cost-ineffective, especially as it uses the clipboard for loading of the PDF into memory.

  • ITextSharp has a large API for manipulating PDFs, though I've read a few places that say that it can't create a thumbnail from a PDF, and I haven't managed to do it either. If someone can correct me with an example, then that'd be very much appreciated!

  • GFL SDK is a free solution that (after already having written this post!) I've gotten to work in C#.NET! Hallelujah! The code I used is here: http://homeofcox-cs.blogspot.com/2008/10/c-convert-pdf-to-image-format.html and you'll need to reference the gflAx.dll by using regsvr32.exe. It'll then appear when you add a reference to the DLL under the COM tab.

So in conclusion, if you want it done for free, it can be done in c#.NET using GflaX.

Cheers,

Karl.

Karl
  • 6,793
  • 3
  • 23
  • 21
4

Using Itext to create Thumbnails of PDFS

http://threebit.net/mail-archive/itext-questions/msg00436.html

I would recommend iTextSharp so you don't need the java redistributable

  • 1
    I think this code sample is using bits from JPedal. The PdfDecoder class isn't part of iTextSharp. Maybe it got rolled into iText and never got ported to iTextSharp? – Bob Black Sep 29 '09 at 20:46
1

You can generate a bitmap using the COM interface to the Windows Shell and calling IExtractImage(). I don't have C# code, but I wrote a function in C++ that does this successfully. The Windows shell doesn't depend on the Acrobat SDK to generate the thumbnail, but it might depend on your having the free Acrobat Reader installed on your machine.

Here's link some code written in Delphi that provides that functionality.

http://www.delphi3000.com/articles/article_3806.asp?SK=

Kluge
  • 3,567
  • 3
  • 24
  • 21
1

I will be testing this component. Its free and their online demo looks compelling: http://www.tallcomponents.com/pdfthumbnail-overview.aspx

Robert
  • 11
  • 1
0

I absolutely despise working with PDF documents. But when I absolutely have to, I have been using iTextSharp. It has quite a bit of functionality, the API is fairly well documented, and it is theoretically free. Though to use it effectively it helps if you get the book that they push on their website. I'm not certain if you can easily make thumbnails with it, but it has worked for me in generating and manipulating PDFs on every project I've worked on so far.

stephenbayer
  • 12,373
  • 15
  • 63
  • 98
  • I've seen where forums talk about using JPedal to dynamically generate a thumbnail, but not for iTextSharp. I saw where you can import an image, of course, but not export a JPG representation. Can you specificy where in the API to look? Thanks! – Anjisan Oct 14 '08 at 02:20
  • I realize this is an old post, but iTextSharp can do this easily and free. – Anthony Gatlin Sep 05 '11 at 05:12
  • @AnthonyGatlin According to the forum it is not possible. http://sourceforge.net/mailarchive/forum.php?thread_name=CAH9EZ9%3DC_Tp8FpCmPMNastJmH6GsKozgR47-y4kYm39fEr8M0A%40mail.gmail.com&forum_name=itext-questions – Lloyd Oct 18 '12 at 14:59
0

I wrote some .NET code once that wrapped GhostView and generated TIFFs--which could then easily be used to generate thumbnails. You can check out the code here. The function processAndInsertLoan contains the code that actually kicks of the GhostView process and catches the processing output. You should be able to salvage something from that if you so choose.

theraccoonbear
  • 4,283
  • 3
  • 33
  • 41
0

I have blogged about an open source solution for generating thumbnails of PDFS in ASP.NET here.

Internally it uses GhostscriptSharp, but wraps it in the DynamicImage environment, which means you can apply many other filters to the PDF thumbnail images.

Tim Jones
  • 1,766
  • 12
  • 17
0

I found Tim's DynamicImage to be the best. The free TallComponents.com version limits thumbnail size.

John
  • 11
  • 2