Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
143902 | Apr 10,2019 03:38 AM UTC | May 8,2019 09:03 AM UTC | ASP.NET MVC (Classic) | 10 |
![]() |
Tags: PdfViewer |
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"); |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.