From c8ac6fdff5280982a062c495e34369ae47f9b0c9 Mon Sep 17 00:00:00 2001
From: VijayalakshmiGSF4561 <vijayalakshmi.govindan@syncfusion.com>
Date: Fri, 27 Sep 2024 13:44:35 +0530
Subject: [PATCH 1/3] 897552: Modified index file

---
 .../PDFViewerSample/Pages/Index.cshtml.cs     | 313 +++++++++++++++++-
 1 file changed, 308 insertions(+), 5 deletions(-)

diff --git a/How to/Add Handwritten Signature Programmatically/PDFViewerSample/PDFViewerSample/Pages/Index.cshtml.cs b/How to/Add Handwritten Signature Programmatically/PDFViewerSample/PDFViewerSample/Pages/Index.cshtml.cs
index ef356dd..4144c59 100644
--- a/How to/Add Handwritten Signature Programmatically/PDFViewerSample/PDFViewerSample/Pages/Index.cshtml.cs	
+++ b/How to/Add Handwritten Signature Programmatically/PDFViewerSample/PDFViewerSample/Pages/Index.cshtml.cs	
@@ -1,20 +1,323 @@
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Caching.Memory;
+using Syncfusion.EJ2.PdfViewer;
+using Newtonsoft.Json;
 using Microsoft.AspNetCore.Mvc.RazorPages;
+using System.Reflection;
+using System.Net;
 
 namespace PDFViewerSample.Pages
 {
+    [IgnoreAntiforgeryToken(Order = 1001)]
     public class IndexModel : PageModel
     {
-        private readonly ILogger<IndexModel> _logger;
 
-        public IndexModel(ILogger<IndexModel> logger)
+        private readonly Microsoft.AspNetCore.Hosting.IHostingEnvironment _hostingEnvironment;
+        private IMemoryCache _cache;
+
+        public IndexModel(Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment, IMemoryCache cache)
+        {
+            _hostingEnvironment = hostingEnvironment;
+            _cache = cache;
+        }
+
+        public IActionResult OnPostLoad([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);
+                }
+            }
+            jsonResult = pdfviewer.Load(stream, jsonObject);
+            return Content(JsonConvert.SerializeObject(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;
+        }
+
+        //Post action for processing the PDF documents.
+        public IActionResult OnPostRenderPdfPages([FromBody] jsonObjects responseData)
+        {
+            PdfRenderer pdfviewer = new PdfRenderer(_cache);
+            var jsonObject = JsonConverterstring(responseData);
+            object jsonResult = pdfviewer.GetPage(jsonObject);
+            return Content(JsonConvert.SerializeObject(jsonResult));
+        }
+
+         public IActionResult RenderPdfTexts([FromBody] Dictionary<string, string> jsonObject)
+        {
+            //Initialize the PDF Viewer object with memory cache object
+            PdfRenderer pdfviewer = new PdfRenderer(_cache);
+            object jsonResult = pdfviewer.GetDocumentText(jsonObject);
+            return Content(JsonConvert.SerializeObject(jsonResult));
+        }
+
+         public IActionResult ValidatePassword([FromBody] Dictionary<string, string> jsonObject)
+        {
+            PdfRenderer pdfviewer = new PdfRenderer(_cache);
+            MemoryStream stream = new MemoryStream();
+            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));
+        }
+
+
+        //Post action for unloading and disposing the PDF document resources
+        public IActionResult OnPostUnload([FromBody] jsonObjects responseData)
         {
-            _logger = logger;
+            PdfRenderer pdfviewer = new PdfRenderer(_cache);
+            var jsonObject = JsonConverterstring(responseData);
+            pdfviewer.ClearCache(jsonObject);
+            return this.Content("Document cache is cleared");
         }
 
-        public void OnGet()
+        //Post action for rendering the ThumbnailImages
+        public IActionResult OnPostRenderThumbnailImages([FromBody] jsonObjects responseData)
         {
+            PdfRenderer pdfviewer = new PdfRenderer(_cache);
+            var jsonObject = JsonConverterstring(responseData);
+            object result = pdfviewer.GetThumbnailImages(jsonObject);
+            return Content(JsonConvert.SerializeObject(result));
+        }
+
+        //Post action for processing the bookmarks from the PDF documents
+        public IActionResult OnPostBookmarks([FromBody] jsonObjects responseData)
+        {
+            PdfRenderer pdfviewer = new PdfRenderer(_cache);
+            var jsonObject = JsonConverterstring(responseData);
+            object jsonResult = pdfviewer.GetBookmarks(jsonObject);
+            return Content(JsonConvert.SerializeObject(jsonResult));
+        }
+
+        //Post action for rendering the annotation comments
+        public IActionResult OnPostRenderAnnotationComments([FromBody] jsonObjects responseData)
+        {
+            PdfRenderer pdfviewer = new PdfRenderer(_cache);
+            var jsonObject = JsonConverterstring(responseData);
+            object jsonResult = pdfviewer.GetAnnotationComments(jsonObject);
+            return Content(JsonConvert.SerializeObject(jsonResult));
+        }
+
+        //Post action for exporting the annotations
+        public IActionResult OnPostExportAnnotations([FromBody] jsonObjects responseData)
+        {
+            PdfRenderer pdfviewer = new PdfRenderer(_cache);
+            var jsonObject = JsonConverterstring(responseData);
+            string jsonResult = pdfviewer.ExportAnnotation(jsonObject);
+            return Content(jsonResult);
+        }
 
+        //Post action for importing the annotations
+        public IActionResult OnPostImportAnnotations([FromBody] jsonObjects responseData)
+        {
+            PdfRenderer pdfviewer = new PdfRenderer(_cache);
+            var jsonObject = JsonConverterstring(responseData);
+            string jsonResult = string.Empty;
+            object JsonResult;
+            if (jsonObject != null && jsonObject.ContainsKey("fileName"))
+            {
+                string documentPath = GetDocumentPath(jsonObject["fileName"]);
+                if (!string.IsNullOrEmpty(documentPath))
+                {
+                    jsonResult = System.IO.File.ReadAllText(documentPath);
+                }
+                else
+                {
+                    return this.Content(jsonObject["document"] + " is not found");
+                }
+            }
+            else
+            {
+                string extension = Path.GetExtension(jsonObject["importedData"]);
+                if (extension != ".xfdf")
+                {
+                    JsonResult = pdfviewer.ImportAnnotation(jsonObject);
+                    return Content(JsonConvert.SerializeObject(JsonResult));
+                }
+                else
+                {
+                    string documentPath = GetDocumentPath(jsonObject["importedData"]);
+                    if (!string.IsNullOrEmpty(documentPath))
+                    {
+                        byte[] bytes = System.IO.File.ReadAllBytes(documentPath);
+                        jsonObject["importedData"] = Convert.ToBase64String(bytes);
+                        JsonResult = pdfviewer.ImportAnnotation(jsonObject);
+                        return Content(JsonConvert.SerializeObject(JsonResult));
+                    }
+                    else
+                    {
+                        return this.Content(jsonObject["document"] + " is not found");
+                    }
+                }
+            }
+            return Content(jsonResult);
         }
+
+        //Post action for downloading the PDF documents
+        public IActionResult OnPostDownload([FromBody] jsonObjects responseData)
+        {
+            PdfRenderer pdfviewer = new PdfRenderer(_cache);
+            var jsonObject = JsonConverterstring(responseData);
+            string documentBase = pdfviewer.GetDocumentAsBase64(jsonObject);
+            return Content(documentBase);
+        }
+
+        //Post action for printing the PDF documents
+        public IActionResult OnPostPrintImages([FromBody] jsonObjects responseData)
+        {
+            PdfRenderer pdfviewer = new PdfRenderer(_cache);
+            var jsonObject = JsonConverterstring(responseData);
+            object pageImage = pdfviewer.GetPrintImage(jsonObject);
+            return Content(JsonConvert.SerializeObject(pageImage));
+        }
+
+        //Gets the path of the PDF document
+        private string GetDocumentPath(string document)
+        {
+            string documentPath = string.Empty;
+            if (!System.IO.File.Exists(document))
+            {
+                string basePath = _hostingEnvironment.WebRootPath;
+                string dataPath = string.Empty;
+                dataPath = basePath + "/";
+                if (System.IO.File.Exists(dataPath + (document)))
+                    documentPath = dataPath + document;
+            }
+            else
+            {
+                documentPath = document;
+            }
+            return documentPath;
+        }
+    }
+
+    public class jsonObjects
+    {
+        public string document { get; set; }
+        public string password { get; set; }
+        public string zoomFactor { get; set; }
+        public string isFileName { get; set; }
+        public string xCoordinate { get; set; }
+        public string yCoordinate { get; set; }
+        public string pageNumber { get; set; }
+        public string documentId { get; set; }
+        public string hashId { get; set; }
+        public string sizeX { get; set; }
+        public string sizeY { get; set; }
+        public string startPage { get; set; }
+        public string endPage { get; set; }
+        public string stampAnnotations { get; set; }
+        public string textMarkupAnnotations { get; set; }
+        public string stickyNotesAnnotation { get; set; }
+        public string shapeAnnotations { get; set; }
+        public string measureShapeAnnotations { get; set; }
+        public string action { get; set; }
+        public string pageStartIndex { get; set; }
+        public string pageEndIndex { get; set; }
+        public string fileName { get; set; }
+        public string elementId { get; set; }
+        public string pdfAnnotation { get; set; }
+        public string importPageList { get; set; }
+        public string uniqueId { get; set; }
+        public string data { get; set; }
+        public string viewPortWidth { get; set; }
+        public string viewPortHeight { get; set; }
+        public string tilecount { get; set; }
+        public bool isCompletePageSizeNotReceived { get; set; }
+        public string freeTextAnnotation { get; set; }
+        public string signatureData { get; set; }
+        public string fieldsData { get; set; }
+        public string FormDesigner { get; set; }
+        public string inkSignatureData { get; set; }
+        public bool hideEmptyDigitalSignatureFields { get; set; }
+        public bool showDigitalSignatureAppearance { get; set; }
+        public bool digitalSignaturePresent { get; set; }
+        public string tileXCount { get; set; }
+        public string tileYCount { get; set; }
+        public string digitalSignaturePageList { get; set; }
+        public string annotationCollection { get; set; }
+        public string annotationsPageList { get; set; }
+        public string formFieldsPageList { get; set; }
+        public bool isAnnotationsExist { get; set; }
+        public bool isFormFieldAnnotationsExist { get; set; }
+        public string documentLiveCount { get; set; }
+        public string annotationDataFormat { get; set; }
+        public string importedData { get; set; }
     }
-}
+}
\ No newline at end of file

From 204a9d5c3946a9a15eac6e38abe069bc0f13f49b Mon Sep 17 00:00:00 2001
From: VijayalakshmiGSF4561 <vijayalakshmi.govindan@syncfusion.com>
Date: Fri, 27 Sep 2024 15:46:49 +0530
Subject: [PATCH 2/3] 897552: Included package

---
 .../PDFViewerSample/PDFViewerSample/PDFViewerSample.csproj       | 1 +
 1 file changed, 1 insertion(+)

diff --git a/How to/Add Handwritten Signature Programmatically/PDFViewerSample/PDFViewerSample/PDFViewerSample.csproj b/How to/Add Handwritten Signature Programmatically/PDFViewerSample/PDFViewerSample/PDFViewerSample.csproj
index 9f067fe..2baa1b9 100644
--- a/How to/Add Handwritten Signature Programmatically/PDFViewerSample/PDFViewerSample/PDFViewerSample.csproj	
+++ b/How to/Add Handwritten Signature Programmatically/PDFViewerSample/PDFViewerSample/PDFViewerSample.csproj	
@@ -9,6 +9,7 @@
 
   <ItemGroup>
     <PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="*" />
+    <PackageReference Include="Syncfusion.EJ2.PdfViewer.AspNet.Core" Version="*" />
   </ItemGroup>
 
 </Project>

From bf0569dd02a4a574341ab2ef65561f78974c9987 Mon Sep 17 00:00:00 2001
From: VijayalakshmiGSF4561 <vijayalakshmi.govindan@syncfusion.com>
Date: Mon, 30 Sep 2024 10:00:15 +0530
Subject: [PATCH 3/3] :Removed comment lines

---
 .../PDFViewerSample/Pages/Index.cshtml.cs     | 145 +++++++-----------
 1 file changed, 58 insertions(+), 87 deletions(-)

diff --git a/How to/Add Handwritten Signature Programmatically/PDFViewerSample/PDFViewerSample/Pages/Index.cshtml.cs b/How to/Add Handwritten Signature Programmatically/PDFViewerSample/PDFViewerSample/Pages/Index.cshtml.cs
index 4144c59..50897ef 100644
--- a/How to/Add Handwritten Signature Programmatically/PDFViewerSample/PDFViewerSample/Pages/Index.cshtml.cs	
+++ b/How to/Add Handwritten Signature Programmatically/PDFViewerSample/PDFViewerSample/Pages/Index.cshtml.cs	
@@ -21,11 +21,14 @@ public IndexModel(Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnviro
             _cache = cache;
         }
 
-        public IActionResult OnPostLoad([FromBody] jsonObjects responseData)
+        [HttpPost("Load")]
+        [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
+        [Route("[controller]/Load")]
+        //Post action for Loading the PDF documents  
+        public IActionResult OnPostLoad([FromBody] Dictionary<string, string> jsonObject)
         {
             PdfRenderer pdfviewer = new PdfRenderer(_cache);
             MemoryStream stream = new MemoryStream();
-            var jsonObject = JsonConverterstring(responseData);
             object jsonResult = new object();
             if (jsonObject != null && jsonObject.ContainsKey("document"))
             {
@@ -60,27 +63,23 @@ public IActionResult OnPostLoad([FromBody] jsonObjects responseData)
             return Content(JsonConvert.SerializeObject(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;
-        }
-
+        [AcceptVerbs("Post")]
+        [HttpPost("RenderPdfPages")]
+        [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
+        [Route("[controller]/RenderPdfPages")]
         //Post action for processing the PDF documents.
-        public IActionResult OnPostRenderPdfPages([FromBody] jsonObjects responseData)
+        public IActionResult OnPostRenderPdfPages([FromBody] Dictionary<string, string> jsonObject)
         {
             PdfRenderer pdfviewer = new PdfRenderer(_cache);
-            var jsonObject = JsonConverterstring(responseData);
             object jsonResult = pdfviewer.GetPage(jsonObject);
             return Content(JsonConvert.SerializeObject(jsonResult));
         }
 
+        [AcceptVerbs("Post")]
+        [HttpPost("RenderPdfPages")]
+        [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
+        [Route("[controller]/RenderPdfPages")]
+        //Post action for processing the PDF documents
          public IActionResult RenderPdfTexts([FromBody] Dictionary<string, string> jsonObject)
         {
             //Initialize the PDF Viewer object with memory cache object
@@ -89,6 +88,10 @@ public IActionResult RenderPdfTexts([FromBody] Dictionary<string, string> jsonOb
             return Content(JsonConvert.SerializeObject(jsonResult));
         }
 
+        [AcceptVerbs("Post")]
+        [HttpPost("ValidatePassword")]
+        [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
+        [Route("[controller]/ValidatePassword")]
          public IActionResult ValidatePassword([FromBody] Dictionary<string, string> jsonObject)
         {
             PdfRenderer pdfviewer = new PdfRenderer(_cache);
@@ -138,56 +141,74 @@ public IActionResult ValidatePassword([FromBody] Dictionary<string, string> json
         }
 
 
-        //Post action for unloading and disposing the PDF document resources
-        public IActionResult OnPostUnload([FromBody] jsonObjects responseData)
+        [AcceptVerbs("Post")]
+        [HttpPost("Unload")]
+        [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
+        [Route("[controller]/Unload")]
+        //Post action for unloading and disposing the PDF document resources  
+        public IActionResult OnPostUnload([FromBody] Dictionary<string, string> jsonObject)
         {
             PdfRenderer pdfviewer = new PdfRenderer(_cache);
-            var jsonObject = JsonConverterstring(responseData);
             pdfviewer.ClearCache(jsonObject);
             return this.Content("Document cache is cleared");
         }
 
+        [AcceptVerbs("Post")]
+        [HttpPost("RenderThumbnailImages")]
+        [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
+        [Route("[controller]/RenderThumbnailImages")]
         //Post action for rendering the ThumbnailImages
-        public IActionResult OnPostRenderThumbnailImages([FromBody] jsonObjects responseData)
+        public IActionResult OnPostRenderThumbnailImages([FromBody] Dictionary<string, string> jsonObject)
         {
             PdfRenderer pdfviewer = new PdfRenderer(_cache);
-            var jsonObject = JsonConverterstring(responseData);
             object result = pdfviewer.GetThumbnailImages(jsonObject);
             return Content(JsonConvert.SerializeObject(result));
         }
 
+        [AcceptVerbs("Post")]
+        [HttpPost("Bookmarks")]
+        [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
+        [Route("[controller]/Bookmarks")]
         //Post action for processing the bookmarks from the PDF documents
-        public IActionResult OnPostBookmarks([FromBody] jsonObjects responseData)
+        public IActionResult OnPostBookmarks([FromBody] Dictionary<string, string> jsonObject)
         {
             PdfRenderer pdfviewer = new PdfRenderer(_cache);
-            var jsonObject = JsonConverterstring(responseData);
             object jsonResult = pdfviewer.GetBookmarks(jsonObject);
             return Content(JsonConvert.SerializeObject(jsonResult));
         }
 
+        [AcceptVerbs("Post")]
+        [HttpPost("RenderAnnotationComments")]
+        [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
+        [Route("[controller]/RenderAnnotationComments")]
         //Post action for rendering the annotation comments
-        public IActionResult OnPostRenderAnnotationComments([FromBody] jsonObjects responseData)
+        public IActionResult OnPostRenderAnnotationComments([FromBody] Dictionary<string, string> jsonObject)
         {
             PdfRenderer pdfviewer = new PdfRenderer(_cache);
-            var jsonObject = JsonConverterstring(responseData);
             object jsonResult = pdfviewer.GetAnnotationComments(jsonObject);
             return Content(JsonConvert.SerializeObject(jsonResult));
         }
 
+        [AcceptVerbs("Post")]
+        [HttpPost("ExportAnnotations")]
+        [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
+        [Route("[controller]/ExportAnnotations")]
         //Post action for exporting the annotations
-        public IActionResult OnPostExportAnnotations([FromBody] jsonObjects responseData)
+        public IActionResult OnPostExportAnnotations([FromBody] Dictionary<string, string> jsonObject)
         {
             PdfRenderer pdfviewer = new PdfRenderer(_cache);
-            var jsonObject = JsonConverterstring(responseData);
             string jsonResult = pdfviewer.ExportAnnotation(jsonObject);
             return Content(jsonResult);
         }
 
+        [AcceptVerbs("Post")]
+        [HttpPost("ImportAnnotations")]
+        [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
+        [Route("[controller]/ImportAnnotations")]
         //Post action for importing the annotations
-        public IActionResult OnPostImportAnnotations([FromBody] jsonObjects responseData)
+        public IActionResult OnPostImportAnnotations([FromBody] Dictionary<string, string> jsonObject)
         {
             PdfRenderer pdfviewer = new PdfRenderer(_cache);
-            var jsonObject = JsonConverterstring(responseData);
             string jsonResult = string.Empty;
             object JsonResult;
             if (jsonObject != null && jsonObject.ContainsKey("fileName"))
@@ -229,20 +250,24 @@ public IActionResult OnPostImportAnnotations([FromBody] jsonObjects responseData
             return Content(jsonResult);
         }
 
+        [HttpPost("Download")]
+        [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
+        [Route("[controller]/Download")]
         //Post action for downloading the PDF documents
-        public IActionResult OnPostDownload([FromBody] jsonObjects responseData)
+        public IActionResult OnPostDownload([FromBody] Dictionary<string, string> jsonObject)
         {
             PdfRenderer pdfviewer = new PdfRenderer(_cache);
-            var jsonObject = JsonConverterstring(responseData);
             string documentBase = pdfviewer.GetDocumentAsBase64(jsonObject);
             return Content(documentBase);
         }
 
+        [HttpPost("PrintImages")]
+        [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
+        [Route("[controller]/PrintImages")]
         //Post action for printing the PDF documents
-        public IActionResult OnPostPrintImages([FromBody] jsonObjects responseData)
+        public IActionResult OnPostPrintImages([FromBody] Dictionary<string, string> jsonObject)
         {
             PdfRenderer pdfviewer = new PdfRenderer(_cache);
-            var jsonObject = JsonConverterstring(responseData);
             object pageImage = pdfviewer.GetPrintImage(jsonObject);
             return Content(JsonConvert.SerializeObject(pageImage));
         }
@@ -266,58 +291,4 @@ private string GetDocumentPath(string document)
             return documentPath;
         }
     }
-
-    public class jsonObjects
-    {
-        public string document { get; set; }
-        public string password { get; set; }
-        public string zoomFactor { get; set; }
-        public string isFileName { get; set; }
-        public string xCoordinate { get; set; }
-        public string yCoordinate { get; set; }
-        public string pageNumber { get; set; }
-        public string documentId { get; set; }
-        public string hashId { get; set; }
-        public string sizeX { get; set; }
-        public string sizeY { get; set; }
-        public string startPage { get; set; }
-        public string endPage { get; set; }
-        public string stampAnnotations { get; set; }
-        public string textMarkupAnnotations { get; set; }
-        public string stickyNotesAnnotation { get; set; }
-        public string shapeAnnotations { get; set; }
-        public string measureShapeAnnotations { get; set; }
-        public string action { get; set; }
-        public string pageStartIndex { get; set; }
-        public string pageEndIndex { get; set; }
-        public string fileName { get; set; }
-        public string elementId { get; set; }
-        public string pdfAnnotation { get; set; }
-        public string importPageList { get; set; }
-        public string uniqueId { get; set; }
-        public string data { get; set; }
-        public string viewPortWidth { get; set; }
-        public string viewPortHeight { get; set; }
-        public string tilecount { get; set; }
-        public bool isCompletePageSizeNotReceived { get; set; }
-        public string freeTextAnnotation { get; set; }
-        public string signatureData { get; set; }
-        public string fieldsData { get; set; }
-        public string FormDesigner { get; set; }
-        public string inkSignatureData { get; set; }
-        public bool hideEmptyDigitalSignatureFields { get; set; }
-        public bool showDigitalSignatureAppearance { get; set; }
-        public bool digitalSignaturePresent { get; set; }
-        public string tileXCount { get; set; }
-        public string tileYCount { get; set; }
-        public string digitalSignaturePageList { get; set; }
-        public string annotationCollection { get; set; }
-        public string annotationsPageList { get; set; }
-        public string formFieldsPageList { get; set; }
-        public bool isAnnotationsExist { get; set; }
-        public bool isFormFieldAnnotationsExist { get; set; }
-        public string documentLiveCount { get; set; }
-        public string annotationDataFormat { get; set; }
-        public string importedData { get; set; }
-    }
 }
\ No newline at end of file