Skip to main content
Participant
January 26, 2023
Question

Marking and Redacting PDF

  • January 26, 2023
  • 1 reply
  • 694 views

Hello everyone,

 

I  mark documents for redaction by using the drawing tool to place a rectangle around sensitive data. I then use javascript to place redaction boxes within the rectangles. However, I would like to apply the redactions without deleting the rectangles. Can you help me accomplish this task?

 

Additionally, I prefer to mark documents for redaction using brackets like these "[ ]" , or using a partiallty-completed square/rectangle (only the corners, or the top left and bottom right corner). Is there a drawing tool, or a javascript function that can produce such annotations? I hope to use these annotations instead of the rectangle. 

 

Here is the code I am using to find rectangle annotations and redact:

 

// Get the active document

var doc = event.target;

 

// Get all the rectangle shapes in the document

var rectangles = doc.getAnnots({type: "Rect"});

 

// Loop through each rectangle shape

for (var i = 0; i < rectangles.length; i++) {

    var rectangle = rectangles[i];

 

    // Get the rectangle's coordinates

    var rct = getAnnots(this.pageNum)[i].rect;

    var left = rct[0];

    var right = rct[2];

    var top = rct[3];

    var bot = rct[1];

    qd = [ [left, top, right, top, left, bot, right, bot] ];

    qd.toSource();

 

    // Create a new redaction annotation within the rectangle's bounds

    var redaction = this.addAnnot({

        type: "Redact",

        page: rectangle.page,

        quads: qd,

        repeat:true

    });

}

 

Thank you in advance for your help. Much Appreciated

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
January 27, 2023

Before redacting, export the comment data to an FDF file, then import it back in afterwards.

Participant
January 27, 2023

This is very helpful, thanks

try67
Community Expert
Community Expert
January 27, 2023

Regarding using brackets: There's no built-in way to do that, but it is possible to create a script that will convert the comments you did create (for example, highlights), into this format, using a set of Line comments.

 

If this is something you're interested in, I could develop it for you, for a fee. You can contact me privately by clicking my user-name and then on "Send a Message" to discuss it further.