pq scan
Convert PDF to BMP -- ASP.NET Sample
The following free C# and VB.NET sample codes illustrate the use of our .NET PDF to image library control to convert PDF document to BMP images in ASP.NET web project.
C#: ASP.NET PDF-to-BMP Conversion
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 PDF document. string pdfFileName = Server.MapPath("sample.pdf"); // Create an instance of PQScan.PDFToImage.PDFDocument object. PDFDocument pdfDoc = new PDFDocument(); // Load the PDF document. pdfDoc.LoadPDF(pdfFileName); // Prepare response. Response.Clear(); Response.ContentType = "application/x-bmp"; // Render the first page of PDF document to the output image. System.Drawing.Image bmpImage = pdfDoc.ToImage(0); using (MemoryStream ms = new MemoryStream()) { // Save image to bmp format. bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); // Show bmp image to your aspx web page. Response.OutputStream.Write(ms.GetBuffer(), 0, (int)ms.Length); } bmpImage.Dispose(); Response.End(); } }
VB: ASP.NET PDF-to-BMP Conversion
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 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 = "application/x-bmp" ' Convert the first page of PDF file to the output image. Dim bmpImage As System.Drawing.Image = pdfDoc.ToImage(0) Imports (MemoryStream ms = New MemoryStream()) { ' Save image to bmp file format. bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp) ' Display bmp image to your aspx web page. Response.OutputStream.Write(ms.GetBuffer(), 0, CType(ms.Length, Integer)) } bmpImage.Dispose() Response.End() End Sub End Class