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:

These are code samples in VB.NET:


            '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: https://www.sautinsoft.com/products/pdf-focus/


If you need a new code example or have a question: email us at support@sautinsoft.com or ask at Online Chat (right-bottom corner of this page) or use the Form below:



Questions and suggestions from you are always welcome!

We are developing .Net components since 2002. We know PDF, DOCX, RTF, HTML, XLSX and Images formats. If you need any assistance with creating, modifying or converting documents in various formats, we can help you. We will write any code example for you absolutely free.