VB.NET: Extract Thumbnails From A PDF File

In my last tip, I posted the code for Extracting the Text Content from a PDF File. Well, I promised to post the code for Generating Graphical Thumbnail from PDF File in that post very

ITPro Today

September 1, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today

In my last tip, I posted the code for Extracting the Text Content from a PDF File.
Well, I promised  to post the code for Generating Graphical Thumbnail from PDF File in that post very soon.
However, some viral infection made me inefficient enough to delay this post :-).
Here is the code snippet to generate the graphical thumbnail from the pdf file.
You can extend this thing for generating the thumbnails of all the pages, last page etc.
Currently this code generates the thumbnail of first page only.
Also you can play around with the thumbnail size part, I have not added the sizing section which takes care of the size and the aspect ratio.
Will post the snippet for Getting the Size According to Aspect Ratio in next post.

Regards
Shobhit

A sample call for this function is like below:

Dim strThumbFile As String
Dim strPDFPath As String, strTargetPath As String, strTargetFileName As String
strPDFPath = "YourDrive:YourPathSomePDFFile.pdf"
strTargetPath = "YourDrive:YourPath"
strTargetFileName = "YourFileName.jpg"
If fn02_GenerateThumbFromPDF(strPDFPath, strTargetPath, strTargetFileName, System.Drawing.Imaging.ImageFormat.Jpeg, strThumbFile) = True Then
    MsgBox(strThumbFile)
Else
    MsgBox("Error in generating thumbnail.")
End If

For this code to run, you need Adobe Acrobat installed on your machine.

I have tested this code on Adobe Acrobat Professional 6.0 and it works perfectly on that.

Read more about:

Microsoft
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like