• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit Search
0

Convert rectangle annotation to brackets

New Here ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

Hello everyone,

 

I am attempting to autmate parts of my PDF redacting process by using the following javascript code to draw redactions inside manually drawn redaction marks:

 

var annots = this.getAnnots();

for (var i=annots.length-1; i>=0; i--) {

    if (annots[i].type == "Square") {

    var rct = annots[i].rect;

    var left = rct[0];

    var right = rct[2];

    var top = rct[3];

    var bot = rct[1];

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

    this.addAnnot( {

        page: annots[i].page,

        type: "Redact",

        quads: qd,

        overlayText: " ", //THIS IS THE REDACTION TEXT

        alignment: 1,            // "0" = LEFT, "1" = CENTRE, "2" = RIGHT

        fillColor: color.white,  //THIS CHANGES THE FILL COLOUR

        textColor: color.white,  //THIS CHANGES THE FONT COLOUR

        textSize: 0,             //FONT SIZE, '0' will adjust the size to fit each box, otherwise you can use a specific font size

        });

    }

}

 

this.applyRedactions ({

bKeepMarks: false,

bShowConfirmation: false,

});

Source: 

https://community.adobe.com/t5/acrobat-sdk-discussions/converting-a-rectangle-annotation-to-a-redact... 

 

 

The code works, but my organization has sylistic standards that require redaction marks to apear like brackets "[  ]", or perhaps like a rectangular shape with four corners and the sides hidden. These redaction marks must be visible in the final PDF. 

 

Can anyone help me use javascript, or some other means to make the rectangles appear like brackets? The following code uses a dashed border to produce something similar to brackets, but I would prefer a better solution:

Before: 

Christopher2812030036pt_1-1676490163815.png

 

var annots = this.getAnnots();

 

 

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

if (annots[i].type == "Square") {

annots[i].strokeColor = color.black;

annots[i].dash = [60,20];

}

}

Result: 

Christopher2812030036pt_0-1676489987976.png

 

Thank you!!!

TOPICS
How to , JavaScript , PDF forms

Views

678

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

Redacted areas are replaced by text or a rectangle. These are setting in both the redaction tool, and on the actual redaction annotation. You could set the overlay text to be brackets.

Here's the reference entry.

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#overlaytext

 

Or if setting the overlay text doesn't work, then brackets or corner symbols could be drawn using the "ink" annotation. But, this would need to be done after the document is redacted. If done before redaction, the drawing could be removed. So, your automation script will need to save the redaction rectangle, apply the redaction, then create the brackets, and finally flatten. 

 

Here's an article on automating Redaction:

https://acrobatusers.com/tutorials/auto_redaction_with_javascript/

 

   

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

LATEST

Much appreciated, Thom! I will try these suggestions and see how it goes.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines