public ActionResult Load(jsonObjects jsonObject) { PdfRenderer pdfviewer = new PdfRenderer(); MemoryStream stream = new MemoryStream(); var jsonData = JsonConverter(jsonObject); object jsonResult = new object(); if (jsonObject != null && jsonData.ContainsKey("document")) { if (bool.Parse(jsonData["isFileName"])) { string documentPath = GetDocumentPath(jsonData["document"]); if (!string.IsNullOrEmpty(documentPath)) { byte[] bytes = System.IO.File.ReadAllBytes(documentPath); stream = new MemoryStream(bytes); } else { return(this.Content(jsonData["document"] + " is not found")); } } else { byte[] bytes = Convert.FromBase64String(jsonData["document"]); stream = new MemoryStream(bytes); } } jsonResult = pdfviewer.Load(stream, jsonData); return(Content(JsonConvert.SerializeObject(jsonResult))); }
public ActionResult Unload(jsonObjects jsonObject) { PdfRenderer pdfviewer = new PdfRenderer(); var jsonData = JsonConverter(jsonObject); pdfviewer.ClearCache(jsonData); return(this.Content("Document cache is cleared")); }
public ActionResult RenderAnnotationComments(jsonObjects jsonObject) { PdfRenderer pdfviewer = new PdfRenderer(); var jsonData = JsonConverter(jsonObject); object jsonResult = pdfviewer.GetAnnotationComments(jsonData); return(Content(JsonConvert.SerializeObject(jsonResult))); }
public ActionResult ExportFormFields(jsonObjects jsonObject) { PdfRenderer pdfviewer = new PdfRenderer(); var jsonData = JsonConverter(jsonObject); string jsonResult = pdfviewer.ExportFormFields(jsonData); return(Content(jsonResult)); }
public ActionResult ExportAnnotations(jsonObjects jsonObject) { PdfRenderer pdfviewer = new PdfRenderer(); var jsonData = JsonConverter(jsonObject); string result = pdfviewer.ExportAnnotation(jsonData); return(Content(result)); }
public ActionResult RenderPdfTexts(jsonObjects jsonObject) { PdfRenderer pdfviewer = new PdfRenderer(); var jsonData = JsonConverter(jsonObject); object result = pdfviewer.GetDocumentText(jsonData); return(Content(JsonConvert.SerializeObject(result))); }
public ActionResult PrintImages(jsonObjects jsonObject) { PdfRenderer pdfviewer = new PdfRenderer(); var jsonData = JsonConverter(jsonObject); object pageImage = pdfviewer.GetPrintImage(jsonData); return(Content(JsonConvert.SerializeObject(pageImage))); }
public ActionResult Download(jsonObjects jsonObject) { PdfRenderer pdfviewer = new PdfRenderer(); var jsonData = JsonConverter(jsonObject); string documentBase = pdfviewer.GetDocumentAsBase64(jsonData); return(Content(documentBase)); }
public ActionResult RenderThumbnailImages(jsonObjects jsonObject) { PdfRenderer pdfviewer = new PdfRenderer(); var jsonData = JsonConverter(jsonObject); object result = pdfviewer.GetThumbnailImages(jsonData); return(Content(JsonConvert.SerializeObject(result))); }
public ActionResult ImportFormFields(jsonObjects jsonObject) { PdfRenderer pdfviewer = new PdfRenderer(); var jsonData = JsonConverter(jsonObject); jsonData["data"] = GetDocumentPath(jsonData["data"]); object jsonResult = pdfviewer.ImportFormFields(jsonData); return(Content(JsonConvert.SerializeObject(jsonResult))); }
public Dictionary <string, string> JsonConverter(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); }
public ActionResult ImportAnnotations(jsonObjects jsonObject) { PdfRenderer pdfviewer = new PdfRenderer(); string jsonResult = string.Empty; object JsonResult; var jsonData = JsonConverter(jsonObject); if (jsonObject != null && jsonData.ContainsKey("fileName")) { string documentPath = GetDocumentPath(jsonData["fileName"]); if (!string.IsNullOrEmpty(documentPath)) { jsonResult = System.IO.File.ReadAllText(documentPath); } else { return(Content(jsonData["document"] + " is not found")); } } else { string extension = Path.GetExtension(jsonData["importedData"]); if (extension != ".xfdf") { JsonResult = pdfviewer.ImportAnnotation(jsonData); return(Content(JsonConvert.SerializeObject(JsonResult))); } else { string documentPath = GetDocumentPath(jsonData["importedData"]); if (!string.IsNullOrEmpty(documentPath)) { byte[] bytes = System.IO.File.ReadAllBytes(documentPath); jsonData["importedData"] = Convert.ToBase64String(bytes); JsonResult = pdfviewer.ImportAnnotation(jsonData); return(Content(JsonConvert.SerializeObject(JsonResult))); } else { return(Content(jsonData["document"] + " is not found")); } } } return(Content(jsonResult)); }
public ActionResult ImportAnnotations(jsonObjects jsonObject) { PdfRenderer pdfviewer = new PdfRenderer(); string jsonResult = string.Empty; var jsonData = JsonConverter(jsonObject); if (jsonObject != null && jsonData.ContainsKey("fileName")) { string documentPath = GetDocumentPath(jsonData["fileName"]); if (!string.IsNullOrEmpty(documentPath)) { jsonResult = System.IO.File.ReadAllText(documentPath); } else { return(Content(jsonData["document"] + " is not found")); } } return(Content(jsonResult)); }