PDF to JPEG - pqScan.com
ASP.NET PDF to JPG/JPEG Conversion Convert PDF Document to JPEG/JPG Images for Viewing on ASP.NET Web Page Online Demo Download Trial Purchase Now
.NET C#.NET VB.NET
ASP.NET

How to Convert PDF to JPEG/JPG in ASP.NET?

back to home  >  .NET PDF to Image SDK  >  How to Convert PDF to Image in .NET  >  ASP.NET Guide: Convert PDF to JPEG/JPG

JPEG image type is just one of raster image file formats that can be transformed and converted from PDF document. In this article, we will discuss how you can use PDF-to-Jpeg conversion features of pqScan .NET PDF to Image SDK in your ASP.NET web program.

Thanks to its flexible and well-compiled APIs, this SDK can be integrated into ASP.NET web project for converting and viewing Adobe PDF document. It makes the conversion from PDF to JPEG image on fly.

Before starting, you need to download pqScan PDF to Image Library for .NET firstly. Then, add respective DLL to your web application. And finally, use following C# and VB.NET codes based on your programming language.

Convert PDF to JPEG in ASP.NET Web Project

C# and VB.NET languages are both supported to use in ASP.NET application. Here, we provide Visual C# and Visual Basic examples to describe how to convert PDF document to JPG image in a sample web page for viewing.

C# Example for ASP.NET Web Project

using System;
using System.Web.UI;
using System.IO;
using PQScan.PDFToImage;

public partial class _Default: System.Web.UI.Page 
{
  protected void Page_Load(object sender, EventArgs e)
  {
    // Prepare a test document.
    string pdfFileName = Server.MapPath("sample.pdf");

    // Create an instance of PQScan.PDFToImage.PDFDocument object.
    PDFDocument pdfDoc = new PDFDocument();

    // Load your PDF document.
    pdfDoc.LoadPDF(pdfFileName);

    // Prepare response.
    Response.Clear();
    Response.ContentType = "image/jpeg";

    // Change the first page of PDF document to the output image.
    System.Drawing.Image jpgImage = pdfDoc.ToImage(0);

    using (MemoryStream ms = new MemoryStream())
    {
      // Save image to jpg format.
      jpgImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

      // Show jpg image to your aspx web page.
      Response.OutputStream.Write(ms.GetBuffer(), 0, (int)ms.Length);
      }

    jpgImage.Dispose();

    Response.End();

  }
}

VB.NET Example for ASP.NET Web Project

Imports System
Imports System.Web.UI
Imports System.IO
Imports PQScan.PDFToImage
 
Public partial Class _Default
     Inherits System.Web.UI.Page
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    ' Prepare a test document.
    Dim pdfFileName As String = Server.MapPath("sample.pdf") 
 
    ' Create an instance of PQScan.PDFToImage.PDFDocument object.
    Dim pdfDoc As PDFDocument = New PDFDocument() 
 
    ' Load your PDF document.
    pdfDoc.LoadPDF(pdfFileName)
 
    ' Prepare response.
    Response.Clear()
    Response.ContentType = "image/jpeg"
 
    ' Turn the first page of PDF document to the output image.
    Dim jpgImage As System.Drawing.Image = pdfDoc.ToImage(0) 
 
    Imports (MemoryStream ms = New MemoryStream())
    {
      ' Save image to jpeg format.
      jpgImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
 
      ' Show jpeg image to your aspx web page.
      Response.OutputStream.Write(ms.GetBuffer(), 0, CType(ms.Length, Integer))
      }
 
    jpgImage.Dispose()
 
    Response.End()
 
  End Sub
End Class

convert pdf to jpg in asp.net

pqScan SDK
.NET PDF to Image Library
Online Guide
PDF to Image Conversion in .NET
Conversion Type
Render PDF to Multi-page TIF for .NET Render PDF to Bitmap for .NET Render PDF to PNG for .NET Render PDF to PNG for C# Render PDF to GIF for ASP.NET Render PDF to BMP for ASP.NET Render PDF to TIFF for ASP.NET Render PDF to BMP for VB.NET View All Image Types >>
Great experience! I hope to express how grateful we are for the excellence of your product, your service and your staff. The product has proven to be an indispensible tool that I would be lost without. Kelly Arora