diff --git a/PDFViewer/ASP.NET Core Tag Helper Examples/Pages/Index.cshtml.cs b/PDFViewer/ASP.NET Core Tag Helper Examples/Pages/Index.cshtml.cs index 1f24ca8..e1b6a1a 100644 --- a/PDFViewer/ASP.NET Core Tag Helper Examples/Pages/Index.cshtml.cs +++ b/PDFViewer/ASP.NET Core Tag Helper Examples/Pages/Index.cshtml.cs @@ -60,6 +60,51 @@ public IActionResult OnPostLoad([FromBody] jsonObjects responseData) return Content(JsonConvert.SerializeObject(jsonResult)); } + public IActionResult OnPostValidatePassword([FromBody] jsonObjects responseData) + { + PdfRenderer pdfviewer = new PdfRenderer(_cache); + MemoryStream stream = new MemoryStream(); + var jsonObject = JsonConverterstring(responseData); + object jsonResult = new object(); + if (jsonObject != null && jsonObject.ContainsKey("document")) + { + if (bool.Parse(jsonObject["isFileName"])) + { + string documentPath = GetDocumentPath(jsonObject["document"]); + if (!string.IsNullOrEmpty(documentPath)) + { + byte[] bytes = System.IO.File.ReadAllBytes(documentPath); + stream = new MemoryStream(bytes); + } + else + { + string fileName = jsonObject["document"].Split(new string[] { "://" }, StringSplitOptions.None)[0]; + if (fileName == "http" || fileName == "https") + { + WebClient WebClient = new WebClient(); + byte[] pdfDoc = WebClient.DownloadData(jsonObject["document"]); + stream = new MemoryStream(pdfDoc); + } + else + return this.Content(jsonObject["document"] + " is not found"); + } + } + else + { + byte[] bytes = Convert.FromBase64String(jsonObject["document"]); + stream = new MemoryStream(bytes); + } + } + string password = null; + if (jsonObject.ContainsKey("password")) + { + password = jsonObject["password"]; + } + var result = pdfviewer.Load(stream, password); + + return Content(JsonConvert.SerializeObject(result)); + } + public Dictionary JsonConverterstring(jsonObjects results) { Dictionary resultObjects = new Dictionary(); @@ -81,6 +126,14 @@ public IActionResult OnPostRenderPdfPages([FromBody] jsonObjects responseData) return Content(JsonConvert.SerializeObject(jsonResult)); } + public IActionResult OnPostRenderPdfTexts([FromBody] jsonObjects responseData) + { + PdfRenderer pdfviewer = new PdfRenderer(_cache); + var jsonObject = JsonConverterstring(responseData); + object jsonResult = pdfviewer.GetDocumentText(jsonObject); + return Content(JsonConvert.SerializeObject(jsonResult)); + } + //Post action for unloading and disposing the PDF document resources public IActionResult OnPostUnload([FromBody] jsonObjects responseData) { @@ -215,7 +268,7 @@ public class jsonObjects public string document { get; set; } public string password { get; set; } public string zoomFactor { get; set; } - public string isFileName { get; set; } + public object isFileName { get; set; } public string xCoordinate { get; set; } public string yCoordinate { get; set; } public string pageNumber { get; set; } @@ -262,5 +315,7 @@ public class jsonObjects public string documentLiveCount { get; set; } public string annotationDataFormat { get; set; } public string importedData { get; set; } + public bool isClientsideLoading { get; set; } + public string organizePages { get; set; } } } \ No newline at end of file diff --git a/PDFViewer/ASP.NET Core Tag Helper Examples/Pages/Shared/_Layout.cshtml b/PDFViewer/ASP.NET Core Tag Helper Examples/Pages/Shared/_Layout.cshtml index 73fca1f..bb39335 100644 --- a/PDFViewer/ASP.NET Core Tag Helper Examples/Pages/Shared/_Layout.cshtml +++ b/PDFViewer/ASP.NET Core Tag Helper Examples/Pages/Shared/_Layout.cshtml @@ -6,9 +6,9 @@ @ViewData["Title"] - PDFViewerSample - + - +