Stamps in PDF via C#

Stamping PDF documents with .NET. Use Aspose.PDF to modify PDF documents programmatically

How to add Stamps to PDF Using .NET Library

In order to work with text stamp into PDF file, we’ll use Aspose.PDF for .NET API which is a feature-rich, powerful and easy to use document manipulation API for net platform. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console.

Package Manager Console

PM > Install-Package Aspose.PDF

Add Stamp to PDF Document C#


You need Aspose.PDF for .NET to try the code in your environment.

  1. Load the PDF with an instance of Document.
  2. Get DocumentInfo using Document.Info property.
  3. Access & display different Document.Info properties.

Add Stamp to PDF - C#


    // Open document
    Document pdfDocument = new Document(dataDir+ "AddTextStamp.pdf");

    // Create text stamp
    TextStamp textStamp = new TextStamp("Sample Stamp");
    // Set whether stamp is background
    textStamp.Background = true;
    // Set origin
    textStamp.XIndent = 100;
    textStamp.YIndent = 100;
    // Rotate stamp
    textStamp.Rotate = Rotation.on90;
    // Set text properties
    textStamp.TextState.Font = FontRepository.FindFont("Arial");
    textStamp.TextState.FontSize = 14.0F;
    textStamp.TextState.FontStyle = FontStyles.Bold;
    textStamp.TextState.FontStyle = FontStyles.Italic;
    textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Aqua);
    // Add stamp to particular page
    pdfDocument.Pages[1].AddStamp(textStamp);

    dataDir = dataDir + "AddTextStamp_out.pdf";
    // Save output document
    pdfDocument.Save(dataDir);