Beispiel #1
0
        private void converter()
        {
            foreach (string file in fileList.Items)
            {
                WaitForm wait = new WaitForm();
                wait.StartPosition = FormStartPosition.CenterParent;
                wait.Status = "Converting " + Path.GetFileName(file) + "...";

                if (mdi.Open(file))
                {
                    string saveTo = "";
                    List<int> pages = (List<int>)Enumerable.Range(0, mdi.Doc.Images.Count).ToList();

                    if (toFolder.Checked)
                        saveTo = outDir.Text + "\\";
                    else if (toOrigin.Checked)
                        saveTo = Path.GetDirectoryName(file) + "\\";

                    saveTo += Path.GetFileNameWithoutExtension(file);
                    saveTo += "." + formatBox.SelectedItem.ToString().ToLower();

                    if (formatBox.SelectedItem.ToString() == "TIFF")
                    {
                        mdi.SaveToDocAsync(pages, saveTo, MODI.MiFILE_FORMAT.miFILE_FORMAT_TIFF, wait);
                        wait.ShowDialog();
                    }
                    else if (formatBox.SelectedItem.ToString() == "PDF")
                    {
                        mdi.SaveToPDFAsync(pages, saveTo, wait);
                        wait.ShowDialog();
                    }
                }
                else
                    wait.MessageSafe("Unable to load " + file);
            }

            //wait.CloseSafe();
        }
Beispiel #2
0
        // Converting
        private void Save(IList<int> indices)
        {
            if (!mdi.IsOpen)
            {
                MessageBox.Show("You must open a file first!", title);
                return;
            }

            if(indices.Count < 1)
            {
                MessageBox.Show("No pages selected!", title);
                return;
            }

            // default to: filename.jpg
            saveFileDialog.FilterIndex = (int)fileType.FT_JPG + 1; // filter index starts from 1
            saveFileDialog.FileName = Path.GetFileNameWithoutExtension(mdi.FileName) + ".jpg";
            // default dir to where it was opened
            saveFileDialog.InitialDirectory = Path.GetDirectoryName(mdi.FileName);

            // show the save dialog
            DialogResult result = saveFileDialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                // filter index starts from 1 ...
                fileType type = (fileType)saveFileDialog.FilterIndex - 1;

                // process per page image conv (jpg, png, bmp...)
                if(imageFormats.ContainsKey(type))
                {
                    WaitForm wait = new WaitForm();
                    wait.StartPosition = FormStartPosition.CenterParent;

                    mdi.SaveToImagesAsync(indices, saveFileDialog.FileName,
                        imageFormats[type],  wait);
                    wait.ShowDialog();
                }

                // process doc formats handled by MODI (mdi, tiff)
                else if (documentFormats.ContainsKey(type))
                {
                    WaitForm wait = new WaitForm();
                    wait.StartPosition = FormStartPosition.CenterParent;

                    mdi.SaveToDocAsync(indices, saveFileDialog.FileName,
                        documentFormats[type], wait);
                    wait.ShowDialog();
                }

                // plaintext
                else if(type == fileType.FT_TXT)
                {
                    if (!mdi.IsOCRDone)
                        DoOCR();

                    mdi.SaveToTxt(indices, saveFileDialog.FileName);
                }

                // PDF
                else if (type == fileType.FT_PDF)
                {
                    WaitForm wait = new WaitForm();
                    wait.StartPosition = FormStartPosition.CenterParent;

                    mdi.SaveToPDFAsync(indices, saveFileDialog.FileName, wait);
                    wait.ShowDialog();
                }
            }
        }
Beispiel #3
0
        // Search
        private void DoOCR()
        {
            if (!mdi.IsOpen) return;
            if (mdi.IsOCRDone) return;

            WaitForm wait = new WaitForm();
            wait.StartPosition = FormStartPosition.CenterParent;

            mdi.DoOCRAsync(wait);
            wait.ShowDialog();

            // OCR might auto-rotate pages so re-render
            RenderThumbs();
        }