@@ -60,6 +60,57 @@ public ActionResult Load(jsonObjects jsonObject)
6060 return Content ( JsonConvert . SerializeObject ( jsonResult ) ) ;
6161 }
6262
63+ [ System . Web . Mvc . HttpPost ]
64+ public ActionResult ValidatePassword ( jsonObjects jsonObject )
65+ {
66+ PdfRenderer pdfviewer = new PdfRenderer ( ) ;
67+ MemoryStream stream = new MemoryStream ( ) ;
68+ var jsonData = JsonConverter ( jsonObject ) ;
69+ object jsonResult = new object ( ) ;
70+ if ( jsonObject != null && jsonData . ContainsKey ( "document" ) )
71+ {
72+ if ( bool . Parse ( jsonData [ "isFileName" ] ) )
73+ {
74+ string documentPath = GetDocumentPath ( jsonData [ "document" ] ) ;
75+
76+ if ( ! string . IsNullOrEmpty ( documentPath ) )
77+ {
78+ byte [ ] bytes = System . IO . File . ReadAllBytes ( documentPath ) ;
79+ stream = new MemoryStream ( bytes ) ;
80+
81+ }
82+ else
83+ {
84+ string fileName = jsonData [ "document" ] . Split ( new string [ ] { "://" } , StringSplitOptions . None ) [ 0 ] ;
85+ if ( fileName == "http" || fileName == "https" )
86+ {
87+ var WebClient = new WebClient ( ) ;
88+ byte [ ] pdfDoc = WebClient . DownloadData ( jsonData [ "document" ] ) ;
89+ stream = new MemoryStream ( pdfDoc ) ;
90+ }
91+ else
92+ {
93+ return this . Content ( jsonData [ "document" ] + " is not found" ) ;
94+ }
95+
96+ }
97+ }
98+ else
99+ {
100+ byte [ ] bytes = Convert . FromBase64String ( jsonData [ "document" ] ) ;
101+ stream = new MemoryStream ( bytes ) ;
102+
103+ }
104+ }
105+ string password = null ;
106+ if ( jsonObject != null && jsonData . ContainsKey ( "password" ) )
107+ {
108+ password = jsonData [ "password" ] ;
109+ }
110+ var result = pdfviewer . Load ( stream , password ) ;
111+ return Content ( JsonConvert . SerializeObject ( result ) ) ;
112+ }
113+
63114 public Dictionary < string , string > JsonConverter ( jsonObjects results )
64115 {
65116 Dictionary < string , object > resultObjects = new Dictionary < string , object > ( ) ;
@@ -133,6 +184,15 @@ public ActionResult RenderPdfPages(jsonObjects jsonObject)
133184 return Content ( JsonConvert . SerializeObject ( jsonResult ) ) ;
134185 }
135186
187+ [ System . Web . Mvc . HttpPost ]
188+ public ActionResult RenderPdfTexts ( jsonObjects jsonObject )
189+ {
190+ PdfRenderer pdfviewer = new PdfRenderer ( ) ;
191+ var jsonData = JsonConverter ( jsonObject ) ;
192+ object jsonResult = pdfviewer . GetDocumentText ( jsonData ) ;
193+ return Content ( JsonConvert . SerializeObject ( jsonResult ) ) ;
194+ }
195+
136196 [ System . Web . Mvc . HttpPost ]
137197 public ActionResult Unload ( jsonObjects jsonObject )
138198 {
@@ -282,6 +342,6 @@ public class jsonObjects
282342 public bool isFormFieldAnnotationsExist { get ; set ; }
283343 public string documentLiveCount { get ; set ; }
284344 public string annotationDataFormat { get ; set ; }
285-
345+ public string organizePages { get ; set ; }
286346 }
287347}
0 commit comments