diff --git a/PDFViewer/ASP.NET MVC Razor Examples/Controllers/HomeController.cs b/PDFViewer/ASP.NET MVC Razor Examples/Controllers/HomeController.cs index cc93019..a069295 100644 --- a/PDFViewer/ASP.NET MVC Razor Examples/Controllers/HomeController.cs +++ b/PDFViewer/ASP.NET MVC Razor Examples/Controllers/HomeController.cs @@ -60,6 +60,57 @@ public ActionResult Load(jsonObjects jsonObject) return Content(JsonConvert.SerializeObject(jsonResult)); } + [System.Web.Mvc.HttpPost] + public ActionResult ValidatePassword(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 + { + string fileName = jsonData["document"].Split(new string[] { "://" }, StringSplitOptions.None)[0]; + if (fileName == "http" || fileName == "https") + { + var WebClient = new WebClient(); + byte[] pdfDoc = WebClient.DownloadData(jsonData["document"]); + stream = new MemoryStream(pdfDoc); + } + else + { + return this.Content(jsonData["document"] + " is not found"); + } + + } + } + else + { + byte[] bytes = Convert.FromBase64String(jsonData["document"]); + stream = new MemoryStream(bytes); + + } + } + string password = null; + if (jsonObject != null && jsonData.ContainsKey("password")) + { + password = jsonData["password"]; + } + var result = pdfviewer.Load(stream, password); + return Content(JsonConvert.SerializeObject(result)); + } + public Dictionary JsonConverter(jsonObjects results) { Dictionary resultObjects = new Dictionary(); @@ -133,6 +184,15 @@ public ActionResult RenderPdfPages(jsonObjects jsonObject) return Content(JsonConvert.SerializeObject(jsonResult)); } + [System.Web.Mvc.HttpPost] + public ActionResult RenderPdfTexts(jsonObjects jsonObject) + { + PdfRenderer pdfviewer = new PdfRenderer(); + var jsonData = JsonConverter(jsonObject); + object jsonResult = pdfviewer.GetDocumentText(jsonData); + return Content(JsonConvert.SerializeObject(jsonResult)); + } + [System.Web.Mvc.HttpPost] public ActionResult Unload(jsonObjects jsonObject) { @@ -279,5 +339,6 @@ public class jsonObjects public string isFormFieldAnnotationsExist { get; set; } public string documentLiveCount { get; set; } public string annotationDataFormat { get; set; } + public string organizePages { get; set; } } } \ No newline at end of file diff --git a/PDFViewer/ASP.NET MVC Razor Examples/Views/Shared/_Layout.cshtml b/PDFViewer/ASP.NET MVC Razor Examples/Views/Shared/_Layout.cshtml index 8f88499..615e6a3 100644 --- a/PDFViewer/ASP.NET MVC Razor Examples/Views/Shared/_Layout.cshtml +++ b/PDFViewer/ASP.NET MVC Razor Examples/Views/Shared/_Layout.cshtml @@ -5,8 +5,8 @@ @ViewBag.Title - My ASP.NET Application @Styles.Render("~/Content/css") - - + +