PDFOne .NET
Powerful all-in-one PDF library for .NET
Compatibility
VS 2008 VS 2005 CLR 2.0

Capturing the Image of a Page in a PDF Document (Using PDFOne .NET)

Using the PDFDocument.GetPageMetafile() function on PDF pages.
By L. Santhanam

This is the PDFOne .NET version of an older PDFOne Java article. In that article, we said:

Many companies send their bills as PDF documents. In most cases, the most useful part of the document is just the bill but unfortunately it will be buried under a whole lot of other pages.

Using PDFOne Java, we can just read the document, take a snap of the page where the bill is located, and save it as an image. This way the images will contain just the bills. Finding the bills in these images will be easier than opening the actual PDF documents.

In this article, we will see how to do the same in .NET. Here is the code snippet.

using System;
using System.Drawing;
using System.Drawing.Imaging;
using Gnostice.PDFOne;

class PDF2Image {
 static void Main(string[] args){
  // Load a PDF document
  PDFDocument doc = new PDFDocument();
  doc.Load("input_doc.pdf");

  // Get first page as a metafile
  Metafile Metafile1 = doc.GetPageMetafile(1);

  // Save the metafile as a JPEG image
  Metafile1.Save("FirstPageImage.jpg", ImageFormat.Jpeg);

  // Save a thumbnail of the JPEG image 
  Image Image1 
     = Metafile1.GetThumbnailImage(100, 100, null, IntPtr.Zero);
  Image1.Save("FirstPageImageThumb.gif", ImageFormat.Gif);

  // Dispose the meta file
  Metafile1.Dispose();

  // Close the PDF document
  doc.Close();
 }
}

Here is that PDF file that we usually use to demonstrate the capability of our document creation product for the Delphi/C++Builder market, Gnostice eDocEngine VCL. In this case, we used it as input for PDFOne .NET.

And, here is the captured image.

---o0O0o---

Our Developer Tools
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.

XtremePDFConverter VCL

A Delphi/C++Builder component to intelligently convert PDF to user-friendly Word RTF documents.

PDFOne .NET

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

XtremeDocumentStudio .NET

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

PDFOne (for Java™)

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

XtremeFontEngine (for Java)

Java font engine to render glyphs from Type 1, Type 2 (CFF), and TrueType fonts

Our Office Productivity Applications
Free PDF Reader

A free, fast, and portable application for viewing, printing and converting PDF documents.

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

This site is best viewed on a screen with minimum resolution of 1152 x 864 pixels. Windows XP users are advised to use Microsoft ClearType Tuning for optimal experience. Also, please use the latest version of a standards-compliant browser such as Firefox, Opera, or Dragon (Chromium).