HTML JPG PDF XML DOCX
  Product Family
PDF

Parse PDF for extraction Images in Go SDK

API for parsing PDF documents to extraction images using server-side Go API.

Get Started

How to parse PDF documents for extraction Images using Cloud Go SDK

For parse PDF documents to extraction Images via Cloud Go SDK , we’ll use Aspose.PDF Cloud Go SDK This Cloud Go SDK assists Go programmers in developing cloud-based PDF creator, annotator, editor, converter and parser apps using Go programming language via Aspose.PDF REST API. Use the following command from the Package Manager Console.

Package Manager Console Command


     
    go get -u github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25
     
     

Steps to parse PDF for extaction Images using Go SDK

Aspose.PDF Cloud developers can easily parse PDF documents for extraction Images. Developers need just a few lines of code.

  1. Create a new Configuration object with your Application Secret and Key
  2. Create an object to connect to the Cloud API
  3. Upload your document file
  4. Parse PDF documents for extraction Images in cloud storage using GetImages and GetImageExtractAsPng functions
  5. Checks the response and logs the result
  6. If the operation was successful, print the etracted images
 

This sample code shows parsing PDF document to extract Images


package main

import (
	"fmt"
	"path"

	asposepdfcloud "github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25"
)

// Extract Images from the document to PNG files
func ParseExtractImages(documentName string, pageNumber int32, localFolder string, remoteFolder string) {
	
	// Get your AppSecret and Key from https://dashboard.aspose.cloud (free registration required).
	pdf_api := asposepdfcloud.NewPdfApiService(APP_SID, APP_KEY, "")

	args := map[string]interface{}{
		"folder": remoteFolder,
	}

	file, _ := os.Open(path.Join(localFolder, documentName))	
	_, _, _ = pdf_api.UploadFile(path.Join(remoteFolder, documentName), file, args)

	respImages, httpResponse, err := pdf_api.GetImages(documentName, pageNumber, args)
	if err != nil {
		fmt.Println(err.Error())
	} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
		fmt.Println("ParseExtractImages(): Failed to extract images from the page of document.")
	} else {
		for _, image := range respImages.Images.List {

			response, httpResponse, err := pdf_api.GetImageExtractAsPng(documentName, image.Id, args)

			if err != nil {
				fmt.Println(err.Error())
			} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
				fmt.Println("ParseExtractImages(): Failed to extract image.")
			} else {
				fmt.Println("ParseExtractImages(): Images'" + image.Id + "' successfully extracted from the page of document.")

				fileName := path.Join(localFolder, (image.Id + ".png"))
				f, _ := os.Create(fileName)
				_, _ = f.Write(response)
				fmt.Println("File '" + fileName + "' successfully downloaded.")
			}
		}
	}
}
 

Work with the Images parsing in PDF via Go SDK

By parsing PDF documents for extraction images, one can systematically verify the validity and relevance of each image, ensuring that all references are current and functional.​ For tasks such as downloading linked image or conducting batch analyses, extracting images enables automation, saving time and reducing manual effort. Parse PDF documents for extracting images with Aspose.PDF Cloud Go SDK.

With our Go SDK you can

  • Add PDF document’s header & footer in text or image format.
  • Add tables & text or image stamps 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 test the functionality.

  •