'.NET position on a pdf file to place signature
Goal here is to open PDF file preview. When user click on a certain place on that document I want to put my image/Signature there.
With this code I'm able to do everything except picking position to place.
image.SetAbsolutePosition(100, 100);
What is the best way to open pdf file inside form and pick coordinates of mouse click so I can replace line above with those coordinates.
string _pdfDocument = @"C:\Users\DEV_PC\Desktop\New folder\Test.PDF";
string _pdfDocumentOutput = @"C:\Users\DEV_PC\Desktop\New folder\Test_out.PDF";
string _signature = @"C:\Users\DEV_PC\Desktop\New folder\Sig.png";
using (Stream inputPdfStream = new FileStream(_pdfDocument, FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream inputImageStream = new FileStream(_signature, FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream outputPdfStream = new FileStream(_pdfDocumentOutput, FileMode.Create, FileAccess.Write, FileShare.None))
{
var reader = new PdfReader(inputPdfStream);
var stamper = new PdfStamper(reader, outputPdfStream);
var pdfContentByte = stamper.GetOverContent(1);
iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(inputImageStream);
image.SetAbsolutePosition(100, 100);
pdfContentByte.AddImage(image);
stamper.Close();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
