PDF to PNG - pqScan.com
VB.NET PDF to PNG Converting PDF into PNG Image Files in Visual Basic.NET Online Demo Download Trial Purchase Now

How to Convert PDF to PNG in VB.NET?

back to home  >  PDF to Image SDK  >  How to Convert PDF to Image  >  Convert PDF to PNG

This article shows using vb.net codes to turn PDF into PNG images. First, you need launch your Visual Studio 2005 or later, and create a new Console Application. Then download our PDF to Image SDK in .NET, add the Lib to your project reference. Finaly, just copy and paste the following codes to your project. So it looks very simple and easy.

PDF to PNG -- Visual Basic sample

The sample codes below show PDF to PNG image conversion in VB.NET using PDF To Image SDK.

Imports System.Drawing
Imports System.Drawing.Imaging
Imports PQScan.PDFToImage

Namespace PDF2PNG
  Class Program
    Private Shared Sub Main(args As String())
      ' Create an instance of PQScan.PDFToImage.PDFDocument object.
      Dim pdfDoc As New PDFDocument()

      ' Load local PDF document.
      pdfDoc.LoadPDF("sample.pdf")

      'Get total page count.
      Dim count As Integer = pdfDoc.PageCount

      For i As Integer = 0 To count - 1
        'Convert page to image
        Dim pngImage As Bitmap = pdfDoc.ToImage(i)
        'Save image with png file type
        pngImage.Save("output" & i & ".png", ImageFormat.Png)
      Next
    End Sub
  End Class
End Namespace

The second Visual Basic.NET example shows convert PDF stream to customized size Png image.

Imports System.IO
Imports System.Drawing
Imports System.Drawing.Imaging
Imports PQScan.PDFToImage

Namespace PDFToPNG
  Class Program
    Private Shared Sub Main(args As String())
      ' Generate a new PDFDocument instance from PQScan.PDFToImage.
      Dim pdf As New PDFDocument()

      ' Open PDF document to file stream
      Dim stream As New FileStream("sample.pdf", FileMode.Open)

      ' Load message from PDF document stream.
      pdf.LoadPDF(stream)

      ' Specify png image width from PDF page
      Dim width As Integer = pdf.GetPageWidth(0) / 2
      ' Specify png image height from PDF page
      Dim height As Integer = pdf.GetPageHeight(0) / 2

      'Convert PDF first page to image with the customized size
      Dim png As Bitmap = pdf.ToImage(0, width, height)
      'Save image to png format
      png.Save("result.png", ImageFormat.Png)
    End Sub
  End Class
End Namespace

convert pdf to png in vb.net

Besides resetting the with and height of output image, our library also allows to type image in a custom size through DPI property, if you need, please see "How to resize output images from PDF pages in vb.net".

pqScan SDK
.NET DLL for PDF to Image
Online Guide
.NET Guide for PDF to Image
Conversion Type
Separate PDF to JPG in VB.NET Separate PDF to TIFF in VB.NET Separate PDF to JPEG in C# Separate PDF to GIF in C# Separate PDF to Bitmap in ASP.NET Separate PDF to JPG in .NET Separate PDF to GIF in .NET Separate PDF to BMP in ASP.NET View All Image Types >>
At the very beginning, I tried your online demo, easy and great. Then, downloaded the trial and test it in VS project. I had to say it is the favored tool I've used, combined with high performance and tight integration into Visual Studio project. Keep up the amazing work. Ben Lopez