HTML JPG PDF XML DOCX
  Product Family
PDF

Encrypt PDF in Go SDK

API for encrypting PDF documents using Aspose.PDF Cloud Go SDK

Get Started

How to encrypt PDF via Cloud Go SDK

To encrypt PDF document, 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 encrypt PDF via Go

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

  1. Upload the PDF.
  2. Encrypt PDF using the PostEncryptDocumentInStorage method.
  3. Download the Encrypted PDF.
 

Encrypt PDF using Cloud Go SDK


    package main

    import (
        "encoding/base64"
        "fmt"

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

    func encryptDocument(pdf_api *asposepdfcloud.PdfApiService, document string, output_document string, userPassword string, ownerPassword string, encrypt_algorithm string, remote_folder string) {
        uploadFile(pdf_api, document)

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

        result, httpResponse, err := pdf_api.PostEncryptDocumentInStorage(document,
            base64.StdEncoding.EncodeToString([]byte(userPassword)),
            base64.StdEncoding.EncodeToString([]byte(ownerPassword)),
            encrypt_algorithm,
            args)
        if err != nil {
            fmt.Println(err.Error())
        } else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
            fmt.Println("Unexpected error!")
        } else {
            fmt.Println(result)

            downloadFile(pdf_api, document, output_document)
        }
    }
 

Encrypt PDF

Encrypting a PDF document is a simple yet powerful way to protect sensitive content, ensure privacy, and maintain control over how the document is used. Whether you’re sharing business contracts, financial reports, or personal records, encryption helps safeguard your information from unauthorized access, tampering, or misuse.

By applying encryption and setting appropriate permissions, you enhance the document’s security, ensure compliance with industry regulations, and build trust with your audience. In today’s digital world, PDF encryption is not just a feature—it’s a necessity for responsible data handling. Encrypt 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 & 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 Apps to test the functionality online.

  •