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);
}
question from:
https://stackoverflow.com/questions/65896537/the-stamps-pictures-overlap-in-the-pdf 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…