Get thumbnail of PDF page using itextsharp
Using itextsharp, How can I get the thumbnails of Pages and display 开发者_运维百科in a picturebox. there are hundreds of samples on net using iTextsharp but 99% of them are how to create and manipulate PDF not just read PDF.
// pdfFileName is the file Name
PdfReader reader = new PdfReader(pdfFileName);
for (int i = 1; i <= reader.NumberOfPages; i++)
{
// I need something like PdfPage here
}
Can someone suggest how to do this? I've had a look at the itext docs and can't figure out where to get started and get a PDF Page , I assumed I need PdfImageObject but how to get there...
Thanks in advance..
iText and iTextSharp are PDF generators only unfortunately, and what you are looking for is actually PDF renderer. According to Bruno Lowagie the creator of iText in a recent blog post they have no plan on doing so any time soon, either.
PDF Clown, which is still only in a very early alpha, has a blog post (see point #3) stating that they've got a partial renderer working so I'd recommend looking at that.
Otherwise take a look at these SO posts about converting PDFs to JPGs:
- https://stackoverflow.com/questions/711942/convert-pdf-file-to-jpg-asp-net
- Converting a multiple-page PDF to a single image
The PdfImageObject
object that you were looking at is used to create an "image-like" object that represents a piece of raw PDF content that can be embedded within a PDF but has no methods for creating a raster image such as JPG or BMP so it wouldn't help you. But if you're curious about it see this post.
Check this link to extract an image...Extract images using iTextSharp I have modified this code to extract a form(Table an is data) so i guess you can extract what you want with a little of work :)
精彩评论