Working with Annotations in PDF Files using C++

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 work with annotations in PDF files using C++.

C++ API for Working with Annotations in PDF Files

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

PM> Install-Package Aspose.PDF.Cpp

Read Annotations in PDF Files

The following are the steps to read annotations in PDF files.

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

Add Annotations to PDF Files

The following are the steps to add annotations to PDF files.

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

Modify Annotations in PDF Files using C++

The following are the steps to modify annotations in PDF files.

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

Remove Annotations from PDF Files

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

Remove a Specific 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 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 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++.

Get a Free License

You can try the API without evaluation limitations by requesting a free temporary license.

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 PDF files. Furthermore, you have learned how to delete a specific annotation, annotations by type, or all annotations using Aspose.PDF for C++ API. The API provides a bunch of additional features for working with PDF files. You can explore the API in detail by using the official documentation. In case of any questions, please feel free to reach us on our free support forum.

See Also