Ok, in order to achieve my question I used C# and iTextSharp framework.
This is the code. The code is writen in Visual Studio and you need to add a reference to itextsharp.dll to the project.
Doc1.pdf is the source PDF in which I would like to add the stamps.
JD.wmf and DPI.wmf are my images that I use as stamps
Result.pdf is the result pdf with applied stamps.
using iTextSharp.text;
using iTextSharp.text.pdf;
using System;
using System.IO;
namespace ConsoleApplication
{
class MyCl1
{
static Random random1 = new Random();
public static void Main()
{
using (Stream inputPdfStream = new FileStream("e:\\Doc1.pdf", FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream inputImageStream = new FileStream("e:\\JD.wmf", FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream inputImageStream2 = new FileStream("e:\\DPI.wmf", FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream outputPdfStream = new FileStream("e:\\result.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
{
var reader = new PdfReader(inputPdfStream);
var stamper = new PdfStamper(reader, outputPdfStream);
int numberOfPages = reader.NumberOfPages;
Image jD = Image.GetInstance(inputImageStream);
Image dPI = Image.GetInstance(inputImageStream2);
float fJD, fDPI;
for (int i = 1; i <= numberOfPages; i++)
{
var pdfContentByte = stamper.GetOverContent(i);
fJD = rand1(370,425);
fDPI = rand1(15, 50);
jD.SetAbsolutePosition(fJD, fDPI);
jD.RotationDegrees = rand1(-20,20);
dPI.SetAbsolutePosition(fJD, fDPI);
dPI.RotationDegrees = rand1(-20, 20);
pdfContentByte.AddImage(jD);
pdfContentByte.AddImage(dPI);
}
stamper.Close();
System.Diagnostics.Process.Start("e:\\result.pdf");
}
}
public static float rand1(double minNumber, double maxNumber)
{
return (float) (random1.NextDouble() * (maxNumber - minNumber) + minNumber);
}
}
}