0 I have a pdf template with below content First Name: {{FirstName}} Contact Number: {{ContactNumber}} Email Id: {{EmailId}} Address 1: {{Address1}} Address 2: {{Address2}} Qualification: {{Qualification}} Using itextsharp i need to replace the texts which is inside the curly braces to its actual texts. But when i check the generated pdf, the texts in the {{}} are NOT getting replaced. Any idea why? Update: i heard to know that AcroFields not a simple text, its a form field. Can anyone tell me how to create this acrofields in my template?
So for that i have coded like this string formFile = path; PdfReader reader = new PdfReader(formFile); MemoryStream stream = new MemoryStream(); PdfStamper stamper = new PdfStamper(reader, stream); AcroFields fields = stamper.AcroFields; fields.SetField("{{FirstName}}", objUser.FirstName); fields.SetField("{{ContactNumber}}", objUser.EmailId); fields.SetField("{{Address1}}", objUser.AddressLine1); fields.SetField("{{Address2}}", objUser.AddressLine2); fields.SetField("{{Qualification}}", objUser.Education); fields.SetField("{{AppNumber}}", "01A2021"+objUser.UserId.ToString()); stamper.Writer.CloseStream = false; stamper.FormFlattening = true; stamper.Close(); stream.Position = 0; and then created my email attachment using System.Net.Mime.ContentType contentType = new System.Net.Mime.ContentType(System.Net.Mime.MediaTypeNames.Application.Pdf); var coverAttachment = new Attachment(stream, contentType); coverAttachment.ContentDisposition.FileName = "CoverLetter.pdf"; emailMessage.Attachments.Add(coverAttachment);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)