How to convert PDF to JPG using VB .Net ?!

Articles from our customers

I was looking for a solution to convert only first page of PDF document to JPG in VB.Net.

We’ve online book store which sells electronic books in PDF format. We’ve had a task to automate whole process of converting 1st page to JPG. It was necessary that clients can see a book preview, read contents and annotation at our Website.

I’ve successfully solved this task by the PDF Focus .Net component from SautinSoft company.  With help of this library it’s very easy to create process of converting PDF to any images and specify any dpi. This is my code:

'Convert PDF 1st page to JPG file
Dim f As New SautinSoft.PdfFocus()
Dim pdfPath As String = "d:\journal.pdf"
 
f.OpenPdf(pdfPath)
If f.PageCount > 0 Then
    'Let's convert 1st page from PDF document
    Dim image() As Byte = f.ToImage(System.Drawing.Imaging.ImageFormat.Jpeg, 1, 200)
    'show image
    Response.Buffer = True
    Response.Clear()
    Response.ContentType = "image/jpeg"
    Response.AddHeader("Content-Disposition:", "attachment; filename=Page1.jpg")
    Response.BinaryWrite(image)
    Response.Flush()
    Response.End()
End If

Here you can find more about PDF Focus .Net: http://www.sautinsoft.com/products/pdf-focus/convert_pdf_to_image_jpg_tiff_jpeg_bmp_png_asp_net.php

Share on Facebook

Leave a Comment

Your email address will not be published.