Powerful all-in-one PDF library for .NET
VS 2005/2008/2010/2012/2013

How To Rasterize A PDF Document In .NET

Learn to convert text, shapes, and images in a PDF page as a single graphic item using PDFOne .NET.
By V. Subhash

A page in a PDF document can contain any combination of text, images, shapes, and other page elements. Sometimes, it becomes necessary to convert all these page elements as a single image element, say, to prevent text from being copied word by word.

PDFOne .NET ProPlus edition can export PDF pages as images. It can also draw images on PDF pages. Combining these two capabilities, you can convert your existing PDF documents with heterogeneous content to PDF documents with just images. Such documents are called rasterized documents.

Here is the code to do it.

In VB In C#
Imports Gnostice.PDFOne
Imports System.Drawing.Imaging

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, _
                                  ByVal e As System.EventArgs) _
                    Handles Button1.Click

      'Create two PDFDocument instances for input and output documents
      Dim PDFDocument1 As New PDFDocument("your licence key")
      Dim PDFDocument2 As New PDFDocument("your licence key")

      Dim MetaFile1 As Metafile
      Dim PDFPage1, PDFPage2 As PDFPage
      Dim iCounter, iPageCount As Integer

        ' Load the input document and get its page count
        iPageCount = PDFDocument1.GetPageCount

        ' Iterate through all pages in the input document, export
        ' each page as a vector image, convert each vector image
        ' to a raster image, and add raster image to the output
        ' document.
        For iCounter = 1 To iPageCount

          ' Export current page as vector image
          MetaFile1 = PDFDocument1.GetPageMetafile(iCounter)

          ' Save meta file as a raster image
          MetaFile1.Save("image_of_page_#" & iCounter & ".jpg", _

          ' Release resources used by the vector image

          ' Access current page
          PDFPage1 = PDFDocument1.GetPage(iCounter)

          ' Create a new page with current page dimensions
          PDFPage2 = New PDFPage( _
                         PDFPage1.GetWidth(PDFMeasurementUnit.Inches), _
          ' Draw raster image on the new page
          PDFPage2.DrawImage("image_of_page_#" & iCounter & ".jpg", 0, 0)
          ' Add the new page to the output document
        ' Save rasterized output document
    Catch ex As Exception


    End Try

  End Sub
End Class

Update (April 17, 2013): Higher Resolutions

In Version 5, we introduced new overloads of the PDFDocument.GetPageMetafile method which allow you to specify a DPI value at which the contents of the PDF pages need to be exported. Using this option, you will be able to export PDF page content at high resolutions.


Our Cloud-based document-processing
Gnostice StarDocs

Gnostice StarDocs is a scalable, fault-tolerant document-processing server solution, designed to be the central go-to place for all kinds of electronic document-processing work. StarDocs includes a web application (as seen at stardocs.gnostice.com) that frees your end-users from the need to have format-specific software to merge, split, redact, convert, edit, and sign documents - all they need is a network connection and a HTML5 browser. StarDocs provides a REST-based API that your developers can use to add document-processing functions to a variety of software applications. As the REST API is platform agnostic, your developers can write software on a wide variety of platforms - from desktop to mobile devices to Web services in any development language. To get them started quickly, StarDocs is supported by language-specific native SDK. StarDocs document server has load-balancing built-in and is designed to be scalable across enterprise Intranets and the Internet. StarDocs is available as packaged software for on-premise hosting and also as a subscription-based cloud service.

Our Delphi/C++Builder developer tools
XtremeDocumentStudio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

Our .NET Developer Tools
XtremeDocumentStudio .NET

Multi-format document-processing component suite for .NET developers.


A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

Our Java developer tools
XtremeDocumentStudio (for Java)

Multi-format document-processing component suite for Java developers.

PDFOne (for Java)

A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications.

Privacy | Legal | Feedback | Newsletter | Blog | Resellers © 2002-2015 Gnostice Information Technologies Private Limited. All rights reserved.