Example #1
0
        private void _okButton_Click(object sender, EventArgs e)
        {
            if (_documentControl.CanApplyToPreferences && _optionsControl.CanApplyToPreferences)
            {
                _documentControl.ApplyToPreferences();
                _optionsControl.ApplyToPreferences();

                if (_inputDocument != null)
                {
                    var redactionOptions = new DocumentRedactionOptions();
                    redactionOptions.ViewOptions                = _inputDocument.Annotations.RedactionOptions.ViewOptions;
                    redactionOptions.ConvertOptions             = RedactionOptions;
                    _inputDocument.Annotations.RedactionOptions = redactionOptions;
                }

                bool deleteExistingFile = File.Exists(_preferences.OutputDocumentFileName);
                if (deleteExistingFile && _preferences.DocumentFormat == DocumentFormat.Ltd)
                {
                    // This is an LTD file that already exists, so ask the user what to do here, delete or append to it
                    string message = string.Format("Delete the existing output file '{0}' first?{1}The file already exists. Select 'Yes' to delete it and create a new one or 'No' to append this result to it.",
                                                   _preferences.OutputDocumentFileName, Environment.NewLine);
                    switch (Messager.ShowQuestion(null, message, MessageBoxButtons.YesNo))
                    {
                    case DialogResult.Yes:
                        deleteExistingFile = true;
                        break;

                    case DialogResult.No:
                        deleteExistingFile = false;
                        break;
                    }
                }

                // Delete the output file first
                if (deleteExistingFile)
                {
                    try
                    {
                        File.Delete(_preferences.OutputDocumentFileName);
                    }
                    catch (Exception ex)
                    {
                        Messager.ShowError(this, ex);
                        DialogResult = DialogResult.None;
                        return;
                    }
                }

                // Get the languages
                if (_preferences.OcrEngineInstance != null)
                {
                    if (!GetOCRLanguages(_preferences.OcrEngineInstance))
                    {
                        DialogResult = DialogResult.None;
                    }
                }
            }
        }
Example #2
0
 private void UpdateOptions()
 {
     this._viewRedactionOptionsControl.Options    = this._options.ViewOptions;
     this._convertRedactionOptionsControl.Options = this._options.ConvertOptions;
 }
Example #3
0
        private void SetOptions(DocumentConverter converter, ObjectCache cache, LEADDocument document, ConvertRedactionOptions redactionOptions)
        {
            converter.SetAnnRenderingEngineInstance(this.AnnRenderingEngine);

            // Set the RasterCodecs instance, should go into the DocumentFactory class which will be used to load the document
            if (this.RasterCodecsInstance != null)
            {
                DocumentFactory.RasterCodecsTemplate = this.RasterCodecsInstance;
            }

            // Set the OCR engine
            if (this.OcrEngineInstance != null && this.OcrEngineInstance.IsStarted)
            {
                converter.SetOcrEngineInstance(this.OcrEngineInstance, false);
            }

            if (this.DocumentWriterInstance != null)
            {
                converter.SetDocumentWriterInstance(this.DocumentWriterInstance);
            }

            // Set pre-processing options
            converter.Preprocessor.Deskew = this.PreprocessingDeskew;
            converter.Preprocessor.Invert = this.PreprocessingInvert;
            converter.Preprocessor.Orient = this.PreprocessingOrient;

            // Enable trace
            converter.Diagnostics.EnableTrace = this.EnableTrace;

            // Setup the load document options
            var loadDocumentOptions = new LoadDocumentOptions();

            // Setup cache
            loadDocumentOptions.Cache    = cache;
            loadDocumentOptions.UseCache = cache != null;

            if (document == null)
            {
                // Set the input annotation mode or file name
                loadDocumentOptions.LoadEmbeddedAnnotations = this.LoadEmbeddedAnnotation;
                if (!this.LoadEmbeddedAnnotation && !string.IsNullOrEmpty(this.InputAnnotationsFileName) && File.Exists(this.InputAnnotationsFileName))
                {
                    // We will use this instead of DocumentConverterJobData.InputAnnotationsFileName (this will override it anyway if we give the
                    // document converter a loadDocumentOptions)
                    loadDocumentOptions.AnnotationsUri = new Uri(this.InputAnnotationsFileName);
                }
            }

            converter.LoadDocumentOptions = loadDocumentOptions;

            // Set options
            converter.Options.JobErrorMode = this.ErrorMode;
            if (!string.IsNullOrEmpty(this.PageNumberingTemplate))
            {
                converter.Options.PageNumberingTemplate = this.PageNumberingTemplate;
            }
            converter.Options.EnableSvgConversion      = this.EnableSvgConversion;
            converter.Options.SvgImagesRecognitionMode = (this.OcrEngineInstance != null && this.OcrEngineInstance.IsStarted) ? this.SvgImagesRecognitionMode : DocumentConverterSvgImagesRecognitionMode.Disabled;
            converter.Options.EmptyPageMode            = this.EmptyPageMode;
            converter.Options.UseThreads      = this.UseThreads;
            converter.Diagnostics.EnableTrace = this.EnableTrace;

            // Set Redaction Options
            if (redactionOptions != null)
            {
                var documentRedactionOptions = new DocumentRedactionOptions();
                documentRedactionOptions.ConvertOptions = redactionOptions;
                if (document != null)
                {
                    documentRedactionOptions.ViewOptions  = document.Annotations.RedactionOptions.ViewOptions;
                    document.Annotations.RedactionOptions = documentRedactionOptions;
                }
                else
                {
                    converter.LoadDocumentOptions.RedactionOptions = documentRedactionOptions;
                }
            }
        }