VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
Vintasoft.Imaging.FormsProcessing.FormRecognition Namespace / FormPageTemplate Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
FormPageTemplate Class
In This Topic
Contains information about form page template that is a group of all form field templates on an image.
Object Model
FormPageTemplate
Syntax
'Declaration

Public Class FormPageTemplate
   Inherits FormFieldTemplateGroup

public class FormPageTemplate : FormFieldTemplateGroup

Example

This C#/VB.NET code shows how to scan a document with blank form and create a form template.


''' <summary>
''' Scans the template document and creates page templates.
''' </summary>
''' <returns>
''' A <see cref="Vintasoft.Imaging.FormsProcessing.FormRecognition.FormTemplateManager"/> instance that contains
''' images of template document and the templates of document pages.
''' </returns>
Public Shared Function ScanAndCreatePageTemplates() As Vintasoft.Imaging.FormsProcessing.FormRecognition.FormTemplateManager
    Dim templateManager As New Vintasoft.Imaging.FormsProcessing.FormRecognition.FormTemplateManager()

    System.Console.WriteLine("Create TWAIN device manager...")
    Using deviceManager As New Vintasoft.Twain.DeviceManager()
        System.Console.WriteLine("Open TWAIN device manager...")
        deviceManager.Open()

        Dim device As Vintasoft.Twain.Device = deviceManager.DefaultDevice

        Dim acquireState As Vintasoft.Twain.AcquireModalState
        Do
            System.Console.WriteLine("Acquire image from scanner...")
            acquireState = device.AcquireModal()
            If acquireState = Vintasoft.Twain.AcquireModalState.ImageAcquired Then
                ' create VintasoftImage from acquired image
                Dim image As New Vintasoft.Imaging.VintasoftImage(device.AcquiredImage.GetAsVintasoftBitmap(), True)
                ' if image is not black-white
                If image.PixelFormat <> Vintasoft.Imaging.PixelFormat.BlackWhite Then
                    ' convert to black-white image (1-bpp pixel format)
                    image.ConvertToBlackWhite()
                End If

                ' add page to PDF document
                System.Console.WriteLine("Add page to template manager...")
                templateManager.AddPageTemplate(image, New Vintasoft.Imaging.FormsProcessing.FormRecognition.FormPageTemplate())

                ' dispose the acquired image
                device.AcquiredImage.Dispose()
            End If
        Loop While acquireState <> Vintasoft.Twain.AcquireModalState.None

        System.Console.WriteLine("Scan finished.")
        Return templateManager
    End Using
End Function


/// <summary>
/// Scans the template document and creates page templates.
/// </summary>
/// <returns>
/// A <see cref="Vintasoft.Imaging.FormsProcessing.FormRecognition.FormTemplateManager"/> instance that contains
/// images of template document and the templates of document pages.
/// </returns>
public static Vintasoft.Imaging.FormsProcessing.FormRecognition.FormTemplateManager ScanAndCreatePageTemplates()
{
    Vintasoft.Imaging.FormsProcessing.FormRecognition.FormTemplateManager templateManager = 
        new Vintasoft.Imaging.FormsProcessing.FormRecognition.FormTemplateManager();

    System.Console.WriteLine("Create TWAIN device manager...");
    using (Vintasoft.Twain.DeviceManager deviceManager = 
        new Vintasoft.Twain.DeviceManager())
    {
        System.Console.WriteLine("Open TWAIN device manager...");
        deviceManager.Open();

        Vintasoft.Twain.Device device = deviceManager.DefaultDevice;

        Vintasoft.Twain.AcquireModalState acquireState;
        do
        {
            System.Console.WriteLine("Acquire image from scanner...");
            acquireState = device.AcquireModal();
            if (acquireState == Vintasoft.Twain.AcquireModalState.ImageAcquired)
            {
                // create VintasoftImage from acquired image
                Vintasoft.Imaging.VintasoftImage image = 
                    new Vintasoft.Imaging.VintasoftImage(device.AcquiredImage.GetAsVintasoftBitmap(), true);
                // if image is not black-white
                if (image.PixelFormat != Vintasoft.Imaging.PixelFormat.BlackWhite)
                    // convert to black-white image (1-bpp pixel format)
                    image.ConvertToBlackWhite();

                // add page to PDF document
                System.Console.WriteLine("Add page to template manager...");
                templateManager.AddPageTemplate(image, 
                    new Vintasoft.Imaging.FormsProcessing.FormRecognition.FormPageTemplate());

                // dispose the acquired image
                device.AcquiredImage.Dispose();
            }
        }
        while (acquireState != Vintasoft.Twain.AcquireModalState.None);

        System.Console.WriteLine("Scan finished.");
        return templateManager;
    }
}

Inheritance Hierarchy

System.Object
   Vintasoft.Imaging.FormsProcessing.FormRecognition.FormFieldTemplate
      Vintasoft.Imaging.FormsProcessing.FormRecognition.FormFieldTemplateGroup
         Vintasoft.Imaging.FormsProcessing.FormRecognition.FormPageTemplate

Requirements

Target Platforms: .NET 10; .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

See Also