|
//Load the PDF document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf");
//Set the font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
foreach (var page in loadedDocument.Pages)
{
//Get the loaded page
PdfLoadedPage loadedPage = page as PdfLoadedPage;
//Create graphics
PdfGraphics graphics = loadedPage.Graphics;
//Watermark text
PdfGraphicsState state = graphics.Save();
graphics.SetTransparency(0.25f);
graphics.RotateTransform(-40);
graphics.DrawString("Imported using Essential PDF", font, PdfPens.Red, PdfBrushes.Red,new PointF(-150, 450));
graphics.Restore();
}
//Save and close the document
loadedDocument.Save("Watermark.pdf");
loadedDocument.Close(true); |