File tree Expand file tree Collapse file tree 35 files changed +513
-0
lines changed
Expand file tree Collapse file tree 35 files changed +513
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ Microsoft Visual Studio Solution File, Format Version 12.00
3+ # Visual Studio Version 18
4+ VisualStudioVersion = 18.4.11626.88 stable
5+ MinimumVisualStudioVersion = 10.0.40219.1
6+ Project ("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" ) = "Async-variants-with-CancellationToken" , "Async-variants-with-CancellationToken\Async-variants-with-CancellationToken.csproj" , "{82A96117-C5A7-4EC5-9CEB-4090779E4858}"
7+ EndProject
8+ Global
9+ GlobalSection (SolutionConfigurationPlatforms ) = preSolution
10+ Debug| Any CPU = Debug| Any CPU
11+ Release| Any CPU = Release| Any CPU
12+ EndGlobalSection
13+ GlobalSection (ProjectConfigurationPlatforms ) = postSolution
14+ {82A96117-C5A7-4EC5-9CEB-4090779E4858} .Debug| Any CPU .ActiveCfg = Debug| Any CPU
15+ {82A96117-C5A7-4EC5-9CEB-4090779E4858} .Debug| Any CPU .Build .0 = Debug| Any CPU
16+ {82A96117-C5A7-4EC5-9CEB-4090779E4858} .Release| Any CPU .ActiveCfg = Release| Any CPU
17+ {82A96117-C5A7-4EC5-9CEB-4090779E4858} .Release| Any CPU .Build .0 = Release| Any CPU
18+ EndGlobalSection
19+ GlobalSection (SolutionProperties ) = preSolution
20+ HideSolutionNode = FALSE
21+ EndGlobalSection
22+ GlobalSection (ExtensibilityGlobals ) = postSolution
23+ SolutionGuid = {39F0108F-A812-4FAB-B030-F954DB31A357}
24+ EndGlobalSection
25+ EndGlobal
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+
3+ <PropertyGroup >
4+ <OutputType >Exe</OutputType >
5+ <TargetFramework >net8.0</TargetFramework >
6+ <RootNamespace >Async_variants_with_CancellationToken</RootNamespace >
7+ <ImplicitUsings >enable</ImplicitUsings >
8+ <Nullable >enable</Nullable >
9+ </PropertyGroup >
10+
11+ <ItemGroup >
12+ <PackageReference Include =" Syncfusion.SmartFormRecognizer.Net.Core" Version =" *" />
13+ </ItemGroup >
14+
15+ <ItemGroup >
16+ <None Update =" Data\Input.pdf" >
17+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
18+ </None >
19+ <None Update =" Output\.gitkeep" >
20+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
21+ </None >
22+ </ItemGroup >
23+
24+ </Project >
Original file line number Diff line number Diff line change 1+ using Syncfusion . SmartFormRecognizer ;
2+
3+ namespace AsyncVariantsWithCancellationToken
4+ {
5+ class Program
6+ {
7+ static async Task Main ( string [ ] args )
8+ {
9+ // Read the input PDF file as stream.
10+ using FileStream inputStream = new FileStream ( Path . GetFullPath ( @"Data\Input.pdf" ) , FileMode . Open , FileAccess . Read ) ;
11+ // Initialize the Form Recognizer.
12+ FormRecognizer recognizer = new FormRecognizer ( ) ;
13+ // Create a cancellation token that cancels after 5 seconds.
14+ using CancellationTokenSource cts = new CancellationTokenSource ( ) ;
15+ cts . CancelAfter ( TimeSpan . FromSeconds ( 5 ) ) ;
16+ CancellationToken token = cts . Token ;
17+
18+ // Recognize the form and get the output as PDF stream asynchronously.
19+ using Stream resultStream = await recognizer . RecognizeFormAsPdfStreamAsync ( inputStream , token ) ;
20+
21+ // Save the output PDF stream to file.
22+ using FileStream fileStream = File . Create ( Path . GetFullPath ( @"Output\Output.pdf" ) ) ;
23+ await resultStream . CopyToAsync ( fileStream , token ) ;
24+ }
25+ }
26+ }
Original file line number Diff line number Diff line change 1+
2+ Microsoft Visual Studio Solution File, Format Version 12.00
3+ # Visual Studio Version 18
4+ VisualStudioVersion = 18.4.11626.88 stable
5+ MinimumVisualStudioVersion = 10.0.40219.1
6+ Project ("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" ) = "Recognize-forms-using-JSON-async" , "Recognize-forms-using-JSON-async\Recognize-forms-using-JSON-async.csproj" , "{619DB425-3DFA-49A5-8E12-5627D9DED695}"
7+ EndProject
8+ Global
9+ GlobalSection (SolutionConfigurationPlatforms ) = preSolution
10+ Debug| Any CPU = Debug| Any CPU
11+ Release| Any CPU = Release| Any CPU
12+ EndGlobalSection
13+ GlobalSection (ProjectConfigurationPlatforms ) = postSolution
14+ {619DB425-3DFA-49A5-8E12-5627D9DED695} .Debug| Any CPU .ActiveCfg = Debug| Any CPU
15+ {619DB425-3DFA-49A5-8E12-5627D9DED695} .Debug| Any CPU .Build .0 = Debug| Any CPU
16+ {619DB425-3DFA-49A5-8E12-5627D9DED695} .Release| Any CPU .ActiveCfg = Release| Any CPU
17+ {619DB425-3DFA-49A5-8E12-5627D9DED695} .Release| Any CPU .Build .0 = Release| Any CPU
18+ EndGlobalSection
19+ GlobalSection (SolutionProperties ) = preSolution
20+ HideSolutionNode = FALSE
21+ EndGlobalSection
22+ GlobalSection (ExtensibilityGlobals ) = postSolution
23+ SolutionGuid = {1AEC4C1B-648F-49B0-A2E8-BE31F62FD02B}
24+ EndGlobalSection
25+ EndGlobal
Original file line number Diff line number Diff line change 1+ using System . IO ;
2+ using System . Threading . Tasks ;
3+ using Syncfusion . SmartFormRecognizer ;
4+
5+ namespace RecognizeFormsUsingJsonAsync
6+ {
7+ class Program
8+ {
9+ static async Task Main ( string [ ] args )
10+ {
11+ // Read the input PDF file as stream.
12+ using ( FileStream inputStream = new FileStream ( Path . GetFullPath ( @"Data\Input.pdf" ) , FileMode . Open , FileAccess . ReadWrite ) )
13+ {
14+ // Initialize the Form Recognizer.
15+ FormRecognizer smartFormRecognizer = new FormRecognizer ( ) ;
16+ // Recognize the form and get the output as JSON string asynchronously.
17+ string outputJson = await smartFormRecognizer . RecognizeFormAsJsonAsync ( inputStream ) ;
18+ // Save the output JSON to file.
19+ File . WriteAllText ( Path . GetFullPath ( @"Output\Output.json" ) , outputJson ) ;
20+ }
21+ }
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+
3+ <PropertyGroup >
4+ <OutputType >Exe</OutputType >
5+ <TargetFramework >net8.0</TargetFramework >
6+ <RootNamespace >Recognize_forms_using_JSON_async</RootNamespace >
7+ <ImplicitUsings >enable</ImplicitUsings >
8+ <Nullable >enable</Nullable >
9+ </PropertyGroup >
10+
11+ <ItemGroup >
12+ <PackageReference Include =" Syncfusion.SmartFormRecognizer.Net.Core" Version =" *" />
13+ </ItemGroup >
14+
15+ <ItemGroup >
16+ <None Update =" Data\Input.pdf" >
17+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
18+ </None >
19+ <None Update =" Output\.gitkeep" >
20+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
21+ </None >
22+ </ItemGroup >
23+
24+ </Project >
You can’t perform that action at this time.
0 commit comments