Implementing PDF redaction using PDFNet SDK.

Q:
I need to be able to censor areas of a PDF document. This can not be
achieved securely by adding a PDF.Image that is positioned over the
sensitive part of the page (slow rendering can show the sensitive
information before the mask is overlaid and also the PDF file can be
inspected). Therefore, I have decided to retrieve the page as a single
bitmap, alter this and replace the original page with a "flattened"
version that just contains the detail as a PDF.Image.
---

A:

If you use pdfdraw.GetBitmap() to create a replace for the original
page, you will lose original image quality because the text, vector
graphics, and hi-res images will be converted to raster bitmap. You
can, of course, increase the resolution to image by increasing the DPI
(e.g. pdfdraw.SetDPI(200)), however this will not completely solve the
problem.

A better approach would be to edit the page by deleting all the
content that is inside the selection rectangle.
This can be implemented along the lines of ElementEdit sample project
(http://www.pdftron.com/net/samplecode.html#ElementEdit). In your case
you would need to test for intersections between selection rectangle
and 'Element' bounding boxes (see http://www.pdftron.com/net/samplecode.html#TextExtract
for a similar use case). The only tricky part is when selection
rectangle partially intersects an element. Depending on your
requirements you could implement different solutions to this problem.

The advantage of this approach is that you will not lose original
content or 'downgrade' the quality of original PDF document.