HTML JPG PDF XML DOCX
  Product Family
PDF

Remove Image from PDF in Go SDK

Delete a Images from a PDF Document using Cloud Go SDK

Get Started

How to delete Images from PDF via Go SDK

To delete images from PDF 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, and converter 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 delete images using Go

Aspose.PDF Cloud developers can easily load & delete images from PDF in just a few lines of code.

  1. Initialize the Aspose PDF API
  2. Upload the PDF Document to Cloud Storage
  3. Deletes image by id from the PDF file in the cloud storage.
  4. Download the result if needed it
 

Remove Images from PDF using Go


    func DeleteImage() {
        localFolder := "C:\\Samples"
        storageDocumentName := "sample.pdf"
        storageTempFolder := "TempPdfCloud"
        outputFileName := "output_del_images.pdf"
        imageID := "GE5TCMJQGUZDWMJZGMWDOMZSFQZDSOBMG42DK"

        AppSID := "*********************" // Your Application SID
        AppKey := "*****************"     // Your Application Key

        pdfApi := asposepdfcloud.NewPdfApiService(AppSID, AppKey, "")

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

        file, _ := os.Open(filepath.Join(localFolder, storageDocumentName))
        _, _, _ = pdfApi.UploadFile(filepath.Join(storageTempFolder, storageDocumentName), file, args)

        _, httpResponse, err := pdfApi.DeleteImage(storageDocumentName, imageID, args)
        if err != nil {
            fmt.Println(err.Error())
        } else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
            fmt.Println("DeleteImage()): Failed to delete image from the document.")
        } else {
            result_data, _, _ := pdfApi.DownloadFile(filepath.Join(storageTempFolder, storageDocumentName), args)
            fileName := path.Join(localFolder, outputFileName)
            f, _ := os.Create(fileName)
            _, _ = f.Write(result_data)
            fmt.Println("DeleteImage(): image delete successfully from the document '" + outputFileName + "'.")
        }
    }
 

Work with Images in PDF

Images often contribute significantly to the size of a PDF. Removing them can make the document smaller and easier to share, especially in email or online uploads. Images may contain sensitive information, such as personal photos or proprietary visuals. Removing them ensures the document respects privacy or confidentiality requirements. Removing images from a PDF is a strategic step in ensuring the document is optimized for specific use cases, whether it’s for storage, sharing, or readability. Delete the Images from PDF documents with Aspose.PDF Cloud Go SDK.

With our Go 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.