// Populate the UI from preferences
        public void Populate(LEADDocument inputDocument, DocumentConverterPreferences preferences)
        {
            _preferences = preferences;

            if (_preferences.OcrEngineInstance == null)
            {
                _enableSvgConversionCheckBox.Checked = true;
                _enableSvgConversionCheckBox.Enabled = false;
            }
            else
            {
                _enableSvgConversionCheckBox.Checked = _preferences.EnableSvgConversion;
            }

            _svgImagesRecognitionModeComboBox.Items.Clear();
            foreach (var i in Enum.GetValues(typeof(DocumentConverterSvgImagesRecognitionMode)))
            {
                _svgImagesRecognitionModeComboBox.Items.Add(i);
            }
            _svgImagesRecognitionModeComboBox.SelectedItem = (_preferences.OcrEngineInstance != null && _preferences.OcrEngineInstance.IsStarted) ? _preferences.SvgImagesRecognitionMode : DocumentConverterSvgImagesRecognitionMode.Disabled;
            _svgImagesRecognitionModeLabel.Enabled         = _preferences.OcrEngineInstance != null && _preferences.OcrEngineInstance.IsStarted;
            _svgImagesRecognitionModeComboBox.Enabled      = _preferences.OcrEngineInstance != null && _preferences.OcrEngineInstance.IsStarted;

            _emptyPageModeComboBox.Items.Clear();
            foreach (var i in Enum.GetValues(typeof(DocumentConverterEmptyPageMode)))
            {
                _emptyPageModeComboBox.Items.Add(i);
            }
            _emptyPageModeComboBox.SelectedItem = _preferences.EmptyPageMode;

            _useThreadsCheckBox.Checked = _preferences.UseThreads;

            _deskewCheckBox.Checked = _preferences.PreprocessingDeskew;
            _invertCheckBox.Checked = _preferences.PreprocessingInvert;
            _orientCheckBox.Checked = _preferences.PreprocessingOrient;

            _continueOnRecoverableErrorsCheckBox.Checked = (_preferences.ErrorMode == DocumentConverterJobErrorMode.Continue);
            _enableTraceCheckBox.Checked = _preferences.EnableTrace;
            _jobNameTextBox.Text         = _preferences.JobName;

            if (_preferences.OpenOutputDocumentAllowed)
            {
                _openOutputDocumentCheckBox.Checked = _preferences.OpenOutputDocument;
            }
            else
            {
                _openOutputDocumentCheckBox.Checked = false;
                _openOutputDocumentCheckBox.Enabled = false;
                _openOutputDocumentCheckBox.Visible = false;
            }

            if (inputDocument != null)
            {
                _redactionOptionsControl.Options = inputDocument.Annotations.RedactionOptions.ConvertOptions.Clone();
            }

            UpdateHelp();
        }
コード例 #2
0
        public DocumentConverterPreferences Clone()
        {
            var result = new DocumentConverterPreferences();

            result.InputDocumentFileName     = this.InputDocumentFileName;
            result.InputDocumentPageCount    = this.InputDocumentPageCount;
            result.InputFirstPage            = this.InputFirstPage;
            result.InputLastPage             = this.InputLastPage;
            result.InputMaximumPages         = this.InputMaximumPages;
            result.InputAnnotationsFileName  = this.InputAnnotationsFileName;
            result.LoadEmbeddedAnnotation    = this.LoadEmbeddedAnnotation;
            result.DocumentFormat            = this.DocumentFormat;
            result.RasterImageFormat         = this.RasterImageFormat;
            result.RasterImageBitsPerPixel   = this.RasterImageBitsPerPixel;
            result.OutputDocumentFileName    = this.OutputDocumentFileName;
            result.OutputAnnotationsMode     = this.OutputAnnotationsMode;
            result.OutputAnnotationsFileName = this.OutputAnnotationsFileName;
            result.PageNumberingTemplate     = this.PageNumberingTemplate;
            result.EnableSvgConversion       = this.EnableSvgConversion;
            result.SvgImagesRecognitionMode  = this.SvgImagesRecognitionMode;
            result.EmptyPageMode             = this.EmptyPageMode;
            result.UseThreads                   = this.UseThreads;
            result.PreprocessingDeskew          = this.PreprocessingDeskew;
            result.PreprocessingInvert          = this.PreprocessingInvert;
            result.PreprocessingOrient          = this.PreprocessingOrient;
            result.ErrorMode                    = this.ErrorMode;
            result.EnableTrace                  = this.EnableTrace;
            result.JobName                      = this.JobName;
            result.OpenOutputDocument           = this.OpenOutputDocument;
            result.OpenOutputDocumentAllowed    = this.OpenOutputDocumentAllowed;
            result.OCREngineType                = this.OCREngineType;
            result.OCREngineRuntimePath         = this.OCREngineRuntimePath;
            result.RasterCodecsOptionsPath      = this.RasterCodecsOptionsPath;
            result.DocumentWriterOptionsPath    = this.DocumentWriterOptionsPath;
            result.CacheDirectory               = this.CacheDirectory;
            result.CacheDataSerializationMode   = this.CacheDataSerializationMode;
            result.CachePolicySerializationMode = this.CachePolicySerializationMode;

            result.DocumentId               = this.DocumentId;
            result.DocumentUserToken        = this.DocumentUserToken;
            result.OutputFiles              = this.OutputFiles;
            result.OutputDocumentFiles      = this.OutputDocumentFiles;
            result.OutputDocumentExtraFiles = this.OutputDocumentExtraFiles;
            result.OutputAnnotationFiles    = this.OutputAnnotationFiles;
            result.PurgeOutputFilesOnError  = this.PurgeOutputFilesOnError;

            // Be careful, we are using the same objects here
            result.RasterCodecsInstance   = this.RasterCodecsInstance;
            result.OcrEngineInstance      = this.OcrEngineInstance;
            result.DocumentWriterInstance = this.DocumentWriterInstance;
            result.IsSilentMode           = this.IsSilentMode;
            result.ErrorMessage           = this.ErrorMessage;
            result.AnnRenderingEngine     = this.AnnRenderingEngine;

            return(result);
        }
コード例 #3
0
        // Populate the UI from preferences
        public void Populate(LEADDocument document, DocumentConverterPreferences preferences)
        {
            _preferences   = preferences;
            _inputDocument = document;

            _documentFormatSelector      = new DocumentFormatSelector();
            _documentFormatSelector.Dock = DockStyle.Fill;
            _outputFormatPanel.Controls.Add(_documentFormatSelector);
            _documentFormatSelector.BringToFront();

            _documentFormatSelector.SetDocumentWriter(_preferences.DocumentWriterInstance, true);

            if (_preferences.OcrEngineInstance != null)
            {
                _documentFormatSelector.SetOcrEngineType(_preferences.OcrEngineInstance.EngineType);
            }

            _documentFormatSelector.SelectedFormatChanged += _documentFormatSelector_SelectedFormatChanged;

            foreach (var format in _rasterFormats)
            {
                _rasterImageFormatComboBox.Items.Add(format);
            }

            // Input ...
            if (_inputDocument == null)
            {
                _inputDocumentFileTextBox.Text = _preferences.InputDocumentFileName;
                if (_preferences.LoadEmbeddedAnnotation)
                {
                    _inputAnnotationsModeComboBox.SelectedIndex = 1; // Load embedded
                }
                else if (!string.IsNullOrEmpty(_preferences.InputAnnotationsFileName))
                {
                    _inputAnnotationsModeComboBox.SelectedIndex = 2; // Import from external file
                }
                else
                {
                    _inputAnnotationsModeComboBox.SelectedIndex = 0; // Do not import annotations
                }
                _inputAnnotationsFileTextBox.Text = _preferences.InputAnnotationsFileName;
            }
            else
            {
                string documentPath;
                var    documentUri = _inputDocument.Uri;
                if (documentUri != null)
                {
                    if (documentUri.IsFile)
                    {
                        documentPath = documentUri.LocalPath;
                    }
                    else
                    {
                        documentPath = documentUri.ToString();
                    }
                }
                else
                {
                    documentPath = "input.ext";
                }

                _inputDocumentFileTextBox.Text            = documentPath;
                _inputDocumentFileTextBox.ReadOnly        = true;
                _inputDocumentFileBrowseButton.Visible    = false;
                _inputAnnotationsModeLabel.Visible        = false;
                _inputAnnotationsModeComboBox.Visible     = false;
                _inputAnnotationsFileLabel.Visible        = false;
                _inputAnnotationsFileTextBox.Visible      = false;
                _inputAnnotationsFileBrowseButton.Visible = false;
            }

            // Output ...
            if (_preferences.DocumentFormat == DocumentFormat.User && _preferences.RasterImageFormat == RasterImageFormat.Unknown)
            {
                // Cannot do that, lets pick PDF
                _preferences.DocumentFormat = DocumentFormat.Pdf;
            }

            _documentFormatSelector.SelectedFormat = _preferences.DocumentFormat;

            foreach (var format in _rasterFormats)
            {
                if (format.RasterImageFormat == _preferences.RasterImageFormat)
                {
                    _rasterImageFormatComboBox.SelectedItem = format;
                    break;
                }
            }

            if (_rasterImageFormatComboBox.SelectedIndex == -1)
            {
                _rasterImageFormatComboBox.SelectedIndex = 0;
            }

            // 0 = Document, 1 = Raster
            if (_preferences.DocumentFormat != DocumentFormat.User)
            {
                _outputFormatComboBox.SelectedIndex = 0;
            }
            else
            {
                _outputFormatComboBox.SelectedIndex = 1;
            }

            if (_inputDocument == null || _inputDocument.Uri != null)
            {
                _outputDocumentFileTextBox.Text = _preferences.OutputDocumentFileName;
                _outputAnnotationsModeComboBox.SelectedIndex = (int)_preferences.OutputAnnotationsMode;
                _outputAnnotationsFileTextBox.Text           = _preferences.OutputAnnotationsFileName;
            }
            else
            {
                _outputDocumentFileTextBox.Text = "output.ext";
                _outputAnnotationsModeComboBox.SelectedIndex = (int)_preferences.OutputAnnotationsMode;
                _outputAnnotationsFileTextBox.Text           = _preferences.OutputAnnotationsFileName;

                _outputDocumentFileTextBox.ReadOnly     = true;
                _outputDocumentFileBrowseButton.Enabled = false;
                _outputAnnotationsModeComboBox.Enabled  = false;
            }

            UpdateInputPages(false);
        }