I am looking for repeating watermark at 45 degree angle on whole page from top to bottom as mentioned in below sample image.
I am using itextsharp and C#.
Please help me with sample code.
I am looking for repeating watermark at 45 degree angle on whole page from top to bottom as mentioned in below sample image.
I am using itextsharp and C#.
Please help me with sample code.
byte[] bytes = File.ReadAllBytes(@"D:\20.pdf");
Font blackFont = FontFactory.GetFont("Arial", 22, Font.NORMAL, BaseColor.LIGHT_GRAY);
using (MemoryStream stream = new MemoryStream())
{
PdfReader reader = new PdfReader(bytes);
using (PdfStamper stamper = new PdfStamper(reader, stream))
{
int pages = reader.NumberOfPages;
for (int i = 1; i <= pages; i++)
{
iTextSharp.text.Rectangle pageRect = reader.GetPageSize(i);
float currentPosY = pageRect.Height;
float currentPosX = pageRect.Width;
while(currentPosY>0)
{
while (currentPosX > 0)
{
ColumnText.ShowTextAligned(stamper.GetUnderContent(i), Element.ALIGN_CENTER, new Phrase("sajids@rcjy.gov.sa", blackFont), currentPosX, currentPosY, 45);
currentPosX -= 150;
}
currentPosY -= 100;
currentPosX = pageRect.Width;
}
}
}
bytes = stream.ToArray();
}
File.WriteAllBytes(@"D:\Test_1.pdf", bytes);