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

Can you make a javascript run to delete all unfilled photo fields and fields with certain values and then delete the empty pages?

New Here ,
May 25, 2018 May 25, 2018

Copy link to clipboard

Copied

I am working to build a document for my company that we can use to include photos. Each photo document will have a different number of pictures and i would like an easy way for others to be able to delete unused photo fields and unused caption fields below the photos. After the fields are deleted I was hoping that there would also be a way to delete pages that don't have any photo fields present. I am very new to coding javascript, but i thought that i would give this a shot.

Here is the document that i have started. Any help is appreciated. thanks

https://drive.google.com/open?id=1vJ10Zv5QsVewcx0fSdvBcYKEw_uMheUR

Thanks

TOPICS
Acrobat SDK and JavaScript

Views

357

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 1 Correct answer

Community Expert , May 25, 2018 May 25, 2018

You might want to rethink your solution. Rather than have as many photo pages as you may ever need and then delete the ones that you don't... which will be hard to figure out... use page templates to spawn a new photo page only when one is needed. Much easier to do.

Votes

Translate

Translate
Community Expert ,
May 25, 2018 May 25, 2018

Copy link to clipboard

Copied

Is this file going to be used in Acrobat or in Reader, or in another application?

There's no point in deleting fields and then deleting the pages they're on. You can just delete the pages directly...

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 ,
May 25, 2018 May 25, 2018

Copy link to clipboard

Copied

This will be used in acrobat.

That makes since i just want to make sure that if there are 7 total photos that page 2 is not completely deleted, only the 5 unused photo fields and caption fields.

thanks for the 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 Expert ,
May 25, 2018 May 25, 2018

Copy link to clipboard

Copied

Deleting a field is easy. Finding out whether a button field has an image or not is not so easy...

To do the former just use the removeField method, like this:

this.removeField("Button1");

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 ,
May 25, 2018 May 25, 2018

Copy link to clipboard

Copied

To delete a page use the deletePages command, like this:

this.deletePages(3); // remove page 4

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 ,
May 25, 2018 May 25, 2018

Copy link to clipboard

Copied

Thanks, this seems to be a good place for me to start and possibly tweak somethings to work for this form.

thanks

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 ,
May 25, 2018 May 25, 2018

Copy link to clipboard

Copied

You might want to rethink your solution. Rather than have as many photo pages as you may ever need and then delete the ones that you don't... which will be hard to figure out... use page templates to spawn a new photo page only when one is needed. Much easier to do.

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 ,
May 25, 2018 May 25, 2018

Copy link to clipboard

Copied

LATEST

Thanks, after rethinking the solution and testing out spawning a new page. i think that this is a better solution to my problem.

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