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++ Library for Inserting and Deleting PDF Watermarks

Aspose.PDF for C++ is a C++ library that allows you to create, read and update PDF documents. Furthermore, the library supports inserting and deleting Image/Text watermarks in PDF documents. You can either install the library 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++, 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

Add 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++.

Free C++ Library to Add PDF Watermark

You can use the C++ PDF Watermarking library without evaluation limitations by requesting a free temporary license.

Explore PDF Watermarking Library

The library provides many additional features for automating your PDF-related tasks. You can explore the library in detail by visiting 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 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++.

See Also