The scripts below allows rendering page from PDF file to PNG image with Bytescout PDF Renderer SDK.

Select programming language:

ASP.NET

using System;
using System.Web.UI;
using Bytescout.PDFRenderer;

namespace BasicExample
{
	public partial class _Default : Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			// Prepare a test document.
			// Multipage.pdf file will be copied to the project directory on the pre-build event (see the project properties).
			String inputDocument = Server.MapPath("multipage.pdf");

			// Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
			RasterRenderer renderer = new RasterRenderer();
			renderer.RegistrationName = "demo";
			renderer.RegistrationKey = "demo";

			// Load PDF document.
			renderer.LoadDocumentFromFile(inputDocument);

			// Prepare response.
			Response.Clear();
			Response.ContentType = "image/png";
			Response.AddHeader("Content-Disposition", "inline;filename=result.png");

			// Render first page of the document to the output stream.
			renderer.RenderPageToStream(0, RasterOutputFormat.PNG, Response.OutputStream);

			Response.End();
		}
	}
}

C#

using System;

using Bytescout.PDFRenderer;


namespace BasicExample
{
	class Program
	{
		static void Main(string[] args)
		{
			// Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
			RasterRenderer renderer = new RasterRenderer();
			renderer.RegistrationName = "demo";
			renderer.RegistrationKey = "demo";

			// Load PDF document.
			renderer.LoadDocumentFromFile("multipage.pdf");

			// Render first page of the document to PNG image file.
			renderer.RenderPageToFile(0, RasterOutputFormat.PNG, "result.png");

			// Open the output file in default image viewer.
			System.Diagnostics.Process.Start("result.png");
		}
	}
}

Visual Basic .NET

Imports Bytescout.PDFRenderer

Module Module1

    Sub Main()

        ' Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
        Dim renderer As RasterRenderer = New RasterRenderer("demo", "demo")
        renderer.RegistrationName = "demo"
        renderer.RegistrationKey = "demo"

        ' Load PDF document.
        renderer.LoadDocumentFromFile("multipage.pdf")

        ' Render first page of the document to PNG image file.
        renderer.RenderPageToFile(0, RasterOutputFormat.PNG, "result.png")

        ' Open the output file in default image viewer.
        Process.Start("result.png")

    End Sub

End Module

VBScript

' Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
Set renderer = CreateObject("Bytescout.PDFRenderer.RasterRenderer")
renderer.RegistrationName = "demo"
renderer.RegistrationKey = "demo"

' Load PDF document.
renderer.LoadDocumentFromFile "....multipage.pdf"

' Render first page of the document to PNG image file.
renderer.RenderPageToFile 0, 2, "result.png" ' 2 - PNG image format

' Open the output file in default image viewer.
Set shell = CreateObject("WScript.Shell")
shell.Run "result.png", 1, false
Set shell = Nothing

Set extractor = Nothing