Redact PDF online

We have a requirement to expunge sensitive details from PDF files because of the data secrecy, so we usually redact (remove text, image, etc) from a certain page region of a PDF document. However, when dealing with a large set of documents, we need to use APIs to accomplish this requirement.

In this article, we are going to discuss the steps on how to redact PDF online using RedactionAnnotation class of Aspose.PDF Cloud SDK for Java.

Installation of SDK

Aspose.PDF Cloud SDK for Java is a programming API specific for Java developers and it’s built on top of Aspose.PDF Cloud API. Our Cloud APIs can be used from any platform without any particular software installation. However, in order to use the SDK, you need to first install it over the system.

The Cloud SDK is available for download over Maven and GitHub. Now add the following details in your pom.xml file to download and use Aspose.Pdf.jar in your Maven build project.


Once the SDK is installed, the next step is to obtain your personalized Client ID and Client Secret. Please visit Aspose.Cloud dashboard and if you have GitHub or Google account, simply Sign Up. Otherwise, click on the Create a new Account button and provide the required information. Now login to the dashboard using credentials and expand the Applications section. Scroll down towards the Client Credentials section to see Client ID and Client Secret details.

Add Redaction Annotation using Java

In the section given below, we have explained the steps on how to add a rectangular box to expunge the content of PDF files using Aspose.PDF Cloud SDK for Java.

  • First of all, we need to create an object of PdfApi while passing ClientId and ClientSecret details obtained from Aspose.Cloud dashboard
  • Secondly, create an object of Rectangle class to specify the region on the page where Annotation will be added
  • Thirdly, select the Default value from AnnotationFlags enumeration and add it to the List of type AnnotationFlags
  • Now create an instance of RedactionAnnotation class and set the rectangular region using setRect(…) method
  • Set the horizontal alignment using setHorizontalAlignment(…) method and select Center from HorizontalAlignment enumeration
  • In order to fill the color inside Annotation, use setFillColor(…) method and pass the Color object
  • Set the Last modified date of annotation using setModified(…) method
  • Penultimate, create a List of type RedactionAnnotation and add RedactAnnotation object to this list
  • Finally, call postPageRedactionAnnotations(…) method of PdfApi and pass source file name, the page number where annotation needs to be added. Also, pass RedactionAnnotation List as an argument to initiate the redaction process
Redacted PDF document

Image 1:- Redact Annotation added to PDF file.

Download the sample files used in above example from

Read Page Redaction Annotations

Aspose.PDF Cloud SDK for Java also offers the capabilities to read the information regarding existing Redact annotation in PDF document. The steps given below define how to read Annotation details using Java.

Update existing Redaction Annotation

If a PDF document already contains Redaction annotations, we can also update them using the API. Given below are the details on how to update existing annotation in a PDF document.

  • Create an instance of PdfApi while passing Client ID and Client Secret details as arguments
  • Create a Rectangle object to define the region of annotation. It’s calculated from the Bottom-Left of the document and the default unit is Point
  • Create AnnotationFlags List and add AnnotationFlags.DEFAULT value to the list
  • Now we need to create the RedactionAnnotation object and call the setRect(…) method to define the rectangular region of the annotation
  • Use the setModified(…) method to set last modified date of Annotation
  • Call the getDocumentRedactionAnnotations(…) method of PdfApi call to read the list of Annotations from the document
  • Get a hold of particular Annotation object using responseAnnotations.getAnnotations().getList().get(0).getId()
  • Finally, call the method putRedactionAnnotation(…) of PdfApi class to update existing Redaction Annotation in PDF file
Redact Annotation Updated

Image 2:- Redact Annotation updated.

The resource files used in above example can be downloaded from following links


In this article, we have discussed the steps on how to redact sensitive information from PDF documents. Apart from Redaction annotation, a plethora of other Annotation features are supported by the API and their details can be found over Working with Annotation. You may consider visiting the Product home page for further information about its capabilities. Should you have any related query, please feel free to contact via Free Product support forum.