В этом разделе
Содержит информацию о шаблоне страницы формы, который представляет собой группу всех шаблонов полей формы на изображении.
Объектная модель
Синтаксис
Пример
Вот C#/VB.NET код, который демонстрирует, как сканировать документ с пустой формой и создать шаблон формы.
''' <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;
}
}
Иерархия наследования
Требования
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Смотрите также