public object Download(Dictionary<string, string> jsonResult)
{
PdfViewerHelper helper = new PdfViewerHelper();
object pdfData = (object)helper.GetDocumentData(jsonResult);
var propertyInfo = pdfData.GetType().GetProperty("documentStream");
string value = propertyInfo.GetValue(pdfData, null).ToString();
byte[] byteContents = Convert.FromBase64String(value);
// First, get the empty, unfilled version of the document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(byteContents);
foreach (PdfLoadedField field in loadedDocument.Form.Fields)
{
if (field is PdfLoadedTextBoxField)
{
((PdfLoadedTextBoxField)field).Text = "1";
}
}
loadedDocument.Save(HttpContext.Current.Server.MapPath("~/Data/FormDocument.pdf"));
loadedDocument.Close(true);
return helper.GetDocumentData(jsonResult);
} |
public object Download(Dictionary<string, string> jsonResult)
{
PdfViewerHelper helper = new PdfViewerHelper();
object pdfData = (object)helper.GetDocumentData(jsonResult);
var propertyInfo = pdfData.GetType().GetProperty("documentStream");
string value = propertyInfo.GetValue(pdfData, null).ToString();
byte[] byteContents = Convert.FromBase64String(value);
File.WriteAllBytes(HttpContext.Current.Server.MapPath("~/Data/FormFillingDocument.pdf"), byteContents);
return null;
} |
PdfViewerHelper helper = new PdfViewerHelper();
object pdfData = (object)helper.GetDocumentData(jsonResult);
var propertyInfo = pdfData.GetType().GetProperty("documentStream");
string value = propertyInfo.GetValue(pdfData, null).ToString();
byte[] byteContents = Convert.FromBase64String(value);
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(byteContents);
//Fill the XFA form.
loadedDocument.Form.EnableXfaFormFill = true;
foreach (PdfLoadedField field in loadedDocument.Form.Fields)
{
if (field is PdfLoadedTextBoxField)
{
((PdfLoadedTextBoxField)field).Text = "syncfusion";
}
}
loadedDocument.Save(@"Downloaded.pdf"); |