Adding a watermark to a PDF is a common requirement to protect documents, indicate confidentiality, or brand your files. In this article, we will guide you through the details on how to put watermark in PDF with few code lines. Whether you want to watermark pictures inside PDFs or a complete PDF document, this guide covers everything you need.



Why Add Image Watermark to PDF?

  • Protect your documents from unauthorized distribution.
  • Make your branding consistent across all PDF files.
  • Indicate confidential or draft status clearly.

PDF Manipulation REST API

The GroupDocs.Watermark Cloud SDK for .NET enables you to add, manage, and customize image watermarks in PDF documents with few steps. With this SDK, you can protect your PDFs, maintain brand consistency, and control watermark appearance programmatically without the need for desktop software.

👉 - Apart from PDF, you can also process Word, PPTX, Excel, and various images files with this API.

PDF Image Watermarking Features

  • Add image watermarks to PDF files easily using .NET.
  • Apply watermarks to all pages or specific pages of a PDF.
  • Customize opacity, size, alignment, and rotation of image watermarks.
  • Update or remove existing image watermarks from PDF documents as needed.

Installation

Install the SDK via NuGet in your .NET project:

PM> NuGet\Install-Package GroupDocs.Watermark-Cloud -Version 23.8.0

Image Watermark using C#

Please follow the instructions below to add image watermark to PDF file using C# .NET.

Step 1. – Configure the API.

var configuration = new Configuration("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");
var watermarkApi = new WatermarkApi(configuration);

Step 2. – Specify the name of input PDF file.

var fileInfo = new FileInfo
{
    FilePath = "SourceFile.pdf"
};

Step 3. – Define watermark characteristics.

WatermarkOptions = new PdfWatermarkOptions
{
    ImageWatermark = new ImageWatermark
    {
        FilePath = "logo.png",
        HorizontalAlignment = "Center",
        VerticalAlignment = "Center",
        Opacity = 0.5
    }
}

Step 4. – Insert Image Watermark.

var response = watermarkApi.AddWatermark(request);
  • You can insert a watermark in PDF at specific positions, adjust opacity, or scale the image.

How to Insert a Watermark using cURL

The REST API also enables you to add image watermarks to PDF documents using cURL commands. This feature is handy if you prefer working directly with HTTP requests instead of SDKs.

Step 1 – Obtain Access Token

curl -X POST "https://api.groupdocs.cloud/connect/token" \
-d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET" \
-H "Content-Type: application/x-www-form-urlencoded"

Step 2 – Insert Watermark in PDF

curl -v -X POST "https://api.groupdocs.cloud/v1.0/watermark" \
-H "accept: application/json" \
-H "authorization: Bearer {ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d "{  \"FileInfo\": {    \"FilePath\": \"sourceFile.pdf\",    \"StorageName\": \"internal\"  },  \"OutputFolder\": \"resultant\",  \"WatermarkDetails\": [    {      \"ImageWatermarkOptions\": {        \"Image\": {          \"FilePath\": \"confidential.jpeg\",          \"StorageName\": \"internal\"        }      },      \"Position\": {        \"X\": 120,        \"Y\": 120,        \"Width\": 200,        \"Height\": 200,        \"HorizontalAlignment\": \"center\",        \"VerticalAlignment\": \"center\",        \"Margins\": {          \"Right\": 100,          \"Left\": 100,          \"Top\": 100,          \"Bottom\": 100        },        \"ScaleFactor\": 1,        \"RotateAngle\": 180,        \"ConsiderParentMargins\": true,        \"IsBackground\": true      },      \"Opacity\": 1    }  ],  \"PdfOptions\": {    \"PrintOnlyAnnotationWatermarks\": true,    \"Rasterize\": true  }}"

Replace {ACCESS_TOKEN} with token generated above.


Free Online PDF Watermark App

If you are interested in testing the functionality of Cloud SDK without code snippet, you may consider using our free Online PDF Watermark App. All you need to do is upload the input PDF document, specify image file and download the watermarked PDF, without writing a single line of code.

watermark pdf online

Add watermark to PDF online.


Conclusion

In this article, we have learned that usage of GroupDocs.Watermark Cloud SDK for .NET to watermark PDF files is a fast, reliable, and flexible solution for developers and businesses alike. It allows you to add image watermarks, control their position, opacity, and size, and apply them to all or selected pages without the need for desktop software like Adobe Acrobat. Try using this API to generate professional, secure, and easily manageable PDF documents.


Frequently Asked Questions – FAQs

1. Can I add an image watermark to specific pages of a PDF?
Yes. You can choose to apply the image watermark to all pages or only selected pages in the PDF.

2. Is it possible to watermark a PDF without modifying the original file?
Yes. The API generates a new watermarked PDF while keeping the original document intact.

3. Do I need to install Adobe Acrobat or other external software?
No. All operations run in the cloud, no desktop software required.

4. Can I replace or remove an existing image watermark in a PDF?
Yes. The SDK allows you to update or remove existing watermarks from PDF documents at any time.

5. Is there a free version of the watermark API?
Yes. Create a free trial account to test watermarking features online.