Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
141013 | Nov 19,2018 05:00 AM UTC | Nov 26,2018 08:54 AM UTC | ASP.NET MVC | 3 |
![]() |
Tags: PdfViewer |
[HttpPost]
public ActionResult Load(jsonObjects results)
{
PdfViewerHelper helper = new PdfViewerHelper();
var jsonResult = JsonConverterstring(results);
//load the multiple document from client side
if (jsonResult.ContainsKey("newFileName"))
{
var name = jsonResult["newFileName"];
var pdfName = name.ToString() + ".pdf";
helper.Load(HttpContext.Server.MapPath("~/Data/" + pdfName));
}
else
{
//Initially load the PDF document from the data folder.
if (jsonResult.ContainsKey("isInitialLoading"))
{
helper.Load(HttpContext.Server.MapPath("~/Data/F# Succinctly.pdf"));
}
}
return Content(JsonConvert.SerializeObject(helper.ProcessPdf(jsonResult)));
}
public Dictionary<string, string> JsonConverterstring(jsonObjects results)
{
Dictionary<string, object> resultObjects = new Dictionary<string, object>();
resultObjects = results.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)
.ToDictionary(prop => prop.Name, prop => prop.GetValue(results, null));
var emptyObjects = (from kv in resultObjects
where kv.Value != null
select kv).ToDictionary(kv => kv.Key, kv => kv.Value);
Dictionary<string, string> jsonResult = emptyObjects.ToDictionary(k => k.Key, k => k.Value.ToString());
return jsonResult;
}
//Json fields
public class jsonObjects
{
public string viewerAction { get; set; }
public string pageindex { get; set; }
public string controlId { get; set; }
public string isInitialLoading { get; set; }
public string id { get; set; }
public string isPageScrolled { get; set; }
public string Download { get; set; }
public string uploadedFile { get; set; }
public string newFileName { get; set; }
public string savedFields { get; set; }
public string enableOfflineMode { get; set; }
public string savetextMarkupAnnotation { get; set; }
public string existingAnnotations { get; set; }
public string signatureFields { get; set; }
public string signatureValues { get; set; }
public string newFileID { get; set; }
public string isPrinting { get; set; }
public string file { get; set; }
public string password { get; set; }
} |
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.