Is it possible for the watermark to appear in more than one location in the document.
For example in the top, center and bottom of each page
Is it possible for the watermark to appear in more than one location in the document.
For example in the top, center and bottom of each page
Would you prefer to accomplish this through programming or by using our free web application? Secondly, is this about image watermark or text watermark?
It is text watermark and I prefer to accomplish through .Net programming
This is how you can add the Text Watermark programmatically in .NET.
Below is the example code for this purpose:
// Create a Watermarker object and specify the input PDF file path
using (Watermarker watermarker = new Watermarker(@"D:/source.pdf"))
{
// Iterate through each watermark text
foreach (var watermarkText in new string[] { "Top Watermark", "Center Watermark", "Bottom Watermark" })
{
// Create a TextWatermark with the specified text and font size
TextWatermark watermark = new TextWatermark(watermarkText, new Font("Arial", 36));
// Set the text color to red
watermark.ForegroundColor = Color.Red;
// Center the watermark horizontally on each page
watermark.HorizontalAlignment = HorizontalAlignment.Center;
// Determine the vertical alignment of the watermark based on the text
if (watermarkText == "Top Watermark")
{
// Align the watermark to the top of each page
watermark.VerticalAlignment = VerticalAlignment.Top;
// Set the top margin to 0 (no additional top margin)
watermark.Margins.Top = 0;
}
else if (watermarkText == "Center Watermark")
{
// Align the watermark to the center of each page
watermark.VerticalAlignment = VerticalAlignment.Center;
}
else if (watermarkText == "Bottom Watermark")
{
// Align the watermark to the bottom of each page
watermark.VerticalAlignment = VerticalAlignment.Bottom;
// Add a 20-unit margin at the bottom
watermark.Margins.Bottom = 20f;
}
// Add the watermark to the current page
watermarker.Add(watermark);
}
// Save the modified PDF to the specified output file path
watermarker.Save(@"D:/output.pdf");
}