Skip to main content
Participant
January 30, 2019
Answered

Changing images or image colours in a PDF with Javascript

  • January 30, 2019
  • 4 replies
  • 1297 views

Hi.

I have a big document with confidential information. We have to send it to a person, but we must to hide some information in it.

My collegue has been working in the document for several days adding white blocks wherever a critic information is. She added a white gif image and rearranged the size for every situation.

Now we have realized that the block should be black.

I tried to run a Javascript to change the colour of the blocks but i't doesn't work.

This is the code:

      // Get a color convert action

       var toBlack= this.getColorConvertAction();

   

       // Set up the action for a conversion to Black

       toBlack.matchAttributesAll = toBlack.constants.objectFlags.ObjImage

       toBlack.convertProfile = "Apple RGB";

       toBlack.convertIntent = toBlack.constants.renderingIntents.Document;

       toBlack.embed = true;

       toBlack.preserveBlack = true;

       toBlack.colorantName = "Black";

       toBlack.isProcessColor = true;

       toBlack.useBlackPointCompensation = true;

       toBlack.action = toBlack.constants.actions.Convert;

   

       // Convert the first page of the document

       var result = this.colorConvertPage(0,[toBlack],[]);

Any clue why it's not working or an alternative?

This topic has been closed for replies.
Correct answer Bernd Alheit

This is not possible with JavaScript.

4 replies

apascuaAuthor
Participant
February 1, 2019

Ok. Thanks everyone for the answers.

I wish we use Adobe more properly. But that's not the case. We scan documents as images, no ocr. And after that we hide information with the blocks. Then we print it. So there is no chance of anyone removing the blocks.

I know there has to be another way to do that. I'll look into that later.

But i need to know if is possible to change the colour of the blocks with javascript.

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
February 1, 2019

This is not possible with JavaScript.

Legend
January 30, 2019

If you think the GIF can be effective

1. What stops someone else removing it

2. Try this: go to text selecting, select all, copy. All text behind your covers will copy too.

try67
Community Expert
Community Expert
January 30, 2019

No, no, no! If you want to remove information from a PDF the only reliable way is by using the Redaction tool, and making sure to apply the redactions. Any other way can be overcome... Just ask Paul Manafort's lawyers.

Edit: apply the redactions, not reply...

Bernd Alheit
Community Expert
Community Expert
January 30, 2019

Adding gif images will not remove the confidential information. Use the Redaction Tool in Acrobat Pro.