Articles in this section
Category / Section

How to extract images from a PDF file?

2 mins read

Syncfusion Essential PDF is the .NET PDF library used to create, read, and edit PDF documents. Using this library, you can extract images from a page or an entire PDF document.

Steps to extract images in PDF programmatically:

  1. Create a new C# Console application project. Create a console application in visual studio in .NET PDF library
  2. Install the Syncfusion.Pdf.WinForms  NuGet package as reference to your .NET Framework applications from NuGet.org. Install nuget packages in .NET PDF library
  3. Include the following namespaces in the Program.cs file.

C#

using Syncfusion.Pdf;
using Syncfusion.Pdf.Parsing;
using System.Drawing;

 

VB.NET

Imports Syncfusion.Pdf
Imports Syncfusion.Pdf.Parsing
Imports System.Drawing

 

  1. Use the ExtractImages() method that allows you to extract images from a particular page or an entire PDF document.
    //Extract images from first page
    Image[] extractedImages = pageBase.ExtractImages();
    

 

  1. The following C# and VB.NET code snippet shows how to extract images from a particular page or an entire PDF document.

C#

//Load an existing PDF
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(DataPathBase + "sample.pdf");
 
//Load first page
PdfPageBase pageBase = loadedDocument.Pages[0];
 
//Extract images from first page
Image[] extractedImages = pageBase.ExtractImages();
 
//close the document
loadedDocument.Close(true);

 

VB.NET

'Load an existing PDF
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument((DataPathBase + "sample.pdf"))
 
'Load first page
Dim pageBase As PdfPageBase = loadedDocument.Pages(0)
 
'Extract images from first page
Dim extractedImages() As Image = pageBase.ExtractImages
 
'close the document
loadedDocument.Close(True)

  

A complete working sample can be downloaded from Extract-Images-From-PDF-File.zip.

The input PDF document is as follows. Input PDF file of extact images in .NET PDF library

By executing the program, you will get the list of extracted images from the first page of the PDF document.

Take a moment to peruse the documentation, where you can find the image information and text extraction from PDF document with Essential PDF, and brief details about OCR processing , and merge document with code examples.

Refer here to explore the rich set of Syncfusion Essential PDF features.

An online sample link to extract images from PDF document

Note:

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.

 

Conclusion

I hope you enjoyed learning about how to extract images from a PDF file.

You can refer to our WinForms PDF’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms PDF documentation to understand how to present and manipulate data.

For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms PDF and other WinForms components.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied