Working with Annotations in PDF Files using C++

Annotations are additional objects that can be added to PDF documents. Annotations can be helpful in scenarios such as adding contextual information to the document. As PDF files are not easily editable, annotations provide an option to add additional information to the document. In this article, you will learn how to add, update, and remove annotations in PDF files in C++.

C++ Library to Work with PDF Annotations

Aspose.PDF for C++ is a C++ library that allows you to create, read and update PDF documents. Furthermore, the library supports working with annotations in PDF files. You can either install the library through NuGet or download it directly from the downloads section.

PM> Install-Package Aspose.PDF.Cpp

Add Annotations to PDF in C++

The following are the steps to add annotations to PDF files in C++.

The following is the sample code to add annotations to PDF files using C++.

The following is the image of the file saved by the sample code.

Annotation added to the PDF file

Image showing the annotation

Read Annotations in a PDF in C++

The following are the steps to read annotations in a PDF file in C++.

The following is the sample code to read annotations in PDF files using C++.

Edit Annotations in PDF in C++

The following are the steps to edit and update annotations in PDF files in C++.

The following is the sample code to modify annotations in PDF files using C++.

C++ Remove PDF Annotations

Aspose.PDF for C++ provides the following options for removing the annotations from PDF files.

Remove a Specific PDF Annotation

The following are the steps to remove a specific annotation from a PDF file.

The following is the sample code to remove a specific annotation from a PDF file using C++.

Removing PDF Annotations by Type

The following are the steps to remove annotations by type from PDF files.

The following is the sample code to remove annotations by type from PDF files using C++.

Remove All PDF Annotations

The following are the steps to remove all annotations from PDF files.

The following is the sample code to remove all annotations from PDF files using C++.

Free C++ Library to Add PDF Annotations

You can use Aspose.PDF for C++ without evaluation limitations by getting a free temporary license.

C++ PDF Library

The library provides a bunch of additional features for working with PDF files. You can explore the library in detail by using the official documentation. In case of any questions, please feel free to reach us on our free support forum.

Conclusion

In this article, you have learned how to work with annotations in PDF files using C++. Specifically, you have seen how to read, add, edit and delete annotations from a PDF in C++. Furthermore, you have learned how to delete a specific annotation, annotations by type, or all annotations using Aspose.PDF for C++.

See Also