ArrayList rarr = new ArrayList();
Current_View.DocLockRead();
int itr = Current_View.GetSelectionBeginPage();
int end = Current_View.GetSelectionEndPage();
for (; itr <= end; ++itr)
{
PDFViewWPF.Selection selection = Current_View.GetSelection(itr);
double[] quads = selection.GetQuads();
int sz = quads.Length / 8; //each quad has eight numbers (x0, y0), ... (x3, y3)
if (sz == 0) continue;
for(int i = 0; i < sz; ++i)
{
int offset = 8 * i;
// we just want an axis aligned bounding box.
double[] x_axis = { quads[offset], quads[offset + 2], quads[offset + 4], quads[offset + 6] };
double[] y_axis = { quads[offset + 1], quads[offset + 3], quads[offset + 5], quads[offset + 7] };
double x1 = x_axis.Min();
double y1 = y_axis.Min();
double x2 = x_axis.Max();
double y2 = y_axis.Max();
rarr.Add(new Redactor.Redaction(itr, new pdftron.PDF.Rect(x1, y1, x2, y2), false, ""));
}
}
Current_View.DocUnlockRead();
Redactor.Appearance app = new Redactor.Appearance();
app.PositiveOverlayColor = System.Drawing.Color.Red;
app.NegativeOverlayColor = System.Drawing.Color.WhiteSmoke;
Current_View.DocLock(true);
Redactor.Redact(Current_View.GetDoc(), rarr, app);
Current_View.DocUnlock();
The following code will redact all text currently selected in the document.You put this code into something like SetSmoothImages function in PDFViewForm.cs in the PDFViewTest sample project. Then you can highlight text, and then in the toolbar pick the Options->Smooth Images option to redact.
ArrayList rarr = new ArrayList();
_pdfview.DocLockRead();int itr = _pdfview.GetSelectionBeginPage();int end = _pdfview.GetSelectionEndPage();
for (; itr <= end;++itr ){
PDFViewCtrl.Selection selection = _pdfview.GetSelection(itr);
double[] quads = selection.GetQuads();int sz = quads.Length / 8; //each quad has eight numbers (x0, y0), ... (x3, y3)if (sz == 0) continue;
// we just want an axis aligned bounding box.
double[] x_axis = { quads[0], quads[2], quads[4], quads[6] };double[] y_axis = { quads[1], quads[3], quads[5], quads[7] };
double x1 = x_axis.Min();double y1 = y_axis.Min();double x2 = x_axis.Max();double y2 = y_axis.Max();
rarr.Add(new Redactor.Redaction(itr, new Rect(x1, y1, x2, y2), false, ""));}_pdfview.DocUnlockRead();
Redactor.Appearance app = new Redactor.Appearance();app.PositiveOverlayColor = System.Drawing.Color.Red;app.NegativeOverlayColor = System.Drawing.Color.WhiteSmoke;
_pdfview.DocLock(true);Redactor.Redact(_pdfview.GetDoc(), rarr, app);_pdfview.DocUnlock();_pdfview.Update();