ClearImage .NET API
Edit(String,EditPageEventHandler,String,ImageFileFormat,Boolean) Method
Example 





Inlite.ClearImageNet Namespace > ImageEditor Class > Edit Method : Edit(String,EditPageEventHandler,String,ImageFileFormat,Boolean) Method
Input file name.
Input pages processing handler.
Output file name.
Output file format.
If true, overwrite existing file. Otherwise append to the file.
Edit pages in an image file through event handler
Syntax
'Declaration
 
Public Overloads Function Edit( _
   ByVal inputFile As System.String, _
   ByVal handler As ImageEditor.EditPageEventHandler, _
   ByVal outputFile As System.String, _
   ByVal format As ImageFileFormat, _
   ByVal overwrite As System.Boolean _
) As System.Boolean
'Usage
 
Dim instance As ImageEditor
Dim inputFile As System.String
Dim handler As ImageEditor.EditPageEventHandler
Dim outputFile As System.String
Dim format As ImageFileFormat
Dim overwrite As System.Boolean
Dim value As System.Boolean
 
value = instance.Edit(inputFile, handler, outputFile, format, overwrite)
public System.bool Edit( 
   System.string inputFile,
   ImageEditor.EditPageEventHandler handler,
   System.string outputFile,
   ImageFileFormat format,
   System.bool overwrite
)
public function Edit( 
    inputFile: System.String;
    handler: ImageEditor.EditPageEventHandler;
    outputFile: System.String;
    format: ImageFileFormat;
    overwrite: System.Boolean
): System.Boolean; 
public function Edit( 
   inputFile : System.String,
   handler : ImageEditor.EditPageEventHandler,
   outputFile : System.String,
   format : ImageFileFormat,
   overwrite : System.boolean
) : System.boolean;
public:
System.bool Edit( 
   System.String^ inputFile,
   ImageEditor.EditPageEventHandler^ handler,
   System.String^ outputFile,
   ImageFileFormat format,
   System.bool overwrite
) 

Parameters

inputFile
Input file name.
handler
Input pages processing handler.
outputFile
Output file name.
format
Output file format.
overwrite
If true, overwrite existing file. Otherwise append to the file.
Remarks

This method processes a single- or multi-page image file.  Image processing is performed by the method pointed by the handler parameter.  If handler is null no image processing is done, and method is used only for format conversion.  To remove specific inputFile pages from outputFile handler should set EditPageEventArgs.skipPage to true,

Each input page is written to outputFile using format parameter. 
If format = inputFileFormat output format is the same as the format of the inputFile
If format = outputFileFormat output format and outputFile exists and overwrite=false than pages are appended to outputFile
If format = outputFileFormat output format and outputFile does not exist then the format of the inputFile  is used.

The multi-page output file can be created only using PDF and TIFF formats   Set format=pdf or format=tiff respectively. Image compression controlled by IO.compressionBitonalEx and IO.compressionColorEx properties.

IO.jpegQuality controls compression when format=jpeg or IO.compressionColorEx=jpeg and output format is PDF or TIFF

Example
private static void EditPageEventHandler(object sender, EditPageEventArgs e)
{
    e.Editor.AutoDeskew();              
    e.Editor.AutoRotate();
    e.Editor.AdvancedBinarize();
    e.Editor.BorderExtract(BorderExtractMode.deskewCrop);
    e.Editor.RemovePunchHoles();
    e.Editor.SmoothCharacters();
    e.Editor.CleanNoise(3);             
}

void RepairFile(string imageFile, string imageFileOut)
{
    ImageEditor editor = new ImageEditor();
    try
    {
        editor.Edit(imageFile, EditPageEventHandler, imageFileOut, ImageFileFormat.outputFileExtension, true);
    }
    catch (ClearImageException ex)
    { Console.WriteLine(ex.Message); }
    finally
    {editor.Dispose(); }  // ClearImage V9 and later
}
}
See Also

Reference

ImageEditor Class
ImageEditor Members
Overload List