Q: I just saw your post regarting PDF text editing (changing some
style properties) - http://groups.google.com/group/pdfnet-sdk/t/3dc46957e08067d8#
Can I use the same approach to delete PDF text from a given region.
For example:
byte[] cdata = new byte[1];
element.SetTextData(cdata, 1);
--------------
A: You could use the same apprach however please keep in mind that
full-blown and proper PDF redaction is much more difficult. As part of
the next PDFNet update we are planning to include a new add-on
(pdftron.PDF.Redactor) that will provide simple to use interface for
PDF redaction. The current version (v5.5) of PDFNet already comes with
the preview API which can be used the as follows:
using System;
using System.IO;
using System.Collections;
using pdftron;
using pdftron.Common;
using pdftron.Filters;
using pdftron.SDF;
using pdftron.PDF;
namespace PDFNetSamples
{
class PDFRedactionSample
{
static void Redact(string input, string output, ArrayList
rarr)
{
using (PDFDoc doc = new PDFDoc(input))
{
doc.InitSecurityHandler();
Redactor.Redact(doc, rarr);
doc.Save(output, SDFDoc.SaveOptions.e_linearized);
}
}
/// <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(0, 0, 600,
600), false, "Top Secret"));
rarr.Add(new Redactor.Redaction(2, new Rect(0, 0, 100,
100), false, "foo"));
rarr.Add(new Redactor.Redaction(2, new Rect(100, 100,
200, 200), false, "bar"));
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, ""));
Redact(input_path + "newsletter.pdf", output_path +
"redacted.pdf", rarr);
}
catch (PDFNetException e)
{
Console.WriteLine(e.Message);
}
}
}
}