I am looking for a way to modify Chad's script (Here) to add a stamp to a Laserfiche Document (PDF). In Chad's script he is taking a document outside of Laserfiche and copying it, and creating a new document with the stamp applied. I have this functionality working great, but I am looking to go a bit further with it. The idea is to take a State Form, gather the field information in LF Forms, populate that into a Fillable PDF, then take the LF Forms signature and apply that to the PDF, keeping everything in Laserfiche. (See workflow below) I think I have the logic, now I just need to turn that into code - I believe it involves modifying this:
using (Stream inputPdfStream = new FileStream("C://unsigned.pdf", FileMode.Open, FileAccess.Read, FileShare.Read))
but I'm not sure how to reference the Fillable PDF document using 'This.'
{ string sigimg = GetTokenValue("RetrieveFieldValues_datafield").ToString(); //string loc = Entry byte[] imageBytes = Convert.FromBase64String(sigimg); string name = GetTokenValue("Entry Name").ToString(); // MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length); using (Stream inputPdfStream = new FileStream("C://unsigned.pdf", FileMode.Open, FileAccess.Read, FileShare.Read)) using (Stream inputImageStream = new MemoryStream(imageBytes, 0, imageBytes.Length)) using (Stream outputPdfStream = new FileStream("C://TestSignatures//" + name + ".pdf", FileMode.Create, FileAccess.Write, FileShare.None)) { var reader = new PdfReader(inputPdfStream); var stamper = new PdfStamper(reader, outputPdfStream); var pdfContentByte = stamper.GetOverContent(1); Image image = Image.GetInstance(inputImageStream); image.SetAbsolutePosition(250, 250);//(left/right, top/bottom) image.ScaleAbsolute(100f, 25f);//left/right, top/bottom pdfContentByte.AddImage(image); stamper.Close(); }
Any guidance is much appreciated!
Nate