@@ -21,11 +21,14 @@ public IndexModel(Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnviro
2121 _cache = cache ;
2222 }
2323
24- public IActionResult OnPostLoad ( [ FromBody ] jsonObjects responseData )
24+ [ HttpPost ( "Load" ) ]
25+ [ Microsoft . AspNetCore . Cors . EnableCors ( "MyPolicy" ) ]
26+ [ Route ( "[controller]/Load" ) ]
27+ //Post action for Loading the PDF documents
28+ public IActionResult OnPostLoad ( [ FromBody ] Dictionary < string , string > jsonObject )
2529 {
2630 PdfRenderer pdfviewer = new PdfRenderer ( _cache ) ;
2731 MemoryStream stream = new MemoryStream ( ) ;
28- var jsonObject = JsonConverterstring ( responseData ) ;
2932 object jsonResult = new object ( ) ;
3033 if ( jsonObject != null && jsonObject . ContainsKey ( "document" ) )
3134 {
@@ -60,27 +63,23 @@ public IActionResult OnPostLoad([FromBody] jsonObjects responseData)
6063 return Content ( JsonConvert . SerializeObject ( jsonResult ) ) ;
6164 }
6265
63- public Dictionary < string , string > JsonConverterstring ( jsonObjects results )
64- {
65- Dictionary < string , object > resultObjects = new Dictionary < string , object > ( ) ;
66- resultObjects = results . GetType ( ) . GetProperties ( BindingFlags . Instance | BindingFlags . Public )
67- . ToDictionary ( prop => prop . Name , prop => prop . GetValue ( results , null ) ) ;
68- var emptyObjects = ( from kv in resultObjects
69- where kv . Value != null
70- select kv ) . ToDictionary ( kv => kv . Key , kv => kv . Value ) ;
71- Dictionary < string , string > jsonResult = emptyObjects . ToDictionary ( k => k . Key , k => k . Value . ToString ( ) ) ;
72- return jsonResult ;
73- }
74-
66+ [ AcceptVerbs ( "Post" ) ]
67+ [ HttpPost ( "RenderPdfPages" ) ]
68+ [ Microsoft . AspNetCore . Cors . EnableCors ( "MyPolicy" ) ]
69+ [ Route ( "[controller]/RenderPdfPages" ) ]
7570 //Post action for processing the PDF documents.
76- public IActionResult OnPostRenderPdfPages ( [ FromBody ] jsonObjects responseData )
71+ public IActionResult OnPostRenderPdfPages ( [ FromBody ] Dictionary < string , string > jsonObject )
7772 {
7873 PdfRenderer pdfviewer = new PdfRenderer ( _cache ) ;
79- var jsonObject = JsonConverterstring ( responseData ) ;
8074 object jsonResult = pdfviewer . GetPage ( jsonObject ) ;
8175 return Content ( JsonConvert . SerializeObject ( jsonResult ) ) ;
8276 }
8377
78+ [ AcceptVerbs ( "Post" ) ]
79+ [ HttpPost ( "RenderPdfPages" ) ]
80+ [ Microsoft . AspNetCore . Cors . EnableCors ( "MyPolicy" ) ]
81+ [ Route ( "[controller]/RenderPdfPages" ) ]
82+ //Post action for processing the PDF documents
8483 public IActionResult RenderPdfTexts ( [ FromBody ] Dictionary < string , string > jsonObject )
8584 {
8685 //Initialize the PDF Viewer object with memory cache object
@@ -89,6 +88,10 @@ public IActionResult RenderPdfTexts([FromBody] Dictionary<string, string> jsonOb
8988 return Content ( JsonConvert . SerializeObject ( jsonResult ) ) ;
9089 }
9190
91+ [ AcceptVerbs ( "Post" ) ]
92+ [ HttpPost ( "ValidatePassword" ) ]
93+ [ Microsoft . AspNetCore . Cors . EnableCors ( "MyPolicy" ) ]
94+ [ Route ( "[controller]/ValidatePassword" ) ]
9295 public IActionResult ValidatePassword ( [ FromBody ] Dictionary < string , string > jsonObject )
9396 {
9497 PdfRenderer pdfviewer = new PdfRenderer ( _cache ) ;
@@ -138,56 +141,74 @@ public IActionResult ValidatePassword([FromBody] Dictionary<string, string> json
138141 }
139142
140143
141- //Post action for unloading and disposing the PDF document resources
142- public IActionResult OnPostUnload ( [ FromBody ] jsonObjects responseData )
144+ [ AcceptVerbs ( "Post" ) ]
145+ [ HttpPost ( "Unload" ) ]
146+ [ Microsoft . AspNetCore . Cors . EnableCors ( "MyPolicy" ) ]
147+ [ Route ( "[controller]/Unload" ) ]
148+ //Post action for unloading and disposing the PDF document resources
149+ public IActionResult OnPostUnload ( [ FromBody ] Dictionary < string , string > jsonObject )
143150 {
144151 PdfRenderer pdfviewer = new PdfRenderer ( _cache ) ;
145- var jsonObject = JsonConverterstring ( responseData ) ;
146152 pdfviewer . ClearCache ( jsonObject ) ;
147153 return this . Content ( "Document cache is cleared" ) ;
148154 }
149155
156+ [ AcceptVerbs ( "Post" ) ]
157+ [ HttpPost ( "RenderThumbnailImages" ) ]
158+ [ Microsoft . AspNetCore . Cors . EnableCors ( "MyPolicy" ) ]
159+ [ Route ( "[controller]/RenderThumbnailImages" ) ]
150160 //Post action for rendering the ThumbnailImages
151- public IActionResult OnPostRenderThumbnailImages ( [ FromBody ] jsonObjects responseData )
161+ public IActionResult OnPostRenderThumbnailImages ( [ FromBody ] Dictionary < string , string > jsonObject )
152162 {
153163 PdfRenderer pdfviewer = new PdfRenderer ( _cache ) ;
154- var jsonObject = JsonConverterstring ( responseData ) ;
155164 object result = pdfviewer . GetThumbnailImages ( jsonObject ) ;
156165 return Content ( JsonConvert . SerializeObject ( result ) ) ;
157166 }
158167
168+ [ AcceptVerbs ( "Post" ) ]
169+ [ HttpPost ( "Bookmarks" ) ]
170+ [ Microsoft . AspNetCore . Cors . EnableCors ( "MyPolicy" ) ]
171+ [ Route ( "[controller]/Bookmarks" ) ]
159172 //Post action for processing the bookmarks from the PDF documents
160- public IActionResult OnPostBookmarks ( [ FromBody ] jsonObjects responseData )
173+ public IActionResult OnPostBookmarks ( [ FromBody ] Dictionary < string , string > jsonObject )
161174 {
162175 PdfRenderer pdfviewer = new PdfRenderer ( _cache ) ;
163- var jsonObject = JsonConverterstring ( responseData ) ;
164176 object jsonResult = pdfviewer . GetBookmarks ( jsonObject ) ;
165177 return Content ( JsonConvert . SerializeObject ( jsonResult ) ) ;
166178 }
167179
180+ [ AcceptVerbs ( "Post" ) ]
181+ [ HttpPost ( "RenderAnnotationComments" ) ]
182+ [ Microsoft . AspNetCore . Cors . EnableCors ( "MyPolicy" ) ]
183+ [ Route ( "[controller]/RenderAnnotationComments" ) ]
168184 //Post action for rendering the annotation comments
169- public IActionResult OnPostRenderAnnotationComments ( [ FromBody ] jsonObjects responseData )
185+ public IActionResult OnPostRenderAnnotationComments ( [ FromBody ] Dictionary < string , string > jsonObject )
170186 {
171187 PdfRenderer pdfviewer = new PdfRenderer ( _cache ) ;
172- var jsonObject = JsonConverterstring ( responseData ) ;
173188 object jsonResult = pdfviewer . GetAnnotationComments ( jsonObject ) ;
174189 return Content ( JsonConvert . SerializeObject ( jsonResult ) ) ;
175190 }
176191
192+ [ AcceptVerbs ( "Post" ) ]
193+ [ HttpPost ( "ExportAnnotations" ) ]
194+ [ Microsoft . AspNetCore . Cors . EnableCors ( "MyPolicy" ) ]
195+ [ Route ( "[controller]/ExportAnnotations" ) ]
177196 //Post action for exporting the annotations
178- public IActionResult OnPostExportAnnotations ( [ FromBody ] jsonObjects responseData )
197+ public IActionResult OnPostExportAnnotations ( [ FromBody ] Dictionary < string , string > jsonObject )
179198 {
180199 PdfRenderer pdfviewer = new PdfRenderer ( _cache ) ;
181- var jsonObject = JsonConverterstring ( responseData ) ;
182200 string jsonResult = pdfviewer . ExportAnnotation ( jsonObject ) ;
183201 return Content ( jsonResult ) ;
184202 }
185203
204+ [ AcceptVerbs ( "Post" ) ]
205+ [ HttpPost ( "ImportAnnotations" ) ]
206+ [ Microsoft . AspNetCore . Cors . EnableCors ( "MyPolicy" ) ]
207+ [ Route ( "[controller]/ImportAnnotations" ) ]
186208 //Post action for importing the annotations
187- public IActionResult OnPostImportAnnotations ( [ FromBody ] jsonObjects responseData )
209+ public IActionResult OnPostImportAnnotations ( [ FromBody ] Dictionary < string , string > jsonObject )
188210 {
189211 PdfRenderer pdfviewer = new PdfRenderer ( _cache ) ;
190- var jsonObject = JsonConverterstring ( responseData ) ;
191212 string jsonResult = string . Empty ;
192213 object JsonResult ;
193214 if ( jsonObject != null && jsonObject . ContainsKey ( "fileName" ) )
@@ -229,20 +250,24 @@ public IActionResult OnPostImportAnnotations([FromBody] jsonObjects responseData
229250 return Content ( jsonResult ) ;
230251 }
231252
253+ [ HttpPost ( "Download" ) ]
254+ [ Microsoft . AspNetCore . Cors . EnableCors ( "MyPolicy" ) ]
255+ [ Route ( "[controller]/Download" ) ]
232256 //Post action for downloading the PDF documents
233- public IActionResult OnPostDownload ( [ FromBody ] jsonObjects responseData )
257+ public IActionResult OnPostDownload ( [ FromBody ] Dictionary < string , string > jsonObject )
234258 {
235259 PdfRenderer pdfviewer = new PdfRenderer ( _cache ) ;
236- var jsonObject = JsonConverterstring ( responseData ) ;
237260 string documentBase = pdfviewer . GetDocumentAsBase64 ( jsonObject ) ;
238261 return Content ( documentBase ) ;
239262 }
240263
264+ [ HttpPost ( "PrintImages" ) ]
265+ [ Microsoft . AspNetCore . Cors . EnableCors ( "MyPolicy" ) ]
266+ [ Route ( "[controller]/PrintImages" ) ]
241267 //Post action for printing the PDF documents
242- public IActionResult OnPostPrintImages ( [ FromBody ] jsonObjects responseData )
268+ public IActionResult OnPostPrintImages ( [ FromBody ] Dictionary < string , string > jsonObject )
243269 {
244270 PdfRenderer pdfviewer = new PdfRenderer ( _cache ) ;
245- var jsonObject = JsonConverterstring ( responseData ) ;
246271 object pageImage = pdfviewer . GetPrintImage ( jsonObject ) ;
247272 return Content ( JsonConvert . SerializeObject ( pageImage ) ) ;
248273 }
@@ -266,58 +291,4 @@ private string GetDocumentPath(string document)
266291 return documentPath ;
267292 }
268293 }
269-
270- public class jsonObjects
271- {
272- public string document { get ; set ; }
273- public string password { get ; set ; }
274- public string zoomFactor { get ; set ; }
275- public string isFileName { get ; set ; }
276- public string xCoordinate { get ; set ; }
277- public string yCoordinate { get ; set ; }
278- public string pageNumber { get ; set ; }
279- public string documentId { get ; set ; }
280- public string hashId { get ; set ; }
281- public string sizeX { get ; set ; }
282- public string sizeY { get ; set ; }
283- public string startPage { get ; set ; }
284- public string endPage { get ; set ; }
285- public string stampAnnotations { get ; set ; }
286- public string textMarkupAnnotations { get ; set ; }
287- public string stickyNotesAnnotation { get ; set ; }
288- public string shapeAnnotations { get ; set ; }
289- public string measureShapeAnnotations { get ; set ; }
290- public string action { get ; set ; }
291- public string pageStartIndex { get ; set ; }
292- public string pageEndIndex { get ; set ; }
293- public string fileName { get ; set ; }
294- public string elementId { get ; set ; }
295- public string pdfAnnotation { get ; set ; }
296- public string importPageList { get ; set ; }
297- public string uniqueId { get ; set ; }
298- public string data { get ; set ; }
299- public string viewPortWidth { get ; set ; }
300- public string viewPortHeight { get ; set ; }
301- public string tilecount { get ; set ; }
302- public bool isCompletePageSizeNotReceived { get ; set ; }
303- public string freeTextAnnotation { get ; set ; }
304- public string signatureData { get ; set ; }
305- public string fieldsData { get ; set ; }
306- public string FormDesigner { get ; set ; }
307- public string inkSignatureData { get ; set ; }
308- public bool hideEmptyDigitalSignatureFields { get ; set ; }
309- public bool showDigitalSignatureAppearance { get ; set ; }
310- public bool digitalSignaturePresent { get ; set ; }
311- public string tileXCount { get ; set ; }
312- public string tileYCount { get ; set ; }
313- public string digitalSignaturePageList { get ; set ; }
314- public string annotationCollection { get ; set ; }
315- public string annotationsPageList { get ; set ; }
316- public string formFieldsPageList { get ; set ; }
317- public bool isAnnotationsExist { get ; set ; }
318- public bool isFormFieldAnnotationsExist { get ; set ; }
319- public string documentLiveCount { get ; set ; }
320- public string annotationDataFormat { get ; set ; }
321- public string importedData { get ; set ; }
322- }
323294}
0 commit comments