Hi ,Support:
Is there any method to add a text or image watermark with 50% opacity and clockwise 5 degree rotation?
Another is that how to add a text at a given position with given font/size/color/style/opacity/rotation?
Thanks for your help.
Hi ,Support:
Is there any method to add a text or image watermark with 50% opacity and clockwise 5 degree rotation?
Another is that how to add a text at a given position with given font/size/color/style/opacity/rotation?
Thanks for your help.
using Aspose.Pdf;
// Load the PDF document
Document pdfDocument = new Document("input.pdf");
// Create TextStamp object for text watermark
TextStamp textStamp = new TextStamp("Watermark Text");
textStamp.TextState.Font = FontRepository.FindFont("Arial");
textStamp.TextState.FontSize = 36;
textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.Red;
textStamp.Opacity = 0.5; // 50% opacity
textStamp.RotateAngle = 5;
// Add the watermark to each page of the PDF
foreach (Page page in pdfDocument.Pages)
{
page.AddStamp(textStamp);
}
// Save the PDF with the watermark
pdfDocument.Save("output.pdf");
To add a text at a specific position with custom properties, you can create a TextStamp
and set its properties accordingly:
using Aspose.Pdf;
// Load the PDF document
Document pdfDocument = new Document("input.pdf");
// Create TextStamp object for custom text
TextStamp textStamp = new TextStamp("Custom Text");
textStamp.TextState.Font = FontRepository.FindFont("Times New Roman");
textStamp.TextState.FontSize = 16;
textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;
textStamp.Opacity = 0.7; // 70% opacity
textStamp.Rotate = Rotation.on45; // Rotate clockwise by 45 degrees
// Set the position of the text stamp
textStamp.XIndent = 100; // X-coordinate
textStamp.YIndent = 200; // Y-coordinate
// Add the custom text to each page of the PDF
foreach (Page page in pdfDocument.Pages)
{
page.AddStamp(textStamp);
}
// Save the PDF with the custom text
pdfDocument.Save("output.pdf");