Beispiel #1
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            // Here we look at an area on the page and redact the text in it
            XRect toRedact = new XRect(textBoxRect.Text);

            using (Doc doc = new Doc()) {
                doc.Read(_src);
                TextOperation op = new TextOperation(doc);
                op.PageContents.AddPages(1);
                string text = op.GetText(toRedact, 1);
                IList <TextFragment> fragments = op.Select(0, text.Length);
                if (radioButtonCoarse.Checked)
                {
                    SimpleRedaction.RedactTextOps(doc, fragments);
                }
                else
                {
                    FineRedaction.RedactCharacters(doc, fragments);
                }
                doc.Flatten();
                string dst = Path.Combine(Directory.GetParent(_src).FullName, "_" + Path.GetRandomFileName() + ".pdf");
                doc.Save(dst);
                _src = dst;
                UpdateDoc();
            }
        }
Beispiel #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     // here we search for some text on the page and then redact it
     using (Doc doc = new Doc()) {
         doc.Read(_src);
         using (XRect rect = doc.Rect) {
             List <TextFragment> fragments = FindText(doc);
             if (radioButtonCoarse.Checked)
             {
                 SimpleRedaction.RedactTextOps(doc, fragments);
             }
             else
             {
                 FineRedaction.RedactCharacters(doc, fragments);
             }
             doc.Flatten();
         }
         string dst = Path.Combine(Directory.GetParent(_src).FullName, "_" + Path.GetRandomFileName() + ".pdf");
         doc.Save(dst);
         _src = dst;
         UpdateDoc();
     }
 }