How to control the appearance of anchor text in a redacted region?

Q:

I am trying out PDFTron PDFNet to check whether this can be used for PDF Redaction.

I have provide replacement text , replacement font and size to the redact function, however the replaced text appears very small, regardless of the font size provided.

Below code is used for redaction

void Redact(string input, string output, ArrayList rarr,PDFDoc doc) {

Redactor.Appearance app = new Redactor.Appearance();

app.Font = new System.Drawing.Font(“Arial”, 1);

app.Border = false;

Redactor.Redact(doc, rarr, app);

}

A:

The purpose of Redactor is to remove all PDF content within a specified region.

Although Redactor is not intended for text search & replace in PDF ('pdftron.PDF.ContentReplacer’ may better suited for this - http://www.pdftron.com/pdfnet/samplecode.html#ContentReplacer), there is a feature in Redactor class (Redactor.Appearance) that could be used to customize the appearance of the optional redaction overlay (e.g. used to add extra information in the redacted region that confidential info was removed etc).

Within ‘Redactor.Appearance’ you can specify properties such as ‘MinFontSize’ & ‘MaxFontSize’. If you want all text to be of a specific size set both properties to the same value. For example:

Redactor.Appearance app = new Redactor.Appearance();

app.MinFontSize = app.MaxFontSize = 18;

app.PositiveOverlayColor = System.Drawing.Color.Red;

app.NegativeOverlayColor = System.Drawing.Color.WhiteSmoke;

Redactor.Redact(doc, redact_region, app);

Q:

Thanks for the help. I tried setting ‘MinFontSize’ and ‘MaxFontSize’, and it did fix the font size issue, however the text is not properly aligned.

I tried setting vertical alignment property for ‘Redactor.Appearance’, but the text is going either bit above or below , not aligning properly as the original text.

I understood that redactor is not designed for search and replace. The text I want to replace needs to be in different font from the original text. I tried using ‘pdftron.PDF.ContentReplacer’, but I couldn’t find a property for setting font. Please let me know if there is any method I could use to provide font & size to the ‘ContentReplacer’.

A:

➢ not aligning properly as the original text.

This is the intended behavior for anchor text in Redactor. Also ContentReplacer is supposed to do ‘smart’ things such as copy text properties from the original text.

Your best bet may be to use TextSearch (see TextSearch sample - http://www.pdftron.com/pdfnet/samplecode.html#TextSearch) to search for text and to obtain text positioning info.

You can then use Redactor to erase text in the given region, then use pdftron.PDF.Stamper (http://www.pdftron.com/pdfnet/samplecode/StamperTest.cs) or ElementBuilder/ElementWriter to add new text at the location where the old text was erased.

On Monday, April 22, 2013 10:32:45 AM UTC-7, Support wrote:

Q:

I am trying out PDFTron PDFNet to check whether this can be used for PDF Redaction.

I have provide replacement text , replacement font and size to the redact function, however the replaced text appears very small, regardless of the font size provided.

Below code is used for redaction

void Redact(string input, string output, ArrayList rarr,PDFDoc doc) {

Redactor.Appearance app = new Redactor.Appearance();

app.Font = new System.Drawing.Font(“Arial”, 1);

app.Border = false;

Redactor.Redact(doc, rarr, app);

}


A:

The purpose of Redactor is to remove all PDF content within a specified region.

Although Redactor is not intended for text search & replace in PDF ('pdftron.PDF.ContentReplacer’ may better suited for this - http://www.pdftron.com/pdfnet/samplecode.html#ContentReplacer), there is a feature in Redactor class (Redactor.Appearance) that could be used to customize the appearance of the optional redaction overlay (e.g. used to add extra information in the redacted region that confidential info was removed etc).

Within ‘Redactor.Appearance’ you can specify properties such as ‘MinFontSize’ & ‘MaxFontSize’. If you want all text to be of a specific size set both properties to the same value. For example:

Redactor.Appearance app = new Redactor.Appearance();

app.MinFontSize = app.MaxFontSize = 18;

app.PositiveOverlayColor = System.Drawing.Color.Red;

app.NegativeOverlayColor = System.Drawing.Color.WhiteSmoke;

Redactor.Redact(doc, redact_region, app);