I am trying to stamp existing pdf document using ITextSharp's stamper. I am able to open existing pdf and put an image inside on the desired position. (stamp the pdf)
Probleme is that stamp (red image) is always under the drawing. (black lines are over the red image) I am not able to do it vice versa.
The desired result is exactly the opposite - red image over the black lines
Any idea how to accomplish this properly? Thx for any advice.
Here is my code:
using (Stream inputPdfStream = new FileStream(@"D:\tmp\go\input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream outputPdfStream = new FileStream(@"D:\tmp\go\output.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
using (Stream inputImageStream = new FileStream(@"D:\tmp\go\stamp.png", FileMode.Open, FileAccess.Read, FileShare.Read))
{
var reader = new PdfReader(inputPdfStream);
var stamper = new PdfStamper(reader, outputPdfStream);
int lastPage = reader.NumberOfPages;
Image image = Image.GetInstance(inputImageStream);
image.ScalePercent(35.5f);
image.SetAbsolutePosition(30, 30);
PdfGState graphicsState = new PdfGState();
graphicsState.BlendMode = PdfGState.BM_DARKEN;
var pdfContentByte = stamper.GetOverContent(lastPage);
pdfContentByte.SetGState(graphicsState);
pdfContentByte.SaveState();
pdfContentByte.AddImage(image);
stamper.Close();
}