Skip to content

Commit 8c05f50

Browse files
931795: Removed unnecessary code blocks in controller file
1 parent 1679577 commit 8c05f50

File tree

1 file changed

+0
-201
lines changed
  • How to/Load PDF to Server Side PDF Viewer/Load-PDF-to-Server-Side-PDF-Viewer/Controllers

1 file changed

+0
-201
lines changed

How to/Load PDF to Server Side PDF Viewer/Load-PDF-to-Server-Side-PDF-Viewer/Controllers/PdfViewerController.cs

Lines changed: 0 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -25,207 +25,6 @@ public IActionResult Index()
2525
return View();
2626
}
2727

28-
[HttpPost]
29-
//Post action for Loading the PDF documents
30-
public IActionResult Load([FromBody] Dictionary<string, string> jsonObject)
31-
{
32-
Console.WriteLine("Load called");
33-
//Initialize the PDF viewer object with memory cache object
34-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
35-
MemoryStream stream = new MemoryStream();
36-
object jsonResult = new object();
37-
if (jsonObject != null && jsonObject.ContainsKey("document"))
38-
{
39-
if (bool.Parse(jsonObject["isFileName"]))
40-
{
41-
string documentPath = GetDocumentPath(jsonObject["document"]);
42-
if (!string.IsNullOrEmpty(documentPath))
43-
{
44-
byte[] bytes = System.IO.File.ReadAllBytes(documentPath);
45-
stream = new MemoryStream(bytes);
46-
}
47-
else
48-
{
49-
string fileName = jsonObject["document"].Split(new string[] { "://" }, StringSplitOptions.None)[0];
50-
51-
if (fileName == "http" || fileName == "https")
52-
{
53-
WebClient WebClient = new WebClient();
54-
byte[] pdfDoc = WebClient.DownloadData(jsonObject["document"]);
55-
stream = new MemoryStream(pdfDoc);
56-
}
57-
58-
else
59-
{
60-
return this.Content(jsonObject["document"] + " is not found");
61-
}
62-
}
63-
}
64-
else
65-
{
66-
byte[] bytes = Convert.FromBase64String(jsonObject["document"]);
67-
stream = new MemoryStream(bytes);
68-
}
69-
}
70-
jsonResult = pdfviewer.Load(stream, jsonObject);
71-
return Content(JsonConvert.SerializeObject(jsonResult));
72-
}
73-
74-
[HttpPost]
75-
//Post action for processing the bookmarks from the PDF documents
76-
public IActionResult Bookmarks([FromBody] Dictionary<string, string> jsonObject)
77-
{
78-
//Initialize the PDF Viewer object with memory cache object
79-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
80-
var jsonResult = pdfviewer.GetBookmarks(jsonObject);
81-
return Content(JsonConvert.SerializeObject(jsonResult));
82-
}
83-
84-
[HttpPost]
85-
//Post action for processing the PDF documents
86-
public IActionResult RenderPdfPages([FromBody] Dictionary<string, string> jsonObject)
87-
{
88-
//Initialize the PDF Viewer object with memory cache object
89-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
90-
object jsonResult = pdfviewer.GetPage(jsonObject);
91-
return Content(JsonConvert.SerializeObject(jsonResult));
92-
}
93-
94-
[HttpPost]
95-
//Post action for processing the PDF texts
96-
public IActionResult RenderPdfTexts([FromBody] Dictionary<string, string> jsonObject)
97-
{
98-
//Initialize the PDF Viewer object with memory cache object
99-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
100-
object jsonResult = pdfviewer.GetDocumentText(jsonObject);
101-
return Content(JsonConvert.SerializeObject(jsonResult));
102-
}
103-
104-
[HttpPost]
105-
//Post action for rendering the ThumbnailImages
106-
public IActionResult RenderThumbnailImages([FromBody] Dictionary<string, string> jsonObject)
107-
{
108-
//Initialize the PDF Viewer object with memory cache object
109-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
110-
object result = pdfviewer.GetThumbnailImages(jsonObject);
111-
return Content(JsonConvert.SerializeObject(result));
112-
}
113-
114-
[HttpPost]
115-
//Post action for rendering the annotations
116-
public IActionResult RenderAnnotationComments([FromBody] Dictionary<string, string> jsonObject)
117-
{
118-
//Initialize the PDF Viewer object with memory cache object
119-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
120-
object jsonResult = pdfviewer.GetAnnotationComments(jsonObject);
121-
return Content(JsonConvert.SerializeObject(jsonResult));
122-
}
123-
124-
[HttpPost]
125-
//Post action to export annotations
126-
public IActionResult ExportAnnotations([FromBody] Dictionary<string, string> jsonObject)
127-
{
128-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
129-
string jsonResult = pdfviewer.ExportAnnotation(jsonObject);
130-
return Content(jsonResult);
131-
}
132-
133-
[HttpPost]
134-
//Post action to import annotations
135-
public IActionResult ImportAnnotations([FromBody] Dictionary<string, string> jsonObject)
136-
{
137-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
138-
string jsonResult = string.Empty;
139-
object JsonResult;
140-
if (jsonObject != null && jsonObject.ContainsKey("fileName"))
141-
{
142-
string documentPath = GetDocumentPath(jsonObject["fileName"]);
143-
if (!string.IsNullOrEmpty(documentPath))
144-
{
145-
jsonResult = System.IO.File.ReadAllText(documentPath);
146-
}
147-
else
148-
{
149-
return this.Content(jsonObject["document"] + " is not found");
150-
}
151-
}
152-
else
153-
{
154-
string extension = Path.GetExtension(jsonObject["importedData"]);
155-
if (extension != ".xfdf")
156-
{
157-
JsonResult = pdfviewer.ImportAnnotation(jsonObject);
158-
return Content(JsonConvert.SerializeObject(JsonResult));
159-
}
160-
else
161-
{
162-
string documentPath = GetDocumentPath(jsonObject["importedData"]);
163-
if (!string.IsNullOrEmpty(documentPath))
164-
{
165-
byte[] bytes = System.IO.File.ReadAllBytes(documentPath);
166-
jsonObject["importedData"] = Convert.ToBase64String(bytes);
167-
JsonResult = pdfviewer.ImportAnnotation(jsonObject);
168-
return Content(JsonConvert.SerializeObject(JsonResult));
169-
}
170-
else
171-
{
172-
return this.Content(jsonObject["document"] + " is not found");
173-
}
174-
}
175-
}
176-
return Content(jsonResult);
177-
}
178-
179-
[HttpPost]
180-
public IActionResult ExportFormFields([FromBody] Dictionary<string, string> jsonObject)
181-
182-
{
183-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
184-
string jsonResult = pdfviewer.ExportFormFields(jsonObject);
185-
return Content(jsonResult);
186-
}
187-
188-
189-
[HttpPost]
190-
public IActionResult ImportFormFields([FromBody] Dictionary<string, string> jsonObject)
191-
{
192-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
193-
jsonObject["data"] = GetDocumentPath(jsonObject["data"]);
194-
object jsonResult = pdfviewer.ImportFormFields(jsonObject);
195-
return Content(JsonConvert.SerializeObject(jsonResult));
196-
}
197-
198-
[HttpPost]
199-
//Post action for unloading and disposing the PDF document resources
200-
public IActionResult Unload([FromBody] Dictionary<string, string> jsonObject)
201-
{
202-
//Initialize the PDF Viewer object with memory cache object
203-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
204-
pdfviewer.ClearCache(jsonObject);
205-
return this.Content("Document cache is cleared");
206-
}
207-
208-
209-
[HttpPost]
210-
//Post action for downloading the PDF documents
211-
public IActionResult Download([FromBody] Dictionary<string, string> jsonObject)
212-
{
213-
//Initialize the PDF Viewer object with memory cache object
214-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
215-
string documentBase = pdfviewer.GetDocumentAsBase64(jsonObject);
216-
return Content(documentBase);
217-
}
218-
219-
[HttpPost]
220-
//Post action for printing the PDF documents
221-
public IActionResult PrintImages([FromBody] Dictionary<string, string> jsonObject)
222-
{
223-
//Initialize the PDF Viewer object with memory cache object
224-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
225-
object pageImage = pdfviewer.GetPrintImage(jsonObject);
226-
return Content(JsonConvert.SerializeObject(pageImage));
227-
}
228-
22928
[HttpGet]
23029
//Get action for obtaing the byte array of the PDF document
23130
public IActionResult GetPDFByte(string fileName)

0 commit comments

Comments
 (0)