Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate a pdf thumbnail (open source/free) [closed]

Looking at other posts for this could not find an adequate solution that for my needs. Trying to just get the first page of a pdf document as a thumbnail. This is to be run as a server application so would not want to write out a pdf document to file to then call a third application that reads the pdf to generate the image on disk.

doc = new PDFdocument("some.pdf"); page = doc.page(1); Image image = page.image; 

Thanks.

like image 496
AndrewB Avatar asked Oct 20 '09 02:10

AndrewB


1 Answers

Matthew Ephraim released an open source wrapper for Ghostscript that sounds like it does what you want and is in C#.

Link to Source Code: https://github.com/mephraim/ghostscriptsharp

Link to Blog Posting: http://www.mattephraim.com/blog/2009/01/06/a-simple-c-wrapper-for-ghostscript/

You can make a simple call to the GeneratePageThumb method to generate a thumbnail (or use GeneratePageThumbs with a start and end page number to generate thumbnails for multiple seperate pages, with each page being a seperate output file), default file format is jpeg but you can change it, and many other options, by using the alternate GenerateOutput method call and specify options such as file format, page size, etc...

like image 187
Peter Avatar answered Oct 12 '22 23:10

Peter