private void showAsJson_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Template t  = getTemplateFromUI(false);
            TextForm tf = new TextForm("Template JSON object", Serialization.Json.Serialize(t), false);

            tf.ShowDialog();
        }
        private void ShowOcrText_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (pages == null)
            {
                return;
            }
            List <string> ls = Page.GetTextLines(pages[currentPageI].ActiveTemplateOcrCharBoxs, new TextAutoInsertSpace {
                Threshold = (float)textAutoInsertSpaceThreshold.Value, Representative = Regex.Unescape(textAutoInsertSpaceRepresentative.Text)
            });
            TextForm tf = new TextForm("OCR Text", string.Join("\r\n", ls), false);

            tf.ShowDialog();
        }
        private void ShowPdfText_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (pages == null)
            {
                return;
            }
            //TextForm tf = new TextForm("Pdf Entity Text", PdfTextExtractor.GetTextFromPage(pages.PdfReader, currentPageI), false);
            TextForm tf = new TextForm("Pdf Entity Text", Page.GetText(pages[currentPageI].PdfCharBoxs, new TextAutoInsertSpace {
                Threshold = (float)textAutoInsertSpaceThreshold.Value, Representative = Regex.Unescape(textAutoInsertSpaceRepresentative.Text)
            }), false);

            tf.ShowDialog();
        }
        private void ShowOcrText_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (pages == null)
            {
                return;
            }
            //TextForm tf = new TextForm("OCR Text", PdfDocumentParser.Ocr.This.GetHtml(pages[currentPageI].Bitmap), true);
            TextForm tf = new TextForm("OCR Text", PdfDocumentParser.Ocr.GetText(pages[currentPageI].ActiveTemplateOcrCharBoxs, new TextAutoInsertSpace {
                Threshold = (float)textAutoInsertSpaceThreshold.Value, Representative = Regex.Unescape(textAutoInsertSpaceRepresentative.Text)
            }), false);

            tf.ShowDialog();
        }
        private void showAsJson_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Template t  = GetTemplateFromUI(true);
            TextForm tf = new TextForm("Template JSON object", Serialization.Json.Serialize(t), true);

            while (tf.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Template t2 = Serialization.Json.Deserialize <Template>(tf.Content);
                    t2.Editor = t.Editor;
                    setUIFromTemplate(t2);
                    break;
                }
                catch (Exception ex)
                {
                    Message.Error2("Updating template:", ex);
                }
            }
        }
        private void ShowOcrText_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (pages == null)
            {
                Message.Exclaim("No file is open.");
                return;
            }
            pages.ActiveTemplate = GetTemplateFromUI(false);
            List <string> ls = Page.GetTextLines(
                pages[currentPageI].ActiveTemplateOcrCharBoxs,
                new TextAutoInsertSpace {
                Threshold = (float)textAutoInsertSpace_Threshold.Value, IgnoreSourceSpaces = textAutoInsertSpace_IgnoreSourceSpaces.Checked                          /*, Representative//default*/
            },
                new CharFilter {
                MinWidth = (float)CharSizeFilterMinWidth.Value, MaxWidth = (float)CharSizeFilterMaxWidth.Value, MinHeight = (float)CharSizeFilterMinHeight.Value, MaxHeight = (float)CharSizeFilterMaxHeight.Value
            }
                );
            TextForm tf = new TextForm("OCR Text", string.Join("\r\n", ls), false);

            tf.ShowDialog();
        }
        private void ShowPdfText_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (pages == null)
            {
                Message.Exclaim("No file is open.");
                return;
            }
            //TextForm tf = new TextForm("Pdf Entity Text", PdfTextExtractor.GetTextFromPage(pages.PdfReader, currentPageI), false);
            string t = Page.GetText(
                pages[currentPageI].PdfCharBoxs,
                new TextAutoInsertSpace {
                Threshold = (float)textAutoInsertSpace_Threshold.Value, IgnoreSourceSpaces = textAutoInsertSpace_IgnoreSourceSpaces.Checked                           /*, Representative//default*/
            },
                new CharFilter {
                MinWidth = (float)CharSizeFilterMinWidth.Value, MaxWidth = (float)CharSizeFilterMaxWidth.Value, MinHeight = (float)CharSizeFilterMinHeight.Value, MaxHeight = (float)CharSizeFilterMaxHeight.Value
            }
                );
            TextForm tf = new TextForm("Pdf Entity Text", t, false);

            tf.ShowDialog();
        }