Click or drag to resize
Pdf Library for .NET

PdfImageExtractor Class

Extracts the raster images of a PDF document, using the cross-platform native PDF engine.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfTool
    SelectPdf.UniversalPdfImageExtractor

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.6
Syntax
public class PdfImageExtractor : PdfTool

The PdfImageExtractor type exposes the following members.

Constructors
 NameDescription
Public methodPdfImageExtractorInitializes a new instance of the PdfImageExtractor class.
Top
Properties
 NameDescription
Public propertyDocumentInformation PDF document information. Populated after the first operation that returns metadata (e.g. GetPageCount, GetInfo).
(Inherited from PdfTool)
Public propertyEndPageNumber The 1-based page number where the current operation ends. The default value is 0, which means the operation runs to the last page.
(Inherited from PdfTool)
Public propertyImagesFormatThe format the images are returned and written in. Default PNG.
Public propertyImagesPathThe folder where Save writes the images.
Public propertyImagesPrefixThe file-name prefix for the images written by Save.
Public propertyStartPageNumber The 1-based page number where the current operation starts. The default value is 1 (first page).
(Inherited from PdfTool)
Public propertyTimeoutTimeout in seconds for the current operation. Default 600 seconds.
(Inherited from PdfTool)
Public propertyUserPasswordThe user password used to open the PDF document for reading. Default null (no password).
(Inherited from PdfTool)
Top
Methods
 NameDescription
Public methodCloseReleases the loaded document.
(Inherited from PdfTool)
Public methodDispose Releases the loaded document, the same as Close. Lets the PdfTool be used in a using statement. Calling it after Close, or more than once, does nothing.
(Inherited from PdfTool)
Public methodCode exampleExtractImages Extracts the images of the selected pages, each returned as encoded image bytes.
Public methodGetInfoGets the document information (title, author, page count, etc.).
(Inherited from PdfTool)
Public methodGetPageCountGets the number of pages in the loaded PDF document.
(Inherited from PdfTool)
Public methodLoad(Byte)Loads a PDF document from a byte array.
(Inherited from PdfTool)
Public methodLoad(PdfDocument)Loads an in-memory PdfDocument for reading.
(Inherited from PdfTool)
Public methodLoad(Stream)Loads a PDF document from a stream.
(Inherited from PdfTool)
Public methodCode exampleLoad(String)Loads a PDF document from a file.
(Inherited from PdfTool)
Public methodLoad(Byte, String)Loads a password-protected PDF document from a byte array.
(Inherited from PdfTool)
Public methodLoad(PdfDocument, String)Loads an in-memory PdfDocument. The password is used to open the document.
(Inherited from PdfTool)
Public methodLoad(Stream, String)Loads a password-protected PDF document from a stream.
(Inherited from PdfTool)
Public methodLoad(String, String)Loads a password-protected PDF document from a file.
(Inherited from PdfTool)
Public methodCode exampleSave Extracts the images of the selected pages to files written into ImagesPath, named ImagesPrefix + page number + "-" + the image's number on that page, in ImagesFormat.
Top
Remarks
Load a document with one of the Load overloads (see PdfTool), then call ExtractImages or Save. The pages searched are given by StartPageNumber and EndPageNumber. Images are returned in the order they appear, page by page; vector graphics and text are not images and are not returned.
Example
PdfImageExtractor extractor = new PdfImageExtractor();
extractor.Load("document.pdf");
byte[][] images = extractor.ExtractImages();
extractor.ImagesPath = "output";
extractor.ImagesPrefix = "picture-";
// writes output/picture-1-1.png, ...
extractor.Save();
See Also