How to Extract Images from PDF via .NET SDK
To extract images from PDF via Cloud .NET SDK, we’ll use Aspose.PDF Cloud .NET SDK This Cloud SDK allows you to easily build cloud-based PDF creator, editor & converter apps in C#, ASP.NET, or other .NET languages for various cloud platforms. Open NuGet package manager, search for Aspose.PDF Cloud and install. You may also use the following command from the Package Manager Console.
Package Manager Console Command
PM> Install-Package Aspose.Pdf-Cloud
Steps to get images from PDF using .NET
Aspose.PDF Cloud developers can easily load & extract images from PDF in just a few lines of code.
- Initialize the Aspose PDF API
- Upload the PDF Document to Cloud Storage
- Retrieves images from page in the uploaded PDF file.
- Show images list information.
Extract images from PDF using .NET
public async Task ExtractAllImages()
{
const string LOCAL_FOLDER = "C:\\Samples";
const string REMOTE_TEMP_FOLDER = "TempPdfCloud";
const string PDF_DOCUMENT = "sample.pdf";
const string PDF_OUTPUT = "output_sample.pdf";
const int PAGE_NUMBER = 2;
// Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required).
pdfApi = new PdfApi(AppSecret, AppSid);
using (var file = File.OpenRead(Path.Combine(LOCAL_FOLDER, PDF_DOCUMENT)))
{
FilesUploadResult response = await pdfApi.UploadFileAsync(Path.Combine(REMOTE_TEMP_FOLDER, PDF_DOCUMENT), file);
if (response == null)
Console.WriteLine("UploadFile(): Unexpected error - no response!");
else if (response.Errors != null && response.Errors.Count > 0)
foreach (var error in response.Errors)
Console.WriteLine("UploadFile(): {0} -> {1}", [error.Code, error.Message]);
else
Console.WriteLine("UploadFile(): File '{0}' successfully uploaded.", PDF_DOCUMENT);
}
ImagesResponse response = await pdfApi.GetImagesAsync(PDF_DOCUMENT, PAGE_NUMBER, folder: REMOTE_TEMP_FOLDER);
if (response == null)
Console.WriteLine("ExtractAllImages(): Unexpected error!");
else if (response.Code < 200 || response.Code > 299)
Console.WriteLine("ExtractAllImages(): Failed to extract images from the document.");
else {
foreach (Image image in response.Images.List)
Console.WriteLine(image.ToString());
}
}
Work with Images in PDF
Extracted images can be reused in other documents, presentations, or marketing materials, saving time and resources by avoiding re-creation. Once extracted, images can be edited or enhanced to improve their quality or adapt them for specific purposes, such as resizing or recoloring. Images extracted from a PDF can be stored separately for archival purposes, ensuring easy access and organization of visual content. By extracting images from a PDF, users can better manage, edit, and utilize visual content for a wide range of applications, from professional presentations to creative projects. Extract the Images from PDF documents with Aspose.PDF Cloud .NET SDK.
With our .NET library you can:
- Add PDF document’s header & footer in text or image format.
- Add tables & stamps (text or image) to PDF documents.
- Append multiple PDF documents to an existing file.
- Work with PDF attachments, annotations, & form fields.
- Apply encryption or decryption to PDF documents & set a password.
- Delete all stamps & tables from a page or entire PDF document.
- Delete a specific stamp or table from the PDF document by its ID.
- Replace single or multiple instances of text on a PDF page or from the entire document.
- Extensive support for converting PDF documents to various other file formats.
- Extract various elements of PDF files & make PDF documents optimized.
- You can try out our free App to change image dimensions in PDF files online and test the functionality.
- Learning Resources
- Documentation
- Source Code
- API References
- Product Support
- Free Support
- Paid Support
- Blog
- Why Aspose.PDF Cloud for .NET?
- Customers List
- Security