I wrote the following code to stamp a PDF.
imagefile = stamps to be added
filename = PDF's file path
My problem is that the stamps added to each page are overlapping. I want to bring these stamps together. How can I do it? Thanks.
private void damga(string resimdosyası, string dosyayolu)
{
byte[] bytes = File.ReadAllBytes(dosyayolu);
PdfContentByte waterMark;
using (MemoryStream stream = new MemoryStream())
{
PdfReader reader = new PdfReader(bytes);
using (PdfStamper stamper = new PdfStamper(reader, stream))
{
int sayfa = reader.NumberOfPages;
for (int i = 1; i <= sayfa; i++)
{
waterMark = stamper.GetUnderContent(i);
string[] files = Directory.GetFiles(resimdosyası);
foreach (string file in files)
{
var resim = iTextSharp.text.Image.GetInstance("C://Users//tufanc//source//repos//PdfStamp//PdfStamp//stampimage//" + Path.GetFileName(file));
resim.SetAbsolutePosition(0, 100);
waterMark.AddImage(resim);
}
}
}
bytes = stream.ToArray();
}
File.WriteAllBytes(dosyayolu, bytes);
}
this complete the work.