Skip to main content
Participant
March 25, 2020
Question

Image Field not able to change it to readonly?

  • March 25, 2020
  • 4 replies
  • 575 views

Hihi

 

Pls advise how do I make the image field uneditable or lock or compress or flatten such that user not able to click and add a new image? 

This is the code i used but it seems not working: 

-quote-

this.getField("Letterhead1_af_image").readonly = true;

-unquote-

 

All other text fields are working well. 

 

Thanks,

Yixiang

This topic has been closed for replies.

4 replies

Bernd Alheit
Community Expert
Community Expert
March 26, 2020

Did you check the properties of all fields?

Thom Parker
Community Expert
Community Expert
March 25, 2020

Where is this code used, i.e., when is it run?

Are any errors reported in the Console Window when the code is run?

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
ExiangAuthor
Participant
March 26, 2020

Hi 

 

Below is my full code. 

 

I have a button for user to click and the code should compress the fields including all the images. 

 

-code-

var cMsg = "Clicking on this button will render all information in this page to be locked. ";
cMsg += "\n\nPlease confirm all the information provided is final. Are you ready to proceed?";

var nRtn = app.alert(cMsg,2,2,"Question Alert Box");
if(nRtn == 3)
{
}
else if(nRtn == 4)
{ this.getField("Counterparty_pg1").readonly = true;
this.getField("Free1").readonly = true;
this.getField("Free2").readonly = true;
this.getField("Beneficiary").readonly = true;
this.getField("Relationship").readonly = true;
this.getField("Relationship2").readonly = true;
this.getField("Explanation").readonly = true;
this.getField("Name").readonly = true;
this.getField("Address").readonly = true;
this.getField("Country").readonly = true;
this.getField("PIC").readonly = true;
this.getField("PIC Phone").readonly = true;
this.getField("Bank name").readonly = true;
this.getField("Bank Address").readonly = true;
this.getField("Bank Country").readonly = true;
this.getField("Bank Swift").readonly = true;
this.getField("Beneficiary1").readonly = true;
this.getField("Account Currency").readonly = true;
this.getField("IBAN").readonly = true;
this.getField("Corr Bank Name").readonly = true;
this.getField("Corr Bank Swift").readonly = true;
this.getField("Signature circle_pg1").readonly = true;
this.getField("Signatory Name_pg1").readonly = true;
this.getField("Signatory Designation_pg1").readonly = true;
this.getField("Letterhead1_af_image").readonly = true;

}

 

-ends code-

 

Pls advise how to amend?

 

Thanks,

Yixiang

Legend
March 26, 2020

I've just run a simple test in Acrobat Pro 2020.006.20042, and I find that readonly can be set for an image field, and is respected.

I suggest you make a simple test PDF file with simpler code, see if the problem occurs, and share it if so.

Also please carefully answer ALL questions. Especially:

-Are any errors reported in the Console Window when the code is run?

Bernd Alheit
Community Expert
Community Expert
March 25, 2020

This will work when you use the correct name of the image field.

Legend
March 25, 2020

What do the users click on to add a new image? 

 

ExiangAuthor
Participant
March 25, 2020

Hihi, 

 

User open the file using adobe reader or DC. User can just click on the image field area and the pop up dialog box will appear to allow user to add new image or edit it. 

 

My case: the user fills up the image and text on all the field and upon clicking the "save" button, the file will compress or flatten such that no text or image can be edited again. I am having issue with the image. how should i do it?