Insert or Delete Text/Image Watermarks in PDF Files using C++

A watermark in a document identifies the state of the document with texts like confidential, draft, etc., and makes it difficult for the original document to be copied. Watermarks can be image or text-based and are frequently used in PDF documents. You might need to add watermarks to PDF documents within your C++ applications. For that, this article will teach you how to add and remove text and image watermarks from PDF documents using C++.

C++ API for Inserting and Deleting Text/Image Watermarks

Aspose.PDF for C++ is a C++ library that allows you to create, read and update PDF documents. Furthermore, the API supports inserting and deleting Image/Text watermarks in PDF documents. You can either install the API through NuGet or download it directly from the downloads section.

PM> Install-Package Aspose.PDF.Cpp

Insert Text Watermark in a PDF File using C++

With Aspose.PDF for C++ API, you can control the font style, text, color, angle, opacity, etc of the text watermark. The following are the steps to add a text watermark in a PDF file.

The following sample code shows how to add a text watermark in a PDF file using C++.

Image of the output PDF file generated by the sample code
Image of the output PDF file generated by the sample code

Insert Image Watermark in a PDF File using C++

Image watermarks are usually used to show the ownership of the document by using the logo or any other identifiable image. You can add an image watermark to PDF files using the steps given below.

The following sample code demonstrates how to add an image watermark in a PDF file using C++.

Image of the output PDF file generated by the sample code
Image of the output PDF file generated by the sample code

Remove Text or Image Watermark from a PDF File using C++

There might be scenarios where you need to remove watermarks from a PDF document. In the previous examples, we defined ids for both text and image watermarks. We will use those ids to remove the watermarks from the PDF documents. The following are the steps to remove watermarks from PDF files.

The following sample code shows how to remove text and image watermarks 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 watermarks in PDF files using C++. Specifically, you have learned how to add and remove image and text watermarks from PDF documents using Aspose.PDF for C++ API. The API provides many additional features for automating your PDF-related tasks. You can explore the API in detail by visiting the official documentation. In case of any questions, please feel free to reach us on our free support forum.

See Also