Skip to content

Commit 171214a

Browse files
SmartFormRecognizer
1 parent afb9287 commit 171214a

6 files changed

Lines changed: 552 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Assemblies required for SmartFormRecognizer| Syncfusion®
3+
description: Learn the assemblies required to use Syncfusion® SmartFormRecognizer library in various platforms and frameworks.
4+
platform: document-processing
5+
control: SmartFormRecognizer
6+
documentation: UG
7+
---
8+
9+
# Assemblies Required to work with SmartFormRecognizer
10+
The following assemblies need to be referenced in your application based on the platform.
11+
12+
<table>
13+
<tr>
14+
<thead>
15+
<th><b>Platform(s)</b></th>
16+
<th><b>Assembly</b></th>
17+
</thead>
18+
</tr>
19+
<tr>
20+
<td>
21+
Windows Forms, WPF and ASP.NET MVC5
22+
</td>
23+
<td>
24+
Syncfusion.SmartFormRecognizer.Base
25+
</td>
26+
</tr>
27+
<tr>
28+
<tr>
29+
<td rowspan="2">Blazor, .NET Core and .NET Platforms</td>
30+
<td>
31+
Syncfusion.SmartFormRecognizer.Portable
32+
</td>
33+
</tr>
34+
<tr>
35+
<td>
36+
Syncfusion.SmartFormRecognizer.NET
37+
</td>
38+
</tr>
39+
</table>
40+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: NuGet Packages for SmartFormRecognizer | Syncfusion&reg;
3+
description: Learn the NuGet packages required to use Syncfusion&reg; SmartFormRecognizer in various platforms and frameworks.
4+
platform: document-processing
5+
control: SmartFormRecognizer
6+
documentation: UG
7+
---
8+
9+
# NuGet Packages Required
10+
11+
To work with SmartFormRecognizer, the following NuGet packages need to be installed in your application.
12+
13+
<table>
14+
<tr>
15+
<thead>
16+
<th><b>Platform(s)</b></th>
17+
<th><b>NuGet Package</b></th>
18+
</thead>
19+
</tr>
20+
<tr>
21+
<td>
22+
Windows Forms
23+
</td>
24+
<td>
25+
{{'[Syncfusion.SmartFormRecognizer.WinForms.nupkg](https://www.nuget.org/packages/Syncfusion.SmartFormRecognizer.WinForms/)'| markdownify }}
26+
</td>
27+
</tr>
28+
<tr>
29+
<td>
30+
WPF
31+
</td>
32+
<td>
33+
{{'[Syncfusion.SmartFormRecognizer.WPF.nupkg](https://www.nuget.org/packages/Syncfusion.SmartFormRecognizer.WPF/)'| markdownify }}
34+
</td>
35+
</tr>
36+
<tr>
37+
<td rowspan="2">Blazor, .NET Core and .NET Platforms</td>
38+
<td>
39+
{{'[Syncfusion.SmartFormRecognizer.NET.nupkg](https://www.nuget.org/packages/Syncfusion.SmartFormRecognizer.Net/)'| markdownify }}
40+
</td>
41+
</tr>
42+
<tr>
43+
<td>
44+
{{'[Syncfusion.SmartFormRecognizer.Net.Core.nupkg](https://www.nuget.org/packages/Syncfusion.SmartFormRecognizer.Net.Core/)'| markdownify }}
45+
</td>
46+
</tr>
47+
<tr>
48+
<td>
49+
ASP.NET MVC5
50+
</td>
51+
<td>
52+
{{'[Syncfusion.SmartFormRecognizer.AspNet.MVC5.nupkg](https://www.nuget.org/packages/Syncfusion.SmartFormRecognizer.AspNet.Mvc5/)'| markdownify }}
53+
</td>
54+
</tr>
55+
</table>
56+
57+
N> The above mentioned NuGet packages are available in [nuget.org](https://www.nuget.org/).
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title:Smart Form Recognizer| Syncfusion&reg;
3+
description: Learn how to detects form data from PDFs and scanned images using Syncfusion&reg; Essential Studio&reg; SmartFormRecognizer.
4+
platform: document-processing
5+
control: SmartFormRecognizer
6+
documentation: UG
7+
keywords: Assemblies
8+
---
9+
10+
# Smart Form Recognizer
11+
12+
Smart Form Recognizer is a deterministic, on‑premise C# library for .NET designed to reliably detect and extract form data from PDFs and scanned images. Unlike AI/ML‑based approaches, this library uses visual layout heuristics—including lines, boxes, and circular markers—to identify form structures with high consistency and predictability. It supports extraction of common form controls such as text fields, checkboxes, radio buttons, and signature regions, producing clean, structured JSON that can be fed directly into review and workflow systems.
13+
14+
In addition to extraction, the library can also generate fillable PDFs, automatically placing form fields where they were detected, enabling instant integration into digital form processing pipelines.
15+
16+
Core Capabilities
17+
18+
*Form layout detection: Locate form regions using graphical heuristics (lines, boxes, circles) for consistent field discovery.
19+
20+
*Fillable PDF export: Create a PDF with detected form fields added so documents are immediately usable in form workflows.
21+
22+
*Page-level control: Process specific pages or page ranges for targeted extraction.
23+
24+
*Multi-format support: Works with PDF, JPEG, PNG and other common image formats.
25+
26+
*Confidence filtering: Per-field confidence scores with configurable thresholds to control output quality and drive review logic.
27+
28+
*Ready for .NET integration: Deterministic, onpremise library that outputs JSON and integrates into existing .NET pipelines and review UIs.
29+
30+
31+
<b>NuGet</b>
32+
33+
<table>
34+
<tr>
35+
<thead>
36+
<th><b>Platform(s)</b></th>
37+
<th><b>NuGet Package</b></th>
38+
</thead>
39+
</tr>
40+
<tr>
41+
<td>
42+
Windows Forms
43+
</td>
44+
<td>
45+
{{'[Syncfusion.SmartFormRecognizer.WinForms.nupkg](https://www.nuget.org/packages/Syncfusion.SmartFormRecognizer.WinForms/)'| markdownify }}
46+
</td>
47+
</tr>
48+
<tr>
49+
<td>
50+
WPF
51+
</td>
52+
<td>
53+
{{'[Syncfusion.SmartFormRecognizer.WPF.nupkg](https://www.nuget.org/packages/Syncfusion.SmartFormRecognizer.WPF/)'| markdownify }}
54+
</td>
55+
</tr>
56+
<tr>
57+
<td rowspan="2">Blazor, .NET Core and .NET Platforms</td>
58+
<td>
59+
{{'[Syncfusion.SmartFormRecognizer.NET.nupkg](https://www.nuget.org/packages/Syncfusion.SmartFormRecognizer.Net/)'| markdownify }}
60+
</td>
61+
</tr>
62+
<tr>
63+
<td>
64+
{{'[Syncfusion.SmartFormRecognizer.Net.Core.nupkg](https://www.nuget.org/packages/Syncfusion.SmartFormRecognizer.Net.Core/)'| markdownify }}
65+
</td>
66+
</tr>
67+
<tr>
68+
<td>
69+
ASP.NET MVC5
70+
</td>
71+
<td>
72+
{{'[Syncfusion.SmartFormRecognizer.AspNet.MVC5.nupkg](https://www.nuget.org/packages/Syncfusion.SmartFormRecognizer.AspNet.Mvc5/)'| markdownify }}
73+
</td>
74+
</tr>
75+
</table>
76+
77+
N> The above mentioned NuGet packages are available in [nuget.org](https://www.nuget.org/).
78+
79+
The following code snippet illustrates how to detects form data from PDFs using FormRecognizer method in SmartFormRecognizer.
80+
81+
{% tabs %}
82+
{% highlight c# tabtitle="C#" %}
83+
84+
//Initialize the Form Recognizer
85+
FormRecognizer smartFormRecognizer = new FormRecognizer();
86+
//Read the input PDF file as stream
87+
FileStream inputStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.ReadWrite);
88+
//Recognize the form and get the output as PDF stream
89+
Stream outputStream = smartFormRecognizer.RecognizeFormAsPdfStream(inputStream);
90+
//Save the output PDF stream to file
91+
using (FileStream fileStream = File.Create("Output.pdf"))
92+
{
93+
outputStream.Seek(0, SeekOrigin.Begin);
94+
outputStream.CopyTo(fileStream);
95+
}
96+
97+
{% endhighlight %}
98+
{% endtabs %}
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
---
2+
title: Working with Recognize methods in SmartFormRecognizer| Syncfusion&reg;
3+
description: Learn how to use Recognize methods in Syncfusion&reg; SmartFormRecognizer library.
4+
platform: document-processing
5+
control: SmartFormRecognizer
6+
documentation: UG
7+
---
8+
9+
# Recognize Forms
10+
11+
The `FormRecognizer` exposes several convenience methods to recognize forms from a `Stream` input. Each method accepts an input `Stream` (PDF or image) and returns recognized output either as a `PdfLoadedDocument`, a `Stream` containing PDF data, or as a JSON string.
12+
13+
Below each method signature you'll find a explanation and corrected example usage (both synchronous and asynchronous where applicable).
14+
15+
## Recognize forms using PdfLoadedDocument
16+
Using `PdfLoadedDocument` this operation analyzes the form content supplied through the inputStream whether it contains a PDF or an image and produces a fully enriched PdfLoadedDocument that includes recognized form elements such as checkboxes, radio buttons, textboxes, and signatures, according to the options defined in `FormRecognizeOptions`. This recognition process supports both execution patterns: the synchronous `RecognizeFormAsPdfDocument` method for immediate, blocking processing, and the asynchronous `RecognizeFormAsPdfDocumentAsync` method for non‑blocking, awaitable processing ideal for responsive UI applications or scalable server‑side workflows.
17+
18+
Example (synchronous):
19+
20+
{% tabs %}
21+
{% highlight c# tabtitle="C#" %}
22+
public void Button_Click(object sender, RoutedEventArgs e)
23+
{
24+
//Initialize the Form Recognizer
25+
FormRecognizer smartFormRecognizer = new FormRecognizer();
26+
//Read the input PDF file as stream
27+
FileStream inputStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.ReadWrite);
28+
//Recognize the form and get the output as PDF stream
29+
PdfLoadedDocument pdfLoadedDocument =recognizer.RecognizeFormAsPdfDocument(inputStream);
30+
//Save the loadeddocument
31+
pdfLoadedDocument.Save(Output.pdf);
32+
}
33+
{% endhighlight %}
34+
{% endtabs %}
35+
36+
37+
Example (asynchronous):
38+
39+
{% tabs %}
40+
{% highlight c# tabtitle="C#" %}
41+
public async void Button_Click(object sender, RoutedEventArgs e)
42+
{
43+
//Initialize the Form Recognizer
44+
FormRecognizer smartFormRecognizer = new FormRecognizer();
45+
//Read the input PDF file as stream
46+
FileStream inputStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.ReadWrite);
47+
//Recognize the form and get the output as PDF stream
48+
PdfLoadedDocument pdfLoadedDocument = await recognizer.RecognizeFormAsPdfDocumentAsync(inputStream);
49+
//Save the loadeddocument
50+
pdfLoadedDocument.Save(Output.pdf);
51+
}
52+
53+
{% endhighlight %}
54+
{% endtabs %}
55+
56+
57+
## Recognize forms using Stream
58+
Using `Stream`this operation processes the form content provided through the inputStream—whether it contains a PDF or an image—and returns the fully recognized PDF as a Stream.This functionality is available through both the synchronous `RecognizeFormAsPdfStream` method for immediate, blocking execution and the asynchronous `RecognizeFormAsPdfStreamAsync` method for non‑blocking, awaitable processing suitable for responsive UI applications, background services, and scalable server‑side workflows.
59+
60+
Example (synchronous):
61+
62+
{% tabs %}
63+
{% highlight c# tabtitle="C#" %}
64+
public void Button_Click(object sender, RoutedEventArgs e)
65+
{
66+
//Initialize the Form Recognizer
67+
FormRecognizer smartFormRecognizer = new FormRecognizer();
68+
//Read the input PDF file as stream
69+
FileStream inputStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.ReadWrite);
70+
//Recognize the form and get the output as PDF stream
71+
Stream outputStream = smartFormRecognizer.RecognizeFormAsPdfStream(inputStream);
72+
//Save the output PDF stream to file
73+
using (FileStream fileStream = File.Create("Output.pdf"))
74+
{
75+
outputStream.Seek(0, SeekOrigin.Begin);
76+
outputStream.CopyTo(fileStream);
77+
}
78+
}
79+
{% endhighlight %}
80+
{% endtabs %}
81+
82+
83+
Example (asynchronous):
84+
85+
{% tabs %}
86+
{% highlight c# tabtitle="C#" %}
87+
public async void Button_Click(object sender, RoutedEventArgs e)
88+
{
89+
//Initialize the Form Recognizer
90+
FormRecognizer smartFormRecognizer = new FormRecognizer();
91+
//Read the input PDF file as stream
92+
FileStream inputStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.ReadWrite);
93+
//Recognize the form and get the output as PDF stream
94+
Stream outputStream = await smartFormRecognizer.RecognizeFormAsPdfStreamAsync(inputStream);
95+
//Save the output PDF stream to file
96+
using (FileStream fileStream = File.Create("Output.pdf"))
97+
{
98+
outputStream.Seek(0, SeekOrigin.Begin);
99+
outputStream.CopyTo(fileStream);
100+
}
101+
}
102+
103+
{% endhighlight %}
104+
{% endtabs %}
105+
106+
## Recognize forms using JSON
107+
108+
Using `JSON`this operation recognizes the form contained in the inputStream whether the source document is a PDF or an image—and returns the complete recognition output serialized as a JSON string. This functionality is accessible through both the synchronous `RecognizeFormAsJson` method, which performs immediate, blocking processing, and the asynchronous `RecognizeFormAsJsonAsync` method, which provides non‑blocking, awaitable execution suitable for UI applications, background workers, and scalable cloud or server‑side workflows.
109+
110+
Example (synchronous):
111+
112+
{% tabs %}
113+
{% highlight c# tabtitle="C#" %}
114+
public void Button_Click(object sender, RoutedEventArgs e)
115+
{
116+
//Initialize the Form Recognizer
117+
FormRecognizer smartFormRecognizer = new FormRecognizer();
118+
//Read the input PDF file as stream
119+
FileStream inputStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.ReadWrite);
120+
//Recognize the form and get the output as PDF stream
121+
String outputJson = smartFormRecognizer.RecognizeFormAsJson(inputStream);
122+
//Save the outputJson
123+
File.Create("D:\\result.json").Close();
124+
File.WriteAllText("D:\\result.json", outputJson);
125+
}
126+
{% endhighlight %}
127+
{% endtabs %}
128+
129+
130+
Example (asynchronous):
131+
132+
{% tabs %}
133+
{% highlight c# tabtitle="C#" %}
134+
public async void Button_Click(object sender, RoutedEventArgs e)
135+
{
136+
//Initialize the Form Recognizer
137+
FormRecognizer smartFormRecognizer = new FormRecognizer();
138+
//Read the input PDF file as stream
139+
FileStream inputStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.ReadWrite);
140+
//Recognize the form and get the output as PDF stream
141+
String outputJson = await smartFormRecognizer.RecognizeFormAsJsonAsync(inputStream);
142+
//Save the outputJson
143+
File.Create("D:\\result.json").Close();
144+
File.WriteAllText("D:\\result.json", outputJson);
145+
146+
}
147+
148+
{% endhighlight %}
149+
{% endtabs %}
150+
151+
## Async variants with CancellationToken
152+
153+
The async overloads accept an optional `CancellationToken` to cancel long-running operations:
154+
155+
- `Task<PdfLoadedDocument> RecognizeFormAsPdfDocumentAsync(Stream inputStream, CancellationToken cancellationToken = default)`
156+
- `Task<Stream> RecognizeFormAsPdfStreamAsync(Stream inputStream, CancellationToken cancellationToken = default)`
157+
- `Task<string> RecognizeFormAsJsonAsync(Stream inputStream, CancellationToken cancellationToken = default)`
158+
159+
Example with cancellation token (PDF stream):
160+
161+
```csharp
162+
public async Task RecognizeWithCancellationAsync(CancellationToken token)
163+
{
164+
FormRecognizer recognizer = new FormRecognizer();
165+
166+
using FileStream inputStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read);
167+
168+
using Stream resultStream = await recognizer.RecognizeFormAsPdfStreamAsync(inputStream, token);
169+
170+
using FileStream fileStream = File.Create("Output.pdf");
171+
await resultStream.CopyToAsync(fileStream, token);
172+
}
173+
```
174+
175+
Notes:
176+
- Always forward cancellation tokens to I/O methods when available.
177+
178+
---
179+
180+
## Common corrections and best practices shown in the examples
181+
182+
- Use `using` (or `await using` for IAsyncDisposable) to ensure streams are disposed.
183+
- Use `FileAccess.Read` when only reading input files.
184+
- Do not reuse mismatched variable names (e.g., `smartFormRecognizer` vs `recognizer`) — pick one consistent name.
185+
- Prefer `async`/`await` in UI event handlers but avoid `async void` except for top-level event handlers; prefer `async Task` where possible for testability.
186+
187+
---
188+
189+
If you want, I can also:
190+
- Add a short snippet showing how to handle `FormRecognizeOptions` with these calls.
191+
- Add a unit test or a small console app sample demonstrating each method.

0 commit comments

Comments
 (0)