PDF to PNG - pqScan.com
ASP.NET PDF to PNG Conversion Converting PDF File to PNG Image Files in ASP.NET Using .NET PDF Converter Online Demo Download Trial Purchase Now
.NET C#.NET VB.NET
ASP.NET

How to Convert PDF to PNG in ASP.NET?

back to home  >  .NET PDF to Image SDK  >  How to Convert PDF to Image in .NET  >  Online Tutorial for PDF to PNG Conversion in ASP.NET

If you need to quickly convert PDF document to PNG image and then view the file on your ASP.NET project web page, then you should consider to using pqScan PDF to Image Converter for .NET. And this online tutorial will tell you how to perform effective PDF-to-Png file conversion.

To install and start using pqScan .NET PDF to Image Software, you can download the zipped reference file from here, and then add corresponding DLL component to your Visual Studio ASP.NET web form project. Once you have referenced the "PQScan.PDFToImage.dll" library you might be ready to start coding. Simple C# and VB.NET programming demos are both offered on this guide page.

ASP.NET PDF to PNG -- C# Sample

In this part, we provide a fully working example in C# for ASP.NET PDF to PNG conversion. It consists of a web page that displays the output png image rasterized from PDF document page.

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 PDF file.
    string pdfFileName = Server.MapPath("sample.pdf");

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

    // Load the PDF file.
    pdfDoc.LoadPDF(pdfFileName);

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

    // Render the first page of PDF file to the output image.
    System.Drawing.Image pngImage = pdfDoc.ToImage(0);

    using (MemoryStream ms = new MemoryStream())
    {
      // Save image to png format.
      pngImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

      // Display png image to the aspx web page.
      Response.OutputStream.Write(ms.GetBuffer(), 0, (int)ms.Length);
    }

    pngImage.Dispose();

    Response.End();
  }
}

ASP.NET PDF to PNG -- VB Sample

If your web project programming language is VB.NET, please refer to this demo. It will help you change a sample PDF to PNG image rapidly.

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 PDF file.
    Dim pdfFileName As String = Server.MapPath("sample.pdf") 
 
    ' Create an instance of PQScan.PDFToImage.PDFDocument object.
    Dim pdfDoc As PDFDocument = New PDFDocument() 
 
    ' Load the PDF file.
    pdfDoc.LoadPDF(pdfFileName)
 
    ' Prepare response.
    Response.Clear()
    Response.ContentType = "image/png"
 
    ' Change the first page of PDF file to the output image.
    Dim pngImage As System.Drawing.Image = pdfDoc.ToImage(0) 
 
    Imports (MemoryStream ms = New MemoryStream())
    {
      ' Save image to png file format.
      pngImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
 
      ' Show png image to your ASP.NET web page.
      Response.OutputStream.Write(ms.GetBuffer(), 0, CType(ms.Length, Integer))
    }
 
    pngImage.Dispose()
 
    Response.End()
  End Sub
End Class

convert pdf to png in asp.net

pqScan SDK
.NET PDF to Image Library
Online Guide
PDF to Image Conversion in .NET
Conversion Type
PDF to TIFF Converting in ASP.NET PDF to JPG Converting in ASP.NET PDF to Multi-page TIF Converting in VB.NET PDF to TIFF Converting in VB.NET PDF to JPG Converting in C# PDF to GIF Converting in C# PDF to BMP Converting in .NET PDF to Multi-page TIFF Converting in .NET View All Image Types >>
pqScan provides my business with some of the highest-quality pdf conversion sdk. I consistently see mature conversions between pdf file and images. That's really great experience of using your product. Calvin Anderson