Skip to content

Commit 0efeb42

Browse files
Added the changes
1 parent 3c8435e commit 0efeb42

6 files changed

Lines changed: 97 additions & 66 deletions

File tree

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 18
4-
VisualStudioVersion = 18.4.11626.88 stable
4+
VisualStudioVersion = 18.5.11709.299 stable
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Recognize_Forms", "Recognize_Forms\Recognize_Forms.csproj", "{A641CDDE-5818-4343-B668-635B41874BE8}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Recognize_Forms", "Recognize_Forms\Recognize_Forms.csproj", "{4AE5A73B-6F06-44B7-BBCF-4624FE313034}"
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-
{A641CDDE-5818-4343-B668-635B41874BE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{A641CDDE-5818-4343-B668-635B41874BE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{A641CDDE-5818-4343-B668-635B41874BE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{A641CDDE-5818-4343-B668-635B41874BE8}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{4AE5A73B-6F06-44B7-BBCF-4624FE313034}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4AE5A73B-6F06-44B7-BBCF-4624FE313034}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4AE5A73B-6F06-44B7-BBCF-4624FE313034}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{4AE5A73B-6F06-44B7-BBCF-4624FE313034}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {034B5367-0C75-49C4-88E8-84A410FD01A3}
23+
SolutionGuid = {BCA4FBF6-FB92-498E-A599-D1C18B479B61}
2424
EndGlobalSection
2525
EndGlobal
Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,65 @@
11
using Microsoft.AspNetCore.Mvc;
22
using Recognize_Forms.Models;
3-
using Syncfusion.SmartFormRecognizer;
43
using System.Diagnostics;
4+
using Syncfusion.SmartFormRecognizer;
55
using System.Text;
66

77
namespace Recognize_Forms.Controllers
88
{
9-
public class HomeController : Controller
10-
{
11-
private readonly ILogger<HomeController> _logger;
12-
13-
public HomeController(ILogger<HomeController> logger)
14-
{
15-
_logger = logger;
16-
}
17-
18-
public IActionResult Index()
19-
{
20-
return View();
21-
}
22-
23-
public IActionResult Privacy()
24-
{
25-
return View();
26-
}
27-
28-
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
29-
public IActionResult Error()
30-
{
31-
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
32-
}
33-
public IActionResult ExtractForms()
34-
{
35-
// Read the input PDF file as stream.
36-
using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data\Input.pdf"), FileMode.Open, FileAccess.ReadWrite))
37-
{
38-
// Initialize the Form Recognizer.
39-
FormRecognizer smartFormRecognizer = new FormRecognizer();
40-
// Recognize the form and get the output as JSON string.
41-
string outputJson = smartFormRecognizer.RecognizeFormAsJson(inputStream);
42-
// Convert JSON string into a MemoryStream for download.
43-
MemoryStream outputStream = new MemoryStream(Encoding.UTF8.GetBytes(outputJson));
44-
// Reset stream position.
45-
outputStream.Position = 0;
46-
// Return JSON file as download in browser.
47-
FileStreamResult fileStreamResult = new FileStreamResult(outputStream, "application/json");
48-
fileStreamResult.FileDownloadName = "Output.json";
49-
return fileStreamResult;
50-
}
51-
}
52-
}
9+
public class HomeController : Controller
10+
{
11+
private readonly ILogger<HomeController> _logger;
12+
13+
public HomeController(ILogger<HomeController> logger)
14+
{
15+
_logger = logger;
16+
}
17+
18+
public IActionResult Index()
19+
{
20+
return View();
21+
}
22+
23+
public IActionResult Privacy()
24+
{
25+
return View();
26+
}
27+
28+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
29+
public IActionResult Error()
30+
{
31+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
32+
}
33+
34+
public IActionResult ExtractForms()
35+
36+
{
37+
38+
// Read the input PDF file as stream.
39+
using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data\Input.pdf"), FileMode.Open, FileAccess.ReadWrite))
40+
{
41+
42+
// Initialize the Form Recognizer.        
43+
FormRecognizer smartFormRecognizer = new FormRecognizer();
44+
45+
// Recognize the form and get the output as JSON string.
46+
string outputJson = smartFormRecognizer.RecognizeFormAsJson(inputStream);
47+
48+
// Convert JSON string into a MemoryStream for download.        
49+
MemoryStream outputStream = new MemoryStream(Encoding.UTF8.GetBytes(outputJson));
50+
51+
// Reset stream position.
52+
outputStream.Position = 0;
53+
54+
// Return JSON file as download in browser.        
55+
FileStreamResult fileStreamResult = new FileStreamResult(outputStream, "application/json");
56+
57+
fileStreamResult.FileDownloadName = "Output.json";
58+
59+
return fileStreamResult;
60+
61+
}
62+
63+
}
64+
}
5365
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
namespace Recognize_Forms.Models
22
{
3-
public class ErrorViewModel
4-
{
5-
public string? RequestId { get; set; }
3+
public class ErrorViewModel
4+
{
5+
public string? RequestId { get; set; }
66

7-
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
8-
}
7+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
8+
}
99
}

Data-Extraction/Getting-Started/ASP.NETCore/Recognize_Forms/Recognize_Forms/Program.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
// Configure the HTTP request pipeline.
99
if (!app.Environment.IsDevelopment())
1010
{
11-
app.UseExceptionHandler("/Home/Error");
12-
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
13-
app.UseHsts();
11+
app.UseExceptionHandler("/Home/Error");
12+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
13+
app.UseHsts();
1414
}
1515

1616
app.UseHttpsRedirection();
@@ -21,7 +21,7 @@
2121
app.UseAuthorization();
2222

2323
app.MapControllerRoute(
24-
name: "default",
25-
pattern: "{controller=Home}/{action=Index}/{id?}");
24+
name: "default",
25+
pattern: "{controller=Home}/{action=Index}/{id?}");
2626

2727
app.Run();

Data-Extraction/Getting-Started/ASP.NETCore/Recognize_Forms/Recognize_Forms/Properties/launchSettings.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
"windowsAuthentication": false,
55
"anonymousAuthentication": true,
66
"iisExpress": {
7-
"applicationUrl": "http://localhost:13035",
8-
"sslPort": 44361
7+
"applicationUrl": "http://localhost:11943",
8+
"sslPort": 44373
99
}
1010
},
1111
"profiles": {
1212
"http": {
1313
"commandName": "Project",
1414
"dotnetRunMessages": true,
1515
"launchBrowser": true,
16-
"applicationUrl": "http://localhost:5134",
16+
"applicationUrl": "http://localhost:5172",
1717
"environmentVariables": {
1818
"ASPNETCORE_ENVIRONMENT": "Development"
1919
}
@@ -22,7 +22,7 @@
2222
"commandName": "Project",
2323
"dotnetRunMessages": true,
2424
"launchBrowser": true,
25-
"applicationUrl": "https://localhost:7076;http://localhost:5134",
25+
"applicationUrl": "https://localhost:7044;http://localhost:5172",
2626
"environmentVariables": {
2727
"ASPNETCORE_ENVIRONMENT": "Development"
2828
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.SmartFormRecognizer.Net.Core" Version="*" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<None Update="Data\Input.pdf">
15+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
16+
</None>
17+
</ItemGroup>
18+
19+
</Project>

0 commit comments

Comments
 (0)