Skip to content

Commit 9e573d8

Browse files
379783: Updated to standalone mode
1 parent 2a0bdc4 commit 9e573d8

File tree

12 files changed

+62
-310
lines changed

12 files changed

+62
-310
lines changed
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
4-
VisualStudioVersion = 17.10.34607.79
4+
VisualStudioVersion = 17.12.35527.113 d17.12
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenFromBase64", "OpenFromBase64\OpenFromBase64.csproj", "{0C2D9630-9232-4CFA-8D09-9BBD5D156461}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenFromBase64", "OpenFromBase64\OpenFromBase64.csproj", "{634CC05D-AC9E-4113-9E23-3DB7B49776A8}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{0C2D9630-9232-4CFA-8D09-9BBD5D156461}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{0C2D9630-9232-4CFA-8D09-9BBD5D156461}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{0C2D9630-9232-4CFA-8D09-9BBD5D156461}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{0C2D9630-9232-4CFA-8D09-9BBD5D156461}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{634CC05D-AC9E-4113-9E23-3DB7B49776A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{634CC05D-AC9E-4113-9E23-3DB7B49776A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{634CC05D-AC9E-4113-9E23-3DB7B49776A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{634CC05D-AC9E-4113-9E23-3DB7B49776A8}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
22-
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {31245B35-82FC-4C3B-A888-4730D0AD8EE0}
24-
EndGlobalSection
2522
EndGlobal

How to/Open From Base64/OpenFromBase64/OpenFromBase64/EnableLocalStorage.csproj.user

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="*" />
11-
<PackageReference Include="Syncfusion.EJ2.PdfViewer.AspNet.Core" Version="*" />
10+
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="*" />
1211
</ItemGroup>
1312

1413
</Project>

How to/Open From Base64/OpenFromBase64/OpenFromBase64/OpenFromBase64.csproj.user

Lines changed: 0 additions & 6 deletions
This file was deleted.

How to/Open From Base64/OpenFromBase64/OpenFromBase64/Pages/Error.cshtml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
using System.Diagnostics;
12
using Microsoft.AspNetCore.Mvc;
23
using Microsoft.AspNetCore.Mvc.RazorPages;
3-
using System.Diagnostics;
44

5-
namespace PDFViewerSample.Pages
5+
namespace OpenFromBase64.Pages
66
{
77
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
88
[IgnoreAntiforgeryToken]

How to/Open From Base64/OpenFromBase64/OpenFromBase64/Pages/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<div class="text-center">
88
<button type="button" id="loadButton">Load PDF from Base64</button>
9-
<ejs-pdfviewer id="pdfviewer" style="height:600px" resourceUrl="https://cdn.syncfusion.com/ej2/28.1.33/dist/ej2-pdfviewer-lib" documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf">
9+
<ejs-pdfviewer id="pdfviewer" style="height:600px" documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf">
1010
</ejs-pdfviewer>
1111
</div>
1212

Lines changed: 7 additions & 253 deletions
Original file line numberDiff line numberDiff line change
@@ -1,266 +1,20 @@
1-
using Microsoft.AspNetCore.Mvc;
2-
using Microsoft.Extensions.Caching.Memory;
3-
using Syncfusion.EJ2.PdfViewer;
4-
using Newtonsoft.Json;
1+
using Microsoft.AspNetCore.Mvc;
52
using Microsoft.AspNetCore.Mvc.RazorPages;
6-
using System.Reflection;
7-
using System.Net;
83

9-
namespace PDFViewerSample.Pages
4+
namespace OpenFromBase64.Pages
105
{
11-
[IgnoreAntiforgeryToken(Order = 1001)]
126
public class IndexModel : PageModel
137
{
8+
private readonly ILogger<IndexModel> _logger;
149

15-
private readonly Microsoft.AspNetCore.Hosting.IHostingEnvironment _hostingEnvironment;
16-
private IMemoryCache _cache;
17-
18-
public IndexModel(Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment, IMemoryCache cache)
19-
{
20-
_hostingEnvironment = hostingEnvironment;
21-
_cache = cache;
22-
}
23-
24-
public IActionResult OnPostLoad([FromBody] jsonObjects responseData)
25-
{
26-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
27-
MemoryStream stream = new MemoryStream();
28-
var jsonObject = JsonConverterstring(responseData);
29-
object jsonResult = new object();
30-
if (jsonObject != null && jsonObject.ContainsKey("document"))
31-
{
32-
if (bool.Parse(jsonObject["isFileName"]))
33-
{
34-
string documentPath = GetDocumentPath(jsonObject["document"]);
35-
if (!string.IsNullOrEmpty(documentPath))
36-
{
37-
byte[] bytes = System.IO.File.ReadAllBytes(documentPath);
38-
stream = new MemoryStream(bytes);
39-
}
40-
else
41-
{
42-
string fileName = jsonObject["document"].Split(new string[] { "://" }, StringSplitOptions.None)[0];
43-
if (fileName == "http" || fileName == "https")
44-
{
45-
WebClient WebClient = new WebClient();
46-
byte[] pdfDoc = WebClient.DownloadData(jsonObject["document"]);
47-
stream = new MemoryStream(pdfDoc);
48-
}
49-
else
50-
return this.Content(jsonObject["document"] + " is not found");
51-
}
52-
}
53-
else
54-
{
55-
byte[] bytes = Convert.FromBase64String(jsonObject["document"]);
56-
stream = new MemoryStream(bytes);
57-
}
58-
}
59-
jsonResult = pdfviewer.Load(stream, jsonObject);
60-
return Content(JsonConvert.SerializeObject(jsonResult));
61-
}
62-
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-
75-
//Post action for processing the PDF documents.
76-
public IActionResult OnPostRenderPdfPages([FromBody] jsonObjects responseData)
77-
{
78-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
79-
var jsonObject = JsonConverterstring(responseData);
80-
object jsonResult = pdfviewer.GetPage(jsonObject);
81-
return Content(JsonConvert.SerializeObject(jsonResult));
82-
}
83-
84-
//Post action for unloading and disposing the PDF document resources
85-
public IActionResult OnPostUnload([FromBody] jsonObjects responseData)
86-
{
87-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
88-
var jsonObject = JsonConverterstring(responseData);
89-
pdfviewer.ClearCache(jsonObject);
90-
return this.Content("Document cache is cleared");
91-
}
92-
93-
//Post action for rendering the ThumbnailImages
94-
public IActionResult OnPostRenderThumbnailImages([FromBody] jsonObjects responseData)
95-
{
96-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
97-
var jsonObject = JsonConverterstring(responseData);
98-
object result = pdfviewer.GetThumbnailImages(jsonObject);
99-
return Content(JsonConvert.SerializeObject(result));
100-
}
101-
102-
//Post action for processing the bookmarks from the PDF documents
103-
public IActionResult OnPostBookmarks([FromBody] jsonObjects responseData)
104-
{
105-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
106-
var jsonObject = JsonConverterstring(responseData);
107-
object jsonResult = pdfviewer.GetBookmarks(jsonObject);
108-
return Content(JsonConvert.SerializeObject(jsonResult));
109-
}
110-
111-
//Post action for rendering the annotation comments
112-
public IActionResult OnPostRenderAnnotationComments([FromBody] jsonObjects responseData)
113-
{
114-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
115-
var jsonObject = JsonConverterstring(responseData);
116-
object jsonResult = pdfviewer.GetAnnotationComments(jsonObject);
117-
return Content(JsonConvert.SerializeObject(jsonResult));
118-
}
119-
120-
//Post action for exporting the annotations
121-
public IActionResult OnPostExportAnnotations([FromBody] jsonObjects responseData)
122-
{
123-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
124-
var jsonObject = JsonConverterstring(responseData);
125-
string jsonResult = pdfviewer.ExportAnnotation(jsonObject);
126-
return Content(jsonResult);
127-
}
128-
129-
//Post action for importing the annotations
130-
public IActionResult OnPostImportAnnotations([FromBody] jsonObjects responseData)
10+
public IndexModel(ILogger<IndexModel> logger)
13111
{
132-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
133-
var jsonObject = JsonConverterstring(responseData);
134-
string jsonResult = string.Empty;
135-
object JsonResult;
136-
if (jsonObject != null && jsonObject.ContainsKey("fileName"))
137-
{
138-
string documentPath = GetDocumentPath(jsonObject["fileName"]);
139-
if (!string.IsNullOrEmpty(documentPath))
140-
{
141-
jsonResult = System.IO.File.ReadAllText(documentPath);
142-
}
143-
else
144-
{
145-
return this.Content(jsonObject["document"] + " is not found");
146-
}
147-
}
148-
else
149-
{
150-
string extension = Path.GetExtension(jsonObject["importedData"]);
151-
if (extension != ".xfdf")
152-
{
153-
JsonResult = pdfviewer.ImportAnnotation(jsonObject);
154-
return Content(JsonConvert.SerializeObject(JsonResult));
155-
}
156-
else
157-
{
158-
string documentPath = GetDocumentPath(jsonObject["importedData"]);
159-
if (!string.IsNullOrEmpty(documentPath))
160-
{
161-
byte[] bytes = System.IO.File.ReadAllBytes(documentPath);
162-
jsonObject["importedData"] = Convert.ToBase64String(bytes);
163-
JsonResult = pdfviewer.ImportAnnotation(jsonObject);
164-
return Content(JsonConvert.SerializeObject(JsonResult));
165-
}
166-
else
167-
{
168-
return this.Content(jsonObject["document"] + " is not found");
169-
}
170-
}
171-
}
172-
return Content(jsonResult);
12+
_logger = logger;
17313
}
17414

175-
//Post action for downloading the PDF documents
176-
public IActionResult OnPostDownload([FromBody] jsonObjects responseData)
15+
public void OnGet()
17716
{
178-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
179-
var jsonObject = JsonConverterstring(responseData);
180-
string documentBase = pdfviewer.GetDocumentAsBase64(jsonObject);
181-
return Content(documentBase);
182-
}
18317

184-
//Post action for printing the PDF documents
185-
public IActionResult OnPostPrintImages([FromBody] jsonObjects responseData)
186-
{
187-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
188-
var jsonObject = JsonConverterstring(responseData);
189-
object pageImage = pdfviewer.GetPrintImage(jsonObject);
190-
return Content(JsonConvert.SerializeObject(pageImage));
19118
}
192-
193-
//Gets the path of the PDF document
194-
private string GetDocumentPath(string document)
195-
{
196-
string documentPath = string.Empty;
197-
if (!System.IO.File.Exists(document))
198-
{
199-
string basePath = _hostingEnvironment.WebRootPath;
200-
string dataPath = string.Empty;
201-
dataPath = basePath + "/";
202-
if (System.IO.File.Exists(dataPath + (document)))
203-
documentPath = dataPath + document;
204-
}
205-
else
206-
{
207-
documentPath = document;
208-
}
209-
return documentPath;
210-
}
211-
}
212-
213-
public class jsonObjects
214-
{
215-
public string document { get; set; }
216-
public string password { get; set; }
217-
public string zoomFactor { get; set; }
218-
public string isFileName { get; set; }
219-
public string xCoordinate { get; set; }
220-
public string yCoordinate { get; set; }
221-
public string pageNumber { get; set; }
222-
public string documentId { get; set; }
223-
public string hashId { get; set; }
224-
public string sizeX { get; set; }
225-
public string sizeY { get; set; }
226-
public string startPage { get; set; }
227-
public string endPage { get; set; }
228-
public string stampAnnotations { get; set; }
229-
public string textMarkupAnnotations { get; set; }
230-
public string stickyNotesAnnotation { get; set; }
231-
public string shapeAnnotations { get; set; }
232-
public string measureShapeAnnotations { get; set; }
233-
public string action { get; set; }
234-
public string pageStartIndex { get; set; }
235-
public string pageEndIndex { get; set; }
236-
public string fileName { get; set; }
237-
public string elementId { get; set; }
238-
public string pdfAnnotation { get; set; }
239-
public string importPageList { get; set; }
240-
public string uniqueId { get; set; }
241-
public string data { get; set; }
242-
public string viewPortWidth { get; set; }
243-
public string viewPortHeight { get; set; }
244-
public string tilecount { get; set; }
245-
public bool isCompletePageSizeNotReceived { get; set; }
246-
public string freeTextAnnotation { get; set; }
247-
public string signatureData { get; set; }
248-
public string fieldsData { get; set; }
249-
public string formDesigner { get; set; }
250-
public string inkSignatureData { get; set; }
251-
public bool hideEmptyDigitalSignatureFields { get; set; }
252-
public bool showDigitalSignatureAppearance { get; set; }
253-
public bool digitalSignaturePresent { get; set; }
254-
public string tileXCount { get; set; }
255-
public string tileYCount { get; set; }
256-
public string digitalSignaturePageList { get; set; }
257-
public string annotationCollection { get; set; }
258-
public string annotationsPageList { get; set; }
259-
public string formFieldsPageList { get; set; }
260-
public bool isAnnotationsExist { get; set; }
261-
public bool isFormFieldAnnotationsExist { get; set; }
262-
public string documentLiveCount { get; set; }
263-
public string annotationDataFormat { get; set; }
264-
public string importedData { get; set; }
26519
}
266-
}
20+
}

How to/Open From Base64/OpenFromBase64/OpenFromBase64/Pages/Privacy.cshtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Microsoft.AspNetCore.Mvc;
22
using Microsoft.AspNetCore.Mvc.RazorPages;
33

4-
namespace PDFViewerSample.Pages
4+
namespace OpenFromBase64.Pages
55
{
66
public class PrivacyModel : PageModel
77
{

0 commit comments

Comments
 (0)