/// <summary> /// The following sample illustrates how to redact a PDF document using 'pdftron.PDF.Redactor'. /// </summary> static void Main(string[] args) { PDFNet.Initialize(); string input_path = "../../TestFiles/"; string output_path = "../../TestFiles/Output/"; try { ArrayList rarr = new ArrayList(); rarr.Add(new Redactor.Redaction(1, new Rect(100, 100, 550, 600), false, "Top Secret")); rarr.Add(new Redactor.Redaction(2, new Rect(30, 30, 450, 450), true, "Negative Redaction")); rarr.Add(new Redactor.Redaction(2, new Rect(0, 0, 100, 100), false, "Positive")); rarr.Add(new Redactor.Redaction(2, new Rect(100, 100, 200, 200), false, "Positive")); rarr.Add(new Redactor.Redaction(2, new Rect(300, 300, 400, 400), false, "")); rarr.Add(new Redactor.Redaction(2, new Rect(500, 500, 600, 600), false, "")); rarr.Add(new Redactor.Redaction(3, new Rect(0, 0, 700, 20), false, "")); Redactor.Appearance app = new Redactor.Appearance(); app.RedactionOverlay = true; app.Border = false; app.ShowRedactedContentRegions = true; Redact(input_path + "newsletter.pdf", output_path + "redacted.pdf", rarr, app); Console.WriteLine("Done..."); } catch (PDFNetException e) { Console.WriteLine(e.Message); } }
static void Redact(string input, string output, ArrayList rarr, Redactor.Appearance app) { using (PDFDoc doc = new PDFDoc(input)) { doc.InitSecurityHandler(); Redactor.Redact(doc, rarr, app, false, true); doc.Save(output, SDFDoc.SaveOptions.e_linearized); } }