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

Can I clear inserted images in a template page

Participant ,
Jun 02, 2023 Jun 02, 2023

Hi All,

Thaks to help from @Nesa Nurani  I have been able to create a document with a second page that is shown or hidden depending on a basic drop down selection [Group96.picsnotes1] for the additonal page (Yes or No seletion).
The second page conatins 4 image boxes [image(1-4)_af_image] and a text field for notes [notes1] each of the image boxes and the notes field have a group prefix Group95.


I have used the following code in the validation script to show/hide the second page:

var p2 = this.getTemplate("Page2");
var p = Number(this.numPages)-1;
if(this.numPages != 1)
this.deletePages(1,p);

if (event.value == "Yes")
p2.spawn(numPages, false,false);

 

And the following in the custom calculation script to clear the images and notes:

if (this.getField("Group96.picsnotes1").value=="n") {
this.resetForm("Group95");
}
 
However only the notes field is reset, any uploaded images are not cleared when the second page is hidden when selecting No (export value = n).

Is there a way to clear/delete the images when no is selected from the drop down to hide page 2?
 

 

TOPICS
Create PDFs , JavaScript , PDF , PDF forms
520
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Jun 02, 2023 Jun 02, 2023
Translate
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 ,
Jun 02, 2023 Jun 02, 2023

Image field doesn't have value, so you can't reset it.

Read this: http://khkonsulting.com/2017/03/clear-image-field-pdf-form-acrobats-javascript/ 

Translate
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 ,
Jun 02, 2023 Jun 02, 2023
LATEST

Button images are not data, so resetting the button field has no affect. The only way to clear an image from a button (using JavaScript) is to load another image.  I've used this technique before by placing a hidden button on the PDF that contains a blank image. 

However, you can also make the image disappear by setting the "field.buttonPosition" property to "position.textOnly". 

 

 

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

Translate
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