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

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

Adobe Community Professional
Correct answer by Joel_Geraci | Adobe Community Professional

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.

TOPICS
Acrobat SDK and JavaScript

Views

112

Likes

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

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

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

Adobe Community Professional
Correct answer by Joel_Geraci | Adobe Community Professional

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.

TOPICS
Acrobat SDK and JavaScript

Views

113

Likes

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
May 25, 2018 0
Most Valuable Participant ,
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...

Likes

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
Reply
Loading...
May 25, 2018 0
New Here ,
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

Likes

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
Reply
Loading...
May 25, 2018 0
Most Valuable Participant ,
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");

Likes

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
Reply
Loading...
May 25, 2018 0
Most Valuable Participant ,
May 25, 2018

Copy link to clipboard

Copied

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

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

Likes

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
Reply
Loading...
May 25, 2018 0
New Here ,
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

Likes

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
Reply
Loading...
May 25, 2018 0
Adobe Community Professional ,
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.

Likes

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
Reply
Loading...
May 25, 2018 0
New Here ,
May 25, 2018

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
May 25, 2018 0