ADRCreateTemplateFromFile Method (GdPictureImaging)
Creates a new Document Identifier Template from an image file.
public int ADRCreateTemplateFromFile(
string
)
public function ADRCreateTemplateFromFile(
: String
): Integer;
public function ADRCreateTemplateFromFile(
: String
) : int;
public: int ADRCreateTemplateFromFile(
string*
)
public:
int ADRCreateTemplateFromFile(
String^
)
'Declaration
Public Function ADRCreateTemplateFromFile( _
ByVal As String _
) As Integer
Parameters
- FilePath
- The path of the image from which the new template will be created. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
Return Value
The created template ID if success else, -1 if fail. check the GetStat() method to get the reason
on this result.
Creating two templates and renaming a file using the name of the template which has the best similar content.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a template "A".
int templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateA.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateA");
// Create a template "B".
templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateB.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateB");
// Identify the template which has the best similar content and change the file name accordingly.
templateID = gdpictureImaging.ADRGetCloserTemplateForFile("image.tif");
string templateName = gdpictureImaging.ADRGetTemplateTag(templateID);
File.Move("image.tif", templateName + "_image.tif");
// Deletes all document identifier templates.
int templateCount = gdpictureImaging.ADRGetTemplateCount();
for (int i = 1; i <= templateCount; i++)
{
templateID = gdpictureImaging.ADRGetTemplateID(1);
gdpictureImaging.ADRDeleteTemplate(templateID);
}
}