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

How to redact same areas on multiple documents

Community Beginner ,
Sep 18, 2024 Sep 18, 2024

Copy link to clipboard

Copied

I have thousands of documents where I'm trying to redact information that's located in the same position. I can't redact based on searching for text because it's different information on each document. Is there a quick way to do this?

TOPICS
JavaScript , PDF

Views

264

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

correct answers 2 Correct answers

Community Expert , Sep 18, 2024 Sep 18, 2024

The word function at the end of the line that starts //Part 2 is getting commented out.  It should be on the next line.  The next line should read:

function AddMyRedacts(quadList) {

Votes

Translate

Translate
Community Expert , Sep 18, 2024 Sep 18, 2024

I fixed and tested.  It worked.  If you are going to use this in an Action on several docs at once you should set bShowConfirmation to false so you don't have to dismiss a popup message for each doc.

Votes

Translate

Translate
Community Expert ,
Sep 18, 2024 Sep 18, 2024

Copy link to clipboard

Copied

First you will need to get the quads of the area you want to redact.  You can do this by using the highlight text commenting tool, selecting the highlight, and running the following script in the console:

this.selectedAnnots[0].quads;

Next, create an Action that Executes a JavaScript.  The script is:

this.addAnnot({
type:"Redact",
page: pg,
quads: qd});
this.applyRedactions();

pg is a variable representing the zero-based page number to apply the redactions to, and qd is a variable representing the quads returned from the previous step.

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
Community Beginner ,
Sep 18, 2024 Sep 18, 2024

Copy link to clipboard

Copied

Yeah, I was able to get the information for all of my quads and have that saved. 

 

I was able to plug one of them into this Javascript:

this.addAnnot({
type:"Redact",
page: 0,
quads: [[144.00064086914062, 750.10888671875, 179.34625244140625, 750.10888671875, 144.00064086914062, 732.4360961914062, 179.34625244140625, 732.4360961914062]],
overlayText: ":It's gone:",
alignment: 1, // Center alignment
repeat:true
});

 

But beyond that I can't get it to work when I try plugging quads into the full code that I got from the tutorial I'm looking at. It's from 2008 so I'm not sure if it's out of date information

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
Community Expert ,
Sep 18, 2024 Sep 18, 2024

Copy link to clipboard

Copied

I ran my script and yours (with my quads) and they both worked.  Did you run that script in the console to test?  Any errors?

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
Community Beginner ,
Sep 18, 2024 Sep 18, 2024

Copy link to clipboard

Copied

Yeah, the script I shared works fine (no errors) as far as highlighting one of the lines that I want to redact, but I'm trying to have this done to multiple quads, and not sure how I get multiple into that code.

 

Further, when I moved along into the later part of the tutorial, I try to plugin all of my quads and end up with Syntax error  Missing ; Before statement 9

 

The full code I'm working with:

// Part 1: Quads for the different Redaction areas
var qdFirstName = [[144.00064086914062, 750.10888671875, 179.34625244140625, 750.10888671875, 144.00064086914062, 732.4360961914062, 179.34625244140625, 732.4360961914062]];
var qdLastName = [[83.78219604492188, 714.1087646484375, 175.41897583007812, 714.1087646484375, 83.78219604492188, 699.0541381835938, 175.41897583007812, 699.0541381835938]];
var qdAdress = [[73.30941772460938, 701.0177612304688, 107.34593200683594, 701.0177612304688, 73.30941772460938, 681.38134765625, 107.34593200683594, 681.38134765625]];
var qdCityState = [[89.67312622070312, 685.30859375, 266.40118408203125, 685.30859375, 89.67312622070312, 666.3267211914062, 266.40118408203125, 666.3267211914062]];
var qdSocSec = [[106.69139099121094, 651.2720947265625, 166.90985107421875, 651.2720947265625, 106.69139099121094, 633.5993041992188, 166.90985107421875, 633.5993041992188]];
var qdAlow = [[106.03683471679688, 636.217529296875, 255.27386474609375, 636.217529296875, 106.03683471679688, 618.544677734375, 255.27386474609375, 618.544677734375]];
// Part 2: Function for adding Redact Annotations to a PDF function
AddMyRedacts(quadList) {
	for(var pg=1; pg<this.numPages; pg++) {
		for(var index=0; index<quadList.length; index++) {
			this.addAnnot({
				type:"Redact", page:pg,
				quads:quadList[index],
				overlayText: ":It's gone:",
				alignment: 1, // center alignment
				repeat:true });
			}
		}
	}
// Part3: Applying the redactions
// Code for two different redaction schemes
// Use only one per document
// #1 Run this code to apply redactions to W4 employee name
// and address
AddMyRedacts([qdFirstName, qdLastName, qdAdress, qdCityState, qdSocSec, qdAlow] );
this.applyRedactions({bKeepMarks: false, bShowConfirmation: true, cProgText: "It's going away" });

 

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
Community Expert ,
Sep 18, 2024 Sep 18, 2024

Copy link to clipboard

Copied

The word function at the end of the line that starts //Part 2 is getting commented out.  It should be on the next line.  The next line should read:

function AddMyRedacts(quadList) {

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
Community Beginner ,
Sep 18, 2024 Sep 18, 2024

Copy link to clipboard

Copied

I see what you mean, gonna see if that fixes anything

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
Community Expert ,
Sep 18, 2024 Sep 18, 2024

Copy link to clipboard

Copied

I fixed and tested.  It worked.  If you are going to use this in an Action on several docs at once you should set bShowConfirmation to false so you don't have to dismiss a popup message for each doc.

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
Community Beginner ,
Sep 18, 2024 Sep 18, 2024

Copy link to clipboard

Copied

Ok I'll try that.

Another thing, Do you know what line I would need to fix in order to keep it form repeating on multiple pages? (I only need it to apply the redaction to the first page)

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
Community Beginner ,
Sep 18, 2024 Sep 18, 2024

Copy link to clipboard

Copied

Disregard my follow up question, I figured it out.

Thanks so much for your help!

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
Community Beginner ,
Sep 18, 2024 Sep 18, 2024

Copy link to clipboard

Copied

Cant thank you enough, this will save me a lot of time

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
Community Beginner ,
Sep 19, 2024 Sep 19, 2024

Copy link to clipboard

Copied

I have a follow up question if you don't mind. 

 

How would I go about removing Step 3 from the code? I have some documents where I want the redactions placed but not applied. I've tried just deleting that portion but end up with errors. 

// Part 1: Quads for the different Redaction areas
var qdFirstName = [[283.41943359375, 1108.691650390625, 597.6026611328125, 1108.691650390625, 283.41943359375, 1075.9642333984375, 597.6026611328125, 1075.9642333984375]];
var qdLastName = [[294.5467529296875, 1050.4368896484375, 575.3480224609375, 1050.4368896484375, 294.5467529296875, 1000.6912231445312, 575.3480224609375, 1000.6912231445312]];
var qdAdress = [[24.872833251953125, 243.3787841796875, 587.784423828125, 243.3787841796875, 24.872833251953125, 14.94140625, 587.784423828125, 14.94140625]];
// Part 2: Function for adding Redact Annotations to a PDF 
function AddMyRedacts(quadList) {
	for(var pg=0; pg<this.numPages; pg++) {
		for(var index=0; index<quadList.length; index++) {
			this.addAnnot({
				type:"Redact", page:0,
				quads:quadList[index],
				overlayText: "",
				alignment: 1, // center alignment
				repeat:true });
			}
		}
	}
// Part3: Need to remove this part from code
AddMyRedacts([qdFirstName, qdLastName, qdAdress] );
this.applyRedactions({bKeepMarks: false, bShowConfirmation: false, cProgText: "" });

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
Community Beginner ,
Sep 19, 2024 Sep 19, 2024

Copy link to clipboard

Copied

LATEST

disregard, once again I made one small change that got me what i needed

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