Skip to content

Commit e526ae5

Browse files
942243: Updated to resourceUrl
1 parent 6659d81 commit e526ae5

File tree

3 files changed

+4
-292
lines changed

3 files changed

+4
-292
lines changed

How to/Download PDF based on confirmation in the toolbar click/React-Client/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function Default() {
108108
id="container"
109109
downloadStart={downloadStart}
110110
downloadEnd={downloadEnd}
111-
serviceUrl="https://localhost:5001/pdfviewer"
111+
resourceUrl="https://cdn.syncfusion.com/ej2/31.1.17/dist/ej2-pdfviewer-lib"
112112
documentPath="https://cdn.syncfusion.com/content/pdf/blazor-annotations.pdf"
113113
toolbarSettings={{
114114
showTooltip: true,

How to/Download PDF based on confirmation in the toolbar click/Web Service/ControllerPractice/ControllerPractice.csproj

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Google.Cloud.Storage.V1" Version="4.10.0" />
10-
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.13" />
11-
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="27.2.4" />
12-
<PackageReference Include="Azure.Storage.Blobs" Version="*" />
13-
<PackageReference Include="Syncfusion.EJ2.PdfViewer.AspNet.Core.Windows" Version="27.2.4" />
14-
<PackageReference Include="Syncfusion.Pdf.Imaging.Net.Core" Version="27.2.4" />
9+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.13" />
10+
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="*" />
11+
<PackageReference Include="Syncfusion.EJ2.PdfViewer.AspNet.Core" Version="*" />
1512
</ItemGroup>
1613
</Project>

How to/Download PDF based on confirmation in the toolbar click/Web Service/ControllerPractice/Controllers/PdfViewerController.cs

Lines changed: 0 additions & 285 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,12 @@
99
using System.IO;
1010
using System.Net;
1111
using System.Xml.Linq;
12-
using Azure.Storage.Blobs;
13-
using Azure.Storage.Blobs.Specialized;
1412
using Microsoft.Extensions.Logging;
1513
using Microsoft.Extensions.Configuration;
16-
using Google.Cloud.Storage.V1;
17-
using Google.Apis.Auth.OAuth2;
1814
using Syncfusion.Pdf.Graphics;
1915
using Syncfusion.Pdf.Security;
2016
using Syncfusion.Pdf;
2117
using Syncfusion.Pdf.Interactive;
22-
using Syncfusion.Pdf.Redaction;
2318

2419
namespace PdfViewerService2.Controllers
2520
{
@@ -40,79 +35,6 @@ public PdfViewerController(IHostingEnvironment hostingEnvironment, IMemoryCache
4035
_logger = logger;
4136
}
4237

43-
[HttpPost("Load")]
44-
/* [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]*/
45-
[Route("[controller]/Load")]
46-
        //Post action for loading the PDF documents
47-
        public IActionResult Load([FromBody] Dictionary<string, string> jsonObject)
48-
{
49-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
50-
MemoryStream stream = new MemoryStream();
51-
object jsonResult = new object();
52-
53-
if (jsonObject != null && jsonObject.ContainsKey("document"))
54-
{
55-
if (bool.Parse(jsonObject["isFileName"]))
56-
{
57-
string documentPath = GetDocumentPath(jsonObject["document"]);
58-
if (!string.IsNullOrEmpty(documentPath))
59-
{
60-
byte[] bytes = System.IO.File.ReadAllBytes(documentPath);
61-
stream = new MemoryStream(bytes);
62-
}
63-
else
64-
{
65-
string fileName = jsonObject["document"].Split(new string[] { "://" }, StringSplitOptions.None)[0];
66-
if (fileName == "http" || fileName == "https")
67-
{
68-
WebClient WebClient = new WebClient();
69-
byte[] pdfDoc = WebClient.DownloadData(jsonObject["document"]);
70-
stream = new MemoryStream(pdfDoc);
71-
}
72-
else
73-
{
74-
return this.Content(jsonObject["document"] + " is not found");
75-
}
76-
77-
}
78-
}
79-
else
80-
{
81-
byte[] bytes = Convert.FromBase64String(jsonObject["document"]);
82-
stream = new MemoryStream(bytes);
83-
}
84-
}
85-
86-
jsonResult = pdfviewer.Load(stream, jsonObject);
87-
return Content(JsonConvert.SerializeObject(jsonResult));
88-
}
89-
90-
[AcceptVerbs("Post")]
91-
[HttpPost("Bookmarks")]
92-
/* [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]*/
93-
[Route("[controller]/Bookmarks")]
94-
        //Post action for processing the bookmarks from the PDF documents
95-
        public IActionResult Bookmarks([FromBody] Dictionary<string, string> jsonObject)
96-
{
97-
            //Initialize the PDF Viewer object with memory cache object
98-
            PdfRenderer pdfviewer = new PdfRenderer(_cache);
99-
var jsonResult = pdfviewer.GetBookmarks(jsonObject);
100-
return Content(JsonConvert.SerializeObject(jsonResult));
101-
}
102-
103-
[AcceptVerbs("Post")]
104-
[HttpPost("RenderPdfPages")]
105-
/* [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]*/
106-
[Route("[controller]/RenderPdfPages")]
107-
        //Post action for processing the PDF documents 
108-
        public IActionResult RenderPdfPages([FromBody] Dictionary<string, string> jsonObject)
109-
{
110-
            //Initialize the PDF Viewer object with memory cache object
111-
            PdfRenderer pdfviewer = new PdfRenderer(_cache);
112-
object jsonResult = pdfviewer.GetPage(jsonObject);
113-
return Content(JsonConvert.SerializeObject(jsonResult));
114-
}
115-
11638
[AcceptVerbs("Post")]
11739
[HttpPost("CheckDownload")]
11840
/* [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]*/
@@ -123,212 +45,5 @@ public PdfViewerController(IHostingEnvironment hostingEnvironment, IMemoryCache
12345
var canDownload = jsonObject["canDownload"];
12446
return Content(canDownload);
12547
}
126-
127-
128-
[AcceptVerbs("Post")]
129-
[HttpPost("RenderPdfTexts")]
130-
/* [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]*/
131-
[Route("[controller]/RenderPdfTexts")]
132-
        //Post action for processing the PDF texts 
133-
        public IActionResult RenderPdfTexts([FromBody] Dictionary<string, string> jsonObject)
134-
{
135-
            //Initialize the PDF Viewer object with memory cache object
136-
            PdfRenderer pdfviewer = new PdfRenderer(_cache);
137-
object jsonResult = pdfviewer.GetDocumentText(jsonObject);
138-
// object jsonResult1 = pdfviewer.ReturnTaggedDetails();
139-
return Content(JsonConvert.SerializeObject(jsonResult));
140-
}
141-
142-
[AcceptVerbs("Post")]
143-
[HttpPost("RenderThumbnailImages")]
144-
/* [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]*/
145-
[Route("[controller]/RenderThumbnailImages")]
146-
        //Post action for rendering the thumbnail images
147-
        public IActionResult RenderThumbnailImages([FromBody] Dictionary<string, string> jsonObject)
148-
{
149-
            //Initialize the PDF Viewer object with memory cache object
150-
            PdfRenderer pdfviewer = new PdfRenderer(_cache);
151-
object result = pdfviewer.GetThumbnailImages(jsonObject);
152-
return Content(JsonConvert.SerializeObject(result));
153-
}
154-
155-
[AcceptVerbs("Post")]
156-
[HttpPost("RenderAnnotationComments")]
157-
/* [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]*/
158-
[Route("[controller]/RenderAnnotationComments")]
159-
        //Post action for rendering the annotations
160-
        public IActionResult RenderAnnotationComments([FromBody] Dictionary<string, string> jsonObject)
161-
{
162-
            //Initialize the PDF Viewer object with memory cache object
163-
            PdfRenderer pdfviewer = new PdfRenderer(_cache);
164-
object jsonResult = pdfviewer.GetAnnotationComments(jsonObject);
165-
return Content(JsonConvert.SerializeObject(jsonResult));
166-
}
167-
168-
[AcceptVerbs("Post")]
169-
[HttpPost("ExportAnnotations")]
170-
/* [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]*/
171-
[Route("[controller]/ExportAnnotations")]
172-
        //Post action to export annotations
173-
        public IActionResult ExportAnnotations([FromBody] Dictionary<string, string> jsonObject)
174-
{
175-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
176-
string jsonResult = pdfviewer.ExportAnnotation(jsonObject);
177-
178-
string base64String = jsonResult.Split(new string[] { "data:application/pdf;base64," }, StringSplitOptions.None)[1];
179-
if (base64String != null || base64String != string.Empty)
180-
{
181-
byte[] byteArray = Convert.FromBase64String(base64String);
182-
183-
//Saved the annotation in the server location
184-
System.IO.File.WriteAllBytes("Test1.json", byteArray);
185-
}
186-
return Content(jsonResult);
187-
188-
}
189-
[AcceptVerbs("Post")]
190-
[HttpPost("ImportAnnotations")]
191-
/* [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]*/
192-
[Route("[controller]/ImportAnnotations")]
193-
        //Post action to import annotations
194-
        public IActionResult ImportAnnotations([FromBody] Dictionary<string, string> jsonObject)
195-
{
196-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
197-
string jsonResult = string.Empty;
198-
object JsonResult;
199-
if (jsonObject != null && jsonObject.ContainsKey("fileName"))
200-
{
201-
string documentPath = GetDocumentPath(jsonObject["fileName"]);
202-
if (!string.IsNullOrEmpty(documentPath))
203-
{
204-
jsonResult = System.IO.File.ReadAllText(documentPath);
205-
}
206-
else
207-
{
208-
return this.Content(jsonObject["document"] + " is not found");
209-
}
210-
}
211-
else
212-
{
213-
string extension = Path.GetExtension(jsonObject["importedData"]);
214-
if (extension != ".xfdf")
215-
{
216-
JsonResult = pdfviewer.ImportAnnotation(jsonObject);
217-
return Content(JsonConvert.SerializeObject(JsonResult));
218-
}
219-
else
220-
{
221-
string documentPath = GetDocumentPath(jsonObject["importedData"]);
222-
if (!string.IsNullOrEmpty(documentPath))
223-
{
224-
byte[] bytes = System.IO.File.ReadAllBytes(documentPath);
225-
jsonObject["importedData"] = Convert.ToBase64String(bytes);
226-
JsonResult = pdfviewer.ImportAnnotation(jsonObject);
227-
return Content(JsonConvert.SerializeObject(JsonResult));
228-
}
229-
else
230-
{
231-
return this.Content(jsonObject["document"] + " is not found");
232-
}
233-
}
234-
}
235-
return Content(jsonResult);
236-
}
237-
238-
[AcceptVerbs("Post")]
239-
[HttpPost("ExportFormFields")]
240-
/* [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]*/
241-
[Route("[controller]/ExportFormFields")]
242-
        //Post action to export form fields
243-
        public IActionResult ExportFormFields([FromBody] Dictionary<string, string> jsonObject)
244-
245-
{
246-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
247-
string jsonResult = pdfviewer.ExportFormFields(jsonObject);
248-
return Content(jsonResult);
249-
}
250-
251-
252-
[AcceptVerbs("Post")]
253-
[HttpPost("ImportFormFields")]
254-
/* [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]*/
255-
[Route("[controller]/ImportFormFields")]
256-
        //Post action to import form fields
257-
        public IActionResult ImportFormFields([FromBody] Dictionary<string, string> jsonObject)
258-
{
259-
PdfRenderer pdfviewer = new PdfRenderer(_cache);
260-
// var jsonData = JsonConverter(jsonObject);
261-
object jsonResult = pdfviewer.ImportFormFields(jsonObject);
262-
return Content(JsonConvert.SerializeObject(jsonResult));
263-
}
264-
265-
[AcceptVerbs("Post")]
266-
[HttpPost("Unload")]
267-
/* [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]*/
268-
[Route("[controller]/Unload")]
269-
        //Post action for unloading and disposing the PDF document resources 
270-
        public IActionResult Unload([FromBody] Dictionary<string, string> jsonObject)
271-
{
272-
            //Initialize the PDF Viewer object with memory cache object
273-
            PdfRenderer pdfviewer = new PdfRenderer(_cache);
274-
pdfviewer.ClearCache(jsonObject);
275-
return this.Content("Document cache is cleared");
276-
}
277-
278-
[HttpPost("Download")]
279-
/* [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]*/
280-
[Route("[controller]/Download")]
281-
        //Post action for downloading the PDF documents
282-
        public IActionResult Download([FromBody] Dictionary<string, string> jsonObject)
283-
{
284-
            //Initialize the PDF Viewer object with memory cache object
285-
            PdfRenderer pdfviewer = new PdfRenderer(_cache);
286-
string documentBase = pdfviewer.GetDocumentAsBase64(jsonObject);
287-
return Content(documentBase);
288-
}
289-
290-
[HttpPost("PrintImages")]
291-
//[Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
292-
[Route("[controller]/PrintImages")]
293-
        //Post action for printing the PDF documents
294-
        public IActionResult PrintImages([FromBody] Dictionary<string, string> jsonObject)
295-
{
296-
            //Initialize the PDF Viewer object with memory cache object
297-
            PdfRenderer pdfviewer = new PdfRenderer(_cache);
298-
object pageImage = pdfviewer.GetPrintImage(jsonObject);
299-
return Content(JsonConvert.SerializeObject(pageImage));
300-
}
301-
302-
//Returns the PDF document path
303-
private string GetDocumentPath(string document)
304-
{
305-
string documentPath = String.Empty;
306-
if (!System.IO.File.Exists(document))
307-
{
308-
var path = _hostingEnvironment.ContentRootPath;
309-
if (System.IO.File.Exists(path + "/Data/" + document))
310-
documentPath = path + "/Data/" + document;
311-
}
312-
else
313-
{
314-
documentPath = document;
315-
}
316-
Console.WriteLine(documentPath);
317-
return documentPath;
318-
}
319-
320-
//GET api/values
321-
[HttpGet]
322-
public IEnumerable<string> Get()
323-
{
324-
return new string[] { "value1", "value2" };
325-
}
326-
327-
// GET api/values/5
328-
[HttpGet("{id}")]
329-
public string Get(int id)
330-
{
331-
return "value";
332-
}
33348
}
33449
}

0 commit comments

Comments
 (0)